GuidesIntegrations

Integrations

Move one fragile workflow into Causet. The frontend, the database, and the other routes stay put. The route you choose keeps its auth and its response shape. Causet records the workflow behind it.

Use this for an endpoint whose failure is expensive to reconstruct: a refund, a provider webhook, a fulfillment step.

Shape

Client
  → existing API (auth, validate, response shape)
      → Causet (intent)
          → state + events (timeline)
          → projections / queries
          → outbound webhook
      → existing database (updated from the webhook, or still written by the API)

The route can return as soon as the intent is accepted.

Before and after

await refundService.processDirectly(refund)

That call is the whole workflow. A provider timeout leaves you with a failed request and a manual retry.

await client.submitIntent(
  'refund_stream',
  refund.id,
  'REFUND_REQUESTED',
  { refund_id: refund.id, order_id: refund.orderId },
  refund.id,
)
return Response.json({ status: 'accepted', refundId: refund.id }, { status: 202 })

refund.id is the intent id, so a retry of the same refund is the same intent. Products, orders, inventory, the public POST /api/orders/:id/refund contract, and the frontend stay in the existing app.

Point apiUrl at the host for the environment. Sandbox is https://sandbox.api.causet.cloud. Production is https://api.causet.cloud. The client setup is in SDK.

What Causet records

PieceExample
IntentREFUND_REQUESTED
Staterefund entity (status, attempts, risk_level)
EventsREFUND_APPROVED, REFUND_PROVIDER_SUBMISSION_STARTED, REFUND_COMPLETED
Timelinecauset inspect timeline --stream refund_stream --entity <id> --fork sandbox

A recorded processor result is the Payments example. The rules for that intent are in Intents and rules.

Check it

  1. Call the existing endpoint.
  2. Inspect the timeline for that entity on the sandbox fork.
  3. Confirm the webhook or the projection updated the app database.

A provider call still happens when a new intent runs. Replay of the recorded history does not call the provider again. The full walkthrough, including the spec layout, is Retrofit an existing app. Outbound delivery is in Webhooks.