How each case starts
The four ways a case starts, and what Run creates for each one: a route of your app, a public endpoint, a schedule or a subscription.
Every case on the map says how it starts with starts. Run creates exactly that, and nothing else: a case that starts in the app has no public endpoint, and a scheduled case cannot be called from outside.
starts | Who starts it | What Run creates |
|---|---|---|
in_app | a person, on a screen of your app | a route of your app, for that screen |
external | another app: a payment provider, Rappi, a partner | a public endpoint, with its schema and its idempotency key |
scheduled | the clock | a schedule, in your time zone |
event | another case, when it ends in an outcome | a subscription, with its own queue |
A case with no start is an orphan: nothing could ever run it, so the build stops and says which one.
in_app: a person, on a screen
id: order-for-tomorrow
actor: customer
starts: in_app
where: shop.order-for-tomorrowRun adds the route POST /_cases/order-for-tomorrow to your app. The screen at the case’s where calls it with the person’s Sypnia Data session, and the session says who the actor is. A person whose role is not among the case’s allowed actors gets 403, and one with no session gets 401. The route belongs to your app: it answers only to your own pages, never to other origins.
The answer is the outcome or the failure, typed, with the message for the person.
external: another app calls
id: rappi-order
actor: rappi
starts: { external: webhook, idempotency_key: rappi_order_id, signature: { header: X-Rappi-Signature, secret: RAPPI_SECRET } }Run publishes POST /hooks/rappi-order at your app’s address:
- The input is checked against the case’s schema before your code runs; anything else gets
422. - Who is calling is proved with a case key (
Authorization: Bearer syp_rck_…, made withrun cases keys create rappi --case rappi-order, good for that one case only) or, as here, with the caller’s signature: an HMAC of the body with a secret you keep in Run. - The idempotency key names a field of the input. A second call with the same
rappi_order_idwithin 24 hours gets the first answer again, and the case does not run twice: a resent order is not baked twice.
scheduled: the clock
id: check-weather
actor: system
starts: { scheduled: every 2h, timezone: America/Bogota }Run creates a schedule, exactly as for a scheduled job: a cron expression or every <n>m|h|d, in the time zone you name, with summer time handled. A run that is still going when the next one is due is skipped, unless the start says overlap: allow. Like every schedule, it runs at least once per time, so the case must do no harm if it runs twice. run cases trigger check-weather runs it now, by hand.
event: another case ended
id: pause-deliveries
actor: system
starts: { event: weather.check-weather.RainExpected.v1 }The case runs each time check-weather ends in RainExpected. Run creates a subscription for it: a queue of its own, its own retries and its own place for messages that keep failing. One listener that fails never slows another. How outcomes travel, and what Run guarantees, is in Outcomes and events.
An event start can also:
| Write | To |
|---|---|
{ on: [orders.order-for-tomorrow.OrderPlaced.v1, orders.rappi-order.OrderPlaced.v1] } | run on any of several outcomes |
{ on_all: [payments.pay.Paid.v1, kitchen.bake.Baked.v1], key: order_id, within: 2h } | run once all of them happened for the same order_id, within two hours; if the two hours pass first, nothing runs and the wait ends as WindowExpired, visible in Telemetry |
{ event: …, filter: { total: { gte: 100000 } } } | run only when the outcome’s data matches |
{ event: …, order_by: order_id } | handle the events of one order_id in order |
A case can only listen to the public outcomes of another area: what an area keeps internal stays inside it, and the build refuses a listener that reaches for it.