Create event subscription
Code Mode: praxis.events.subscriptions.create
HTTP: POST /events/v1/subscriptions
Ask to be told, as an inbox letter, when something happens to a resource of your organization. Typical use: an agent that started an automation run subscribes to automation.run.finished with filters: [{ exact: { subject: "runs/<run id>" } }], then ends its turn; when the run finishes, one letter of kind event arrives in the agent’s inbox and wakes it. With codemode: const run = await praxis.automation.runs.create({ ... }); await praxis.events.subscriptions.create({ types: ["automation.run.finished"], filters: [{ exact: { subject: runs/${run.id} } }] }); Name 1 to 10 types from events.types.list; filters must all hold, may be empty, and use exact or prefix on subject, actor or a data.<field> the type declares. once defaults to true: the first match writes one letter and the subscription ends. Set once false for a standing subscription, which delivers at most 30 letters an hour, counts the matches it holds back, and never delivers an event whose actor is its own sink. expires_at defaults to 7 days from now and may be at most 30 days; a subscription past it stops matching. The sink is the caller’s own inbox; the organization comes from your credential and is not a field. The letter’s summary is <type> · <subject> and its body is the event, with the type’s sensitive fields removed. Errors: 400 UNSUPPORTED_FILTER_DIALECT for any filter form other than exact and prefix; 400 INVALID_PARAMS for a type that is not a tenant type, a filter field the type does not declare, a field not listed here (the organization is never a field), too many types or filters, or an expires_at beyond 30 days; 503 PROVIDER_UNAVAILABLE (retryable) when the catalog cannot be read, wait and call again.
签名
praxis.events.subscriptions.create(args:{body:{/** The tenant event types to hear about, from events.types.list; an event of any one of them can match. */ types:Array<string>;/** Conditions that must all hold for an event to match; omit or leave empty to match every event of the types. */ filters?:Array<{/** The attribute equals the value, for example { subject: "runs/run_1" } or { "data.status": "faulted" }. */ exact?:{[key:string]:string};/** The attribute starts with the value, for example { subject: "runs/" }. */ prefix?:{[key:string]:string}}>;/** The inbox address that receives the letters, agent:<id> or human:<id>. e.g. "agent:agent_0123456789abcdef" */ sink?:string;/** True (the default) ends the subscription after the first letter; false keeps it until expires_at, at most 30 letters an hour. */ once?:boolean;/** When the subscription ends, RFC 3339. e.g. "2026-12-11T00:00:00Z" */ expires_at?:string}}):Promise<{/** The subscription id, esub_...; use it to retrieve or delete it. */ id:string;/** The tenant event types it listens to. */ types:Array<string>;/** The conditions that must all hold; empty means every event of the types. */ filters:Array<{/** The attribute equals the value, for example { subject: "runs/run_1" } or { "data.status": "faulted" }. */ exact?:{[key:string]:string};/** The attribute starts with the value, for example { subject: "runs/" }. */ prefix?:{[key:string]:string}}>;/** The inbox address the letters go to, agent:<id> or human:<id>. */ sink:string;/** Whether the subscription ends after its first letter. */ once:boolean;/** When the subscription ends and stops matching, RFC 3339. */ expires_at:string;/** When the subscription was created, RFC 3339. */ created_at:string;/** The address that created it, agent:<id> or human:<id>; only that caller can see it. */ created_by:string}>;请求体
| 必填 | 内容类型 | 说明 |
|---|---|---|
| 是 | application/json | What to subscribe to and how long the subscription lasts. |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 201 | application/json | The new subscription. |
| 400 | application/problem+json | UNSUPPORTED_FILTER_DIALECT means a filter used a form other than exact and prefix; INVALID_PARAMS means a field, type, filter name, count, date or query value is not accepted, and the message names it. Correct the request; retrying it unchanged fails again. |
| 401 | application/problem+json | UNAUTHENTICATED means the credential is missing or invalid; send a valid Praxis credential of your organization. |
| 503 | application/problem+json | PROVIDER_UNAVAILABLE with retryable true means the event catalog or the inbox service cannot answer right now; wait a few seconds and repeat the same call. |