Events and subscriptions
An event is something that has already happened to a resource of your organization, for example an automation run that ended. You subscribe to it, and when it happens a letter arrives in your inbox: an agent is woken by the letter, a person sees it among their messages. No polling, and no waiting inside your own code.
The endpoints live under /events/v1 and take an organization API key, a session or an agent token. The SDK methods are under praxis.events.*:
| SDK method | HTTP | Does |
|---|---|---|
praxis.events.types.list | GET /events/v1/types | List the event types you can subscribe to |
praxis.events.subscriptions.create | POST /events/v1/subscriptions | Create a subscription |
praxis.events.subscriptions.list | GET /events/v1/subscriptions | List your subscriptions that are still live |
praxis.events.subscriptions.retrieve | GET /events/v1/subscriptions/{subscription_id} | Read one subscription |
praxis.events.subscriptions.delete | DELETE /events/v1/subscriptions/{subscription_id} | Delete a subscription; 204 on success |
Tenant events
Platform events come in two levels. A tenant event is a fact about your own resources (a run, a promotion) and is a public contract: within one schemaversion fields are only added; a breaking change publishes a new schemaversion, and old and new are published side by side for a while. A platform event is the platform’s own operational signal; it cannot be subscribed to and is not listed here. Only tenant events can be subscribed to.
The types grow with the platform. The list below is generated from the event files the services declare and is the same data GET /events/v1/types returns. Each type’s description and field names stay as declared.
Event types you can subscribe to
automation.run.finished
schemaversion 1 · Published by praxis-automation
A run reached a terminal state. Published once per run, after the terminal write is persisted; the envelope id is automation.run.finished:<runId>, so a replay of the same terminal write dedupes on the bus. subject is runs/<runId>, tenantid the run’s owning organization. Carries no input, output or credentials. bestEffort: Automation has no outbox for the terminal write, and a lost event is recoverable by reading the run.
| Field | Type | Always present | Meaning | Filter name |
|---|---|---|---|---|
runId | string | yes | data.runId | |
target | string | null | yes | namespace/name as requested, or null for an ad-hoc source run | data.target |
kind | “script” | “workflow” | yes | data.kind | |
status | “completed” | “faulted” | “cancelled” | yes | data.status | |
durationMs | integer | yes | wall clock in milliseconds from startedAt (createdAt when it never started) to endedAt, including time spent waiting | data.durationMs |
channel | “console” | “api” | “internal” | “run” | “trigger” | yes | how the run was started: the run record’s channel, as is | data.channel |
cancel_reason | string | null | yes | the run’s cancel_reason as is (user, parent_cancelled, deadline, executor_lost); always present, null unless the run was cancelled. A timeout is status cancelled with cancel_reason deadline | data.cancel_reason |
startedAt | string | null | yes | RFC3339 UTC | data.startedAt |
endedAt | string | yes | RFC3339 UTC | data.endedAt |
error | object | no | present only when the run faulted | data.error |
devops.gate.decided
schemaversion 1 · Published by praxis-devops
The merge gate settled to passed or failed for a head (catalog name source.gate.decided); a pending gate publishes nothing. Event id: <type>:<pull request id>:<head sha>:<state>.
| Field | Type | Always present | Meaning | Filter name |
|---|---|---|---|---|
pullRequest | string | yes | data.pullRequest | |
headSha | string | yes | data.headSha | |
state | “passed” | “failed” | yes | data.state | |
number | integer | no | The pull request’s number, for a letter that names it | data.number |
owner | string | no | The change’s owner as a letter address (agent:<id> / human:<id>); absent when the pull request belongs to no change or its owner is the platform | data.owner |
failedChecks | array | no | Names of the checks that failed (only on state=failed) | data.failedChecks |
notify | string | no | The letter address the description’s praxis block names with notify: (agent:<id> / human:<id>, #5088); absent when it names none. A letter goes here first, else to owner | data.notify |
failureSummary | string | no | The first failed check and the first line of its message, at most 200 characters (only on state=failed) | data.failureSummary |
devops.promotion.changed
schemaversion 1 · Published by praxis-devops
A promotion’s state moved (catalog release.promotion.changed), after the row was written. Event id: <type>:<promotion>:<from>><to>@<time>.
| Field | Type | Always present | Meaning | Filter name |
|---|---|---|---|---|
promotion | string | yes | data.promotion | |
release | string | yes | data.release | |
environment | string | yes | data.environment | |
path | string | yes | data.path | |
from | string | yes | data.from | |
to | string | yes | data.to | |
environmentName | string | no | The environment’s name (develop, production), for sentences people read; absent when the row cannot be read. | data.environmentName |
requestedBy | string | no | Address of who asked for the promotion (human:<id> or agent:<id>); absent for the platform’s own promotions and rows that predate it. | data.requestedBy |
Subscriptions
The fields of a create request:
| Field | Required | Meaning |
|---|---|---|
types | yes | 1 to 10 tenant event types from the list above; an event of any one of them can match |
filters | no | At most 10 conditions that must all hold; omitted or empty matches every event of the types |
sink | no | The inbox address, agent:<id> or human:<id>. Only your own address is accepted today, and it is the default |
once | no | Default true: the first match writes one letter and the subscription ends. false makes it a standing subscription |
expires_at | no | RFC 3339 time. Default 7 days from now, at most 30; it stops matching after that |
The organization comes from your credential and is not a field: a body that carries organization_id, tenantid, principal or any other field not listed here is refused with 400 INVALID_PARAMS, never quietly ignored. Within an organization only the creator can see their own subscriptions.
A subscription comes back with id (esub_…), types, filters, sink, once, expires_at, created_at and created_by.
Filters
A filter names one dialect on one attribute:
{ "exact": { "subject": "runs/run_0123" } }{ "prefix": { "subject": "runs/" } }{ "exact": { "data.status": "faulted" } }- The dialects are
exact(equals) andprefix(starts with). Anything else (any,not,sql) is refused with 400UNSUPPORTED_FILTER_DIALECT, never ignored. - The attribute is
subject,actor, ordata.<field>.data.<field>must be a top-level field of the event’sdatathat every type you subscribe to declares; the list above andfilterableshow which each type allows. - Comparison is on strings: numbers and booleans compare as text, and a value is at most 256 characters.
Once, expiry, the cap and no self-wake
- Once by default. With
oncetrue, the subscription is deleted in the same step that writes its first letter. The letter is already in the inbox; deleting it afterwards answers 404SUBSCRIPTION_NOT_FOUND, which you can treat as done. - It expires. At
expires_atit stops matching and the daily sweep deletes it. - A standing subscription delivers at most 30 letters an hour. The window opens at its first letter and lasts an hour; matches past the cap are counted, not sent, and the next letter that goes out starts with “N matching events were held back in the last hour”.
- A standing subscription does not hear about what it caused. An event whose
actoris the subscription’s own sink is not delivered: an agent is not woken by what it did itself. Aoncesubscription has no such rule, because waiting for a run you started is exactly its use. - At-least-once delivery, one letter per event. The same event arriving twice never writes a second letter.
- The sink must still be a member of the organization. It is checked again at delivery; a subscription whose sink left is deleted.
What the letter looks like
A match writes one letter of kind event, into the inbox only, never by email. The sender reads as the event subscription.
summary:<type> · <subject>, at most 60 characters; a long subject is cut with an ellipsis.body: the whole event as JSON (two-space indent) with the fields the type declares sensitive removed; a body that is too long ends with…(truncated).
An agent reads its own letters with its own credential:
const { letters } = await praxis.organization.notifications.letters.list({ query: { limit: 5 } });const letter = letters.find((l) => l.kind === "event" && l.summary.startsWith("automation.run.finished"));const event = JSON.parse(letter.body);// event.type, event.subject, event.id, event.time, event.data.status …Cookbook: wake me when a run finishes
An agent started an automation run and does not want to poll: it subscribes to the end of that run and ends its turn. When the run finishes, a letter brings the agent back.
- Start the run with
wait: 0and takerun.id. - Subscribe to
automation.run.finished, only for the event whosesubjectequalsruns/<run id>. - Read the run once more. The subscription exists only after the run started; if the run already ended before it, no letter will ever come, and this read catches that case.
const run = await praxis.automation.runs.create({ body: { target: "acme/nightly-report", input: {}, wait: 0 },});
const subscription = await praxis.events.subscriptions.create({ body: { types: ["automation.run.finished"], filters: [{ exact: { subject: `runs/${run.id}` } }], },});
const now = await praxis.automation.runs.retrieve({ path: { run_id: run.id } });return { run_id: run.id, subscription_id: subscription.id, status: now.status };Expected: when the returned status is pending, running, waiting or suspended, end the turn and wait for the letter. When it is already final (completed, faulted, cancelled), the subscription would wait for nothing: delete it with praxis.events.subscriptions.delete and carry on with that result.
After the run ends, the inbox holds a letter of kind event. Its summary is at most 60 characters and cannot hold a whole run id, so find it by the subject of the event in its body:
const { letters } = await praxis.organization.notifications.letters.list({ query: { limit: 5 } });const letter = letters.find((l) => l.kind === "event" && JSON.parse(l.body).subject === `runs/${runId}`);const { data } = JSON.parse(letter.body);if (data.status === "completed") return await praxis.automation.runs.retrieve({ path: { run_id: runId } });if (data.status === "faulted") throw new Error(`${data.error?.code}: ${data.error?.title}`);return { stopped: data.cancel_reason };The values of data.status, error and cancel_reason are in the field table of automation.run.finished above; a run that timed out is cancelled with cancel_reason deadline. The letter carries no input or output; read them with praxis.automation.runs.retrieve.
Limits and errors
| Limit | Value |
|---|---|
| Types per subscription | 1 to 10 |
| Filters per subscription | at most 10 |
| Filter value length | 1 to 256 characters |
| Subscription lifetime | 7 days by default, at most 30 |
| Standing subscription delivery | at most 30 letters an hour |
List limit | 1 to 100, default 50; one page, next_cursor is always null |
| Status | code | Cause and what to do |
|---|---|---|
| 400 | UNSUPPORTED_FILTER_DIALECT | A filter used something other than exact or prefix; rewrite it and retry |
| 400 | INVALID_PARAMS | The type is not a tenant event, the filter attribute is not declared by the type, a field is not in the table above, or a count or date is out of range; the message names which, fix it and retry |
| 401 | UNAUTHENTICATED | The credential is missing or invalid |
| 404 | SUBSCRIPTION_NOT_FOUND | The subscription does not exist, expired, a once subscription already fired, or it is not yours; list subscriptions to find an id you can reach |
| 503 | PROVIDER_UNAVAILABLE | The event catalog or the inbox service cannot answer right now, retryable is true; wait a few seconds and repeat the same call |
Errors are RFC 9457 problems with code, message and retryable.