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
GET /api/v1/runtime/applications/{applicationId}/events?environment=Production&after={cursor}&types=tenant.created,tenant.deleted&limit=100Send 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.
| Query | Meaning |
|---|---|
environment | Development, Staging or Production. Default Production, or the key's own environment if it is tied to one. |
after | The nextCursor from your previous response. Leave it out on your first call. |
since | An ISO time. Used only when there is no after: return events from that moment on. |
types | Comma-separated event types, up to 20. |
limit | 1 to 500, default 100. |
{
"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
GET /api/v1/runtime/applications/{applicationId}/events/{eventId}?environment=ProductionReturns the event, or 404 if it does not exist for this application and environment, or is older than 30 days.
From the command line
# 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.createdWhat 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.
GET /api/v1/runtime/applications/{applicationId}/events/stream?environment=Production&tenantId={tenantId}&types=entitlement.changed
Accept: text/event-streamSame 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 JSONdata:body (id,type,tenantId,environment,occurredAtUtc,data). Thedatais the same payload the webhook carries. - The
readyframe, the last event of each batch and every keepalive carry anid:. A browserEventSourcesends the latest one back asLast-Event-IDwhen it reconnects, and the stream then replays everything you missed (up to 30 days), even if the connection dropped before any event arrived. With noLast-Event-IDthe stream starts from now. You can also passafter=<cursor>(thenextCursorfrom the pull API); it wins overLast-Event-IDwhen 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: endand areason:max_lifetimeafter 15 minutes (reconnect with the last id; nothing is lost),authorization_changedif the key was revoked or expired, the key no longer holds thewebhooks.managescope 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).erroris also sent if the server fails unexpectedly after the stream opened, orcursor_expired/errorif the position can no longer be read. Delivery is at least once, so use the eventidto ignore repeats. - One application can hold 25 streams open per API instance (the count is kept in each instance, not shared). The 26th gets
429withstream_limit. A resume id older than 30 days gets410withcursor_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.