Use cases

These examples show the same primitives in different domains:

  • Send a notification with push.
  • Render durable UI with content and detail.
  • Update state with replace.
  • Add timeline history with append.
  • Route signed response.submitted webhook events.

Shared backend shape

backend pattern
const notification = await roundtrip.notify({
  channel,
  push,
  content,
  detail,
  response: {
    mode: "required",
    behavior: "resolve",
    webhook: "https://api.example.com/roundtrip/webhooks",
  },
  metadata: { domainId },
  idempotency: [domain, domainId, "open"],
});

await saveNotificationId(domainId, notification.id);

Use the webhook event to continue the domain workflow:

webhook
const event = await roundtrip.webhooks.unwrap({
  rawBody,
  headers,
  secret: process.env.ROUNDTRIP_WEBHOOK_SECRET!,
});

await router.dispatch(event);