Skip to content

Pull events: catch up after downtime ​

Webhooks tell your backend when something happens. If your server was down, or sits behind a firewall that blocks inbound calls, you can instead ask TenancyEngine "what happened since I last looked". Both give you the same JSON body for an event, so one handler can serve both.

Events are kept for 30 days.

List events ​

http
GET /api/v1/runtime/applications/{applicationId}/events?environment=Production&after={cursor}&types=tenant.created,tenant.deleted&limit=100

Send your organization API key with the webhooks.manage scope. The key must be allowed to address the environment you name. A key tied to one environment reads that environment only.

QueryMeaning
environmentDevelopment, Staging or Production. Default Production, or the key's own environment if it is tied to one.
afterThe nextCursor from your previous response. Leave it out on your first call.
sinceAn ISO time. Used only when there is no after: return events from that moment on.
typesComma-separated event types, up to 20.
limit1 to 500, default 100.
jsonc
{
  "events": [
    {
      "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
      "type": "tenant.created",
      "tenantId": "0b1c2d3e-0000-4000-8000-000000000001",
      "environment": "Production",
      "occurredAtUtc": "2026-10-17T10:02:11Z",
      "data": { "tenantId": "0b1c2d3e-0000-4000-8000-000000000001" }   // exactly the body a webhook would carry
    }
  ],
  "nextCursor": "djEuNDIuMTc5MjI0NTcyMQ",
  "hasMore": false
}

Store nextCursor after you have handled a page. Next time, pass it as after. Events come back in order, with no gaps and no repeats, even while new events arrive. When hasMore is true, call again straight away with the new cursor.

Events from the last few seconds appear after a short delay (about 3 seconds). This is what keeps a late-committing event from being skipped.

The cursor is opaque. Do not build or edit one.

If you wait longer than 30 days between calls the cursor stops working and you get 410 with cursor_expired. Start again without after, or with since.

Get one event ​

http
GET /api/v1/runtime/applications/{applicationId}/events/{eventId}?environment=Production

Returns the event, or 404 if it does not exist for this application and environment, or is older than 30 days.

From the command line ​

bash
# Everything since 10:00, then print the cursor to resume from
te events list --app my-app --environment Production --since 2026-10-17T10:00:00Z --all

# Follow new events as they happen (outbound HTTPS only)
te events tail --app my-app --environment Development --types tenant.created

What is included ​

Events that belong to one tenant, and events for one application. Organization-wide totals with no tenant (billing and usage roll-ups) are not in this list, because they belong to no single application. Receive those by webhook.

Events with no tenant that belong to one application are filed under Production.

Follow events live (server-sent events) ​

If your app should react within seconds (a tenant upgrades and the feature unlocks), keep a stream open instead of polling.

http
GET /api/v1/runtime/applications/{applicationId}/events/stream?environment=Production&tenantId={tenantId}&types=entitlement.changed
Accept: text/event-stream

Same key, scope (webhooks.manage) and environment rules as the pull API. tenantId and types are optional; with tenantId the stream carries that tenant's events only.

  • Each event arrives as event: <type> with a JSON data: body (id, type, tenantId, environment, occurredAtUtc, data). The data is the same payload the webhook carries.
  • The ready frame, the last event of each batch and every keepalive carry an id:. A browser EventSource sends the latest one back as Last-Event-ID when it reconnects, and the stream then replays everything you missed (up to 30 days), even if the connection dropped before any event arrived. With no Last-Event-ID the stream starts from now. You can also pass after=<cursor> (the nextCursor from the pull API); it wins over Last-Event-ID when both are sent.
  • A keepalive (: keepalive) is sent about every 15 seconds. Events from the last few seconds appear after the same short delay as the pull API. As with the pull API, an event that commits late with a lower internal position than one already delivered can be missed by a long-lived cursor; webhooks remain the guaranteed channel.
  • A stream ends with event: end and a reason: max_lifetime after 15 minutes (reconnect with the last id; nothing is lost), authorization_changed if the key was revoked or expired, the key no longer holds the webhooks.manage scope or may no longer address the streamed environment, the organization was deactivated or its subscription or the application's entitlement was suspended, or the application was removed (all re-checked about every 15 seconds, so access ends within that window rather than at the 15 minute mark; the key's IP allowlist and its application, environment and tenant binding are decided at connect and are not re-checked while a stream is open). error is also sent if the server fails unexpectedly after the stream opened, or cursor_expired / error if the position can no longer be read. Delivery is at least once, so use the event id to ignore repeats.
  • One application can hold 25 streams open per API instance (the count is kept in each instance, not shared). The 26th gets 429 with stream_limit. A resume id older than 30 days gets 410 with cursor_expired.
  • The key stays on your server. This endpoint is not meant for browsers directly; a short-lived browser stream token is not part of this release.

TenancyEngine platform documentation