Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Subscriptions

What to do with the events that match a filter: deliver them to an endpoint, or notify principals in their inbox. A change to the filter or target is a new version, and every match records the version it used.

Subscriptions explains filters, targets, versions, and matching.

Paths are relative to https://api.agentpost.tools/v1/events, and every request follows the API basics. Who may call explains each kind of caller.

Create a subscription

POST /subscriptions

Creates a subscription. Events accepted from now on that match its filter are matched to it as they are accepted.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Idempotency-Key: optional. Retrying a write has the rule.

Body

Name Type Required Description
name string Yes 1–200 characters.
description string No Up to 2000 characters.
filter object Yes
filter.types string[] No 1–50 items.
filter.sources string[] No 1–50 items.
filter.extensions object No Each value is a string or string[].
filter.workspace string No The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
filter.subject string No 1–500 characters.
filter.refs object[] No 1–20 items.
filter.refs[].type string Yes 1–100 characters.
filter.refs[].id string No 1–500 characters.
filter.where object No Each value is a string or string[].
target object Yes
target.kind string Yes One of "webhook" or "notification".
target.endpointId string No With kind: "webhook".
target.topic string No With kind: "notification".
target.recipients object No With kind: "notification".
target.recipients.ids string[] No 1–100 items.
target.recipients.fromPaths string[] No 1–10 items.
target.recipients.followers boolean No
target.template object No With kind: "notification".
target.template.title string Yes 1–500 characters.
target.template.body string No Up to 4000 characters.
target.template.url string No Up to 2048 characters.
target.template.push object No
target.template.push.title string No Up to 200 characters.
target.template.push.body string No Up to 1000 characters.
target.template.push.sound string or null No The sound a push plays: left out, the device’s default sound; null, a silent push; or the name of a sound your app bundles.

Response

201 Created, with:

Name Type Present Description
subscription SubscriptionRecord Always

Errors

Any operation can also answer with the codes Conventions lists.

List subscriptions

GET /subscriptions

Subscriptions, newest first. Deleted ones are listed only when status=deleted asks for them.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Pages: limit, 1 to 200, default 50, with next and after. Lists has the rule.

Query parameters

Name Type Required Description
status string No One of "active", "paused", or "deleted".
endpointId string No
after string No
limit integer No 1–200; default 50.

Response

200 OK, with:

Name Type Present Description
subscriptions SubscriptionRecord array Always
next string When set

Errors

Any operation can also answer with the codes Conventions lists.

Test a subscription

POST /subscriptions/test

Whether a filter, or a subscription’s current filter, matches an event, given inline or by its sequence, with each clause’s outcome. Nothing is written.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Idempotency-Key: not taken. This route writes nothing, so it takes no Idempotency-Key.

Body

Name Type Required Description
filter object No
filter.types string[] No 1–50 items.
filter.sources string[] No 1–50 items.
filter.extensions object No Each value is a string or string[].
filter.workspace string No The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
filter.subject string No 1–500 characters.
filter.refs object[] No 1–20 items.
filter.refs[].type string Yes 1–100 characters.
filter.refs[].id string No 1–500 characters.
filter.where object No Each value is a string or string[].
subscriptionId string No
event any No
sequence integer No At least 1.

Response

200 OK, with SubscriptionTestResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Get a subscription

GET /subscriptions/:id

One subscription, as its current version.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Response

200 OK, with:

Name Type Present Description
subscription SubscriptionRecord Always

Errors

Any operation can also answer with the codes Conventions lists.

Update a subscription

PATCH /subscriptions/:id

Changes a subscription. A new filter or target makes a new version, used for events accepted from then on; a new name or description doesn’t.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Body

Name Type Required Description
name string No 1–200 characters.
description string or null No
filter object No
filter.types string[] No 1–50 items.
filter.sources string[] No 1–50 items.
filter.extensions object No Each value is a string or string[].
filter.workspace string No The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
filter.subject string No 1–500 characters.
filter.refs object[] No 1–20 items.
filter.refs[].type string Yes 1–100 characters.
filter.refs[].id string No 1–500 characters.
filter.where object No Each value is a string or string[].
target object No
target.kind string Yes One of "webhook" or "notification".
target.endpointId string No With kind: "webhook".
target.topic string No With kind: "notification".
target.recipients object No With kind: "notification".
target.recipients.ids string[] No 1–100 items.
target.recipients.fromPaths string[] No 1–10 items.
target.recipients.followers boolean No
target.template object No With kind: "notification".
target.template.title string Yes 1–500 characters.
target.template.body string No Up to 4000 characters.
target.template.url string No Up to 2048 characters.
target.template.push object No
target.template.push.title string No Up to 200 characters.
target.template.push.body string No Up to 1000 characters.
target.template.push.sound string or null No The sound a push plays: left out, the device’s default sound; null, a silent push; or the name of a sound your app bundles.

Response

200 OK, with:

Name Type Present Description
subscription SubscriptionRecord Always

Errors

Any operation can also answer with the codes Conventions lists.

Delete a subscription

DELETE /subscriptions/:id

Deletes a subscription: it matches nothing more, and its matches and deliveries are kept.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Response

204 No Content, with no body.

Errors

Any operation can also answer with the codes Conventions lists.

List subscription versions

GET /subscriptions/:id/versions

Every version of a subscription’s filter and target, oldest first, with when each was in force.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Response

200 OK, with:

Name Type Present Description
versions SubscriptionVersionRecord array Always

Errors

Any operation can also answer with the codes Conventions lists.

List subscription matches

GET /subscriptions/:id/matches

The events a subscription matched, newest first, with the version each used.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Pages: limit, 1 to 200, default 50, with next and after. Lists has the rule.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Query parameters

Name Type Required Description
eventSequence integer No At least 1.
from string No An ISO 8601 date and time.
after string No
limit integer No 1–200; default 50.

Response

200 OK, with:

Name Type Present Description
matches MatchRecord array Always
next string When set

Errors

Any operation can also answer with the codes Conventions lists.

Pause a subscription

POST /subscriptions/:id/pause

Pauses matching for new events. Resuming the subscription applies to future events. For a webhook subscription, replay the paused window to send the missed events.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Response

200 OK, with:

Name Type Present Description
subscription SubscriptionRecord Always

Errors

Any operation can also answer with the codes Conventions lists.

Resume a subscription

POST /subscriptions/:id/resume

Resumes a paused subscription for events accepted from now on. For a webhook subscription, replay the paused window to send the missed events.

  • Who may call: Your server, with your project’s secret key.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A subscription ID, sub_…. The id of a SubscriptionRecord.

Response

200 OK, with:

Name Type Present Description
subscription SubscriptionRecord Always

Errors

Any operation can also answer with the codes Conventions lists.

The SubscriptionRecord object

Name Type Present Description
id string Always A subscription ID, sub_….
name string Always
description string When set
status string Always One of "active", "paused", or "deleted".
version number Always
filter object Always
filter.types string[] When set 1–50 items.
filter.sources string[] When set 1–50 items.
filter.extensions object When set Each value is a string or string[].
filter.workspace string When set The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
filter.subject string When set 1–500 characters.
filter.refs object[] When set 1–20 items.
filter.refs[].type string Always 1–100 characters.
filter.refs[].id string When set 1–500 characters.
filter.where object When set Each value is a string or string[].
constraint object When set What the credential that set this version’s filter could read, when that was less than every event. An event matches only when it meets both.
constraint.types string[] When set 1–50 items.
constraint.sources string[] When set 1–50 items.
constraint.extensions object When set Each value is a string or string[].
constraint.workspace string When set The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
constraint.subject string When set 1–500 characters.
constraint.refs object[] When set 1–20 items.
constraint.refs[].type string Always 1–100 characters.
constraint.refs[].id string When set 1–500 characters.
constraint.where object When set Each value is a string or string[].
target object Always
target.kind string Always One of "webhook" or "notification".
target.endpointId string When set With kind: "webhook".
target.topic string When set With kind: "notification".
target.recipients object When set With kind: "notification".
target.recipients.ids string[] When set 1–100 items.
target.recipients.fromPaths string[] When set 1–10 items.
target.recipients.followers boolean When set
target.template object When set With kind: "notification".
target.template.title string Always 1–500 characters.
target.template.body string When set Up to 4000 characters.
target.template.url string When set Up to 2048 characters.
target.template.push object When set
target.template.push.title string When set Up to 200 characters.
target.template.push.body string When set Up to 1000 characters.
target.template.push.sound string or null When set The sound a push plays: left out, the device’s default sound; null, a silent push; or the name of a sound your app bundles.
createdAt string Always
createdBy string Always
updatedAt string Always

The SubscriptionTestResponse object

Name Type Present Description
matched boolean Always
steps object[] Always
steps[].clause string Always status, constraint, filter, types, sources, workspace, subject, extensions.<name>, refs, or where.<path>.
steps[].outcome string Always One of "matched" or "not_matched".
steps[].detail string Always

The SubscriptionVersionRecord object

Name Type Present Description
subscriptionId string Always A subscription ID, sub_….
version number Always
filter object Always
filter.types string[] When set 1–50 items.
filter.sources string[] When set 1–50 items.
filter.extensions object When set Each value is a string or string[].
filter.workspace string When set The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
filter.subject string When set 1–500 characters.
filter.refs object[] When set 1–20 items.
filter.refs[].type string Always 1–100 characters.
filter.refs[].id string When set 1–500 characters.
filter.where object When set Each value is a string or string[].
constraint object When set
constraint.types string[] When set 1–50 items.
constraint.sources string[] When set 1–50 items.
constraint.extensions object When set Each value is a string or string[].
constraint.workspace string When set The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters.
constraint.subject string When set 1–500 characters.
constraint.refs object[] When set 1–20 items.
constraint.refs[].type string Always 1–100 characters.
constraint.refs[].id string When set 1–500 characters.
constraint.where object When set Each value is a string or string[].
target object Always
target.kind string Always One of "webhook" or "notification".
target.endpointId string When set With kind: "webhook".
target.topic string When set With kind: "notification".
target.recipients object When set With kind: "notification".
target.recipients.ids string[] When set 1–100 items.
target.recipients.fromPaths string[] When set 1–10 items.
target.recipients.followers boolean When set
target.template object When set With kind: "notification".
target.template.title string Always 1–500 characters.
target.template.body string When set Up to 4000 characters.
target.template.url string When set Up to 2048 characters.
target.template.push object When set
target.template.push.title string When set Up to 200 characters.
target.template.push.body string When set Up to 1000 characters.
target.template.push.sound string or null When set The sound a push plays: left out, the device’s default sound; null, a silent push; or the name of a sound your app bundles.
effectiveFrom string Always
effectiveTo string When set

The MatchRecord object

Name Type Present Description
id string Always A match ID, mat_….
eventSequence number Always
subscriptionId string Always A subscription ID, sub_….
subscriptionVersion number Always
cause "ingest" or "replay" Always
replayId string When set
decidedAt string Always