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
devsecret key,sk_test_…, asAuthorization: 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. |
string[] |
No | 1–50 items. |
filter. |
string[] |
No | 1–50 items. |
filter. |
object |
No | Each value is a string or string[]. |
filter. |
string |
No | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
filter. |
string |
No | 1–500 characters. |
filter. |
object[] |
No | 1–20 items. |
filter. |
string |
Yes | 1–100 characters. |
filter. |
string |
No | 1–500 characters. |
filter. |
object |
No | Each value is a string or string[]. |
target |
object |
Yes | |
target. |
string |
Yes | One of "webhook" or "notification". |
target. |
string |
No | With kind: "webhook". |
target. |
string |
No | With kind: "notification". |
target. |
object |
No | With kind: "notification". |
target. |
string[] |
No | 1–100 items. |
target. |
string[] |
No | 1–10 items. |
target. |
boolean |
No | |
target. |
object |
No | With kind: "notification". |
target. |
string |
Yes | 1–500 characters. |
target. |
string |
No | Up to 4000 characters. |
target. |
string |
No | Up to 2048 characters. |
target. |
object |
No | |
target. |
string |
No | Up to 200 characters. |
target. |
string |
No | Up to 1000 characters. |
target. |
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
invalid_request(400)payload_too_large(413)
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
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - Pages:
limit, 1 to 200, default 50, withnextandafter. 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
invalid_request(400)
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
devsecret key,sk_test_…, asAuthorization: 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. |
string[] |
No | 1–50 items. |
filter. |
string[] |
No | 1–50 items. |
filter. |
object |
No | Each value is a string or string[]. |
filter. |
string |
No | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
filter. |
string |
No | 1–500 characters. |
filter. |
object[] |
No | 1–20 items. |
filter. |
string |
Yes | 1–100 characters. |
filter. |
string |
No | 1–500 characters. |
filter. |
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
not_found(404)invalid_request(400)payload_too_large(413)
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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)
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
devsecret key,sk_test_…, asAuthorization: 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. |
string[] |
No | 1–50 items. |
filter. |
string[] |
No | 1–50 items. |
filter. |
object |
No | Each value is a string or string[]. |
filter. |
string |
No | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
filter. |
string |
No | 1–500 characters. |
filter. |
object[] |
No | 1–20 items. |
filter. |
string |
Yes | 1–100 characters. |
filter. |
string |
No | 1–500 characters. |
filter. |
object |
No | Each value is a string or string[]. |
target |
object |
No | |
target. |
string |
Yes | One of "webhook" or "notification". |
target. |
string |
No | With kind: "webhook". |
target. |
string |
No | With kind: "notification". |
target. |
object |
No | With kind: "notification". |
target. |
string[] |
No | 1–100 items. |
target. |
string[] |
No | 1–10 items. |
target. |
boolean |
No | |
target. |
object |
No | With kind: "notification". |
target. |
string |
Yes | 1–500 characters. |
target. |
string |
No | Up to 4000 characters. |
target. |
string |
No | Up to 2048 characters. |
target. |
object |
No | |
target. |
string |
No | Up to 200 characters. |
target. |
string |
No | Up to 1000 characters. |
target. |
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
not_found(404)conflict(409)invalid_request(400)payload_too_large(413)
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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)
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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)
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
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - Pages:
limit, 1 to 200, default 50, withnextandafter. 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
not_found(404)invalid_request(400)
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
devsecret key,sk_test_…, asAuthorization: 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
devsecret key,sk_test_…, asAuthorization: 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. |
string[] |
When set | 1–50 items. |
filter. |
string[] |
When set | 1–50 items. |
filter. |
object |
When set | Each value is a string or string[]. |
filter. |
string |
When set | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
filter. |
string |
When set | 1–500 characters. |
filter. |
object[] |
When set | 1–20 items. |
filter. |
string |
Always | 1–100 characters. |
filter. |
string |
When set | 1–500 characters. |
filter. |
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. |
string[] |
When set | 1–50 items. |
constraint. |
string[] |
When set | 1–50 items. |
constraint. |
object |
When set | Each value is a string or string[]. |
constraint. |
string |
When set | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
constraint. |
string |
When set | 1–500 characters. |
constraint. |
object[] |
When set | 1–20 items. |
constraint. |
string |
Always | 1–100 characters. |
constraint. |
string |
When set | 1–500 characters. |
constraint. |
object |
When set | Each value is a string or string[]. |
target |
object |
Always | |
target. |
string |
Always | One of "webhook" or "notification". |
target. |
string |
When set | With kind: "webhook". |
target. |
string |
When set | With kind: "notification". |
target. |
object |
When set | With kind: "notification". |
target. |
string[] |
When set | 1–100 items. |
target. |
string[] |
When set | 1–10 items. |
target. |
boolean |
When set | |
target. |
object |
When set | With kind: "notification". |
target. |
string |
Always | 1–500 characters. |
target. |
string |
When set | Up to 4000 characters. |
target. |
string |
When set | Up to 2048 characters. |
target. |
object |
When set | |
target. |
string |
When set | Up to 200 characters. |
target. |
string |
When set | Up to 1000 characters. |
target. |
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[]. |
string |
Always | status, constraint, filter, types, sources, workspace, subject, extensions.<name>, refs, or where.<path>. |
steps[]. |
string |
Always | One of "matched" or "not_matched". |
steps[]. |
string |
Always |
The SubscriptionVersionRecord object
| Name | Type | Present | Description |
|---|---|---|---|
subscriptionId |
string |
Always | A subscription ID, sub_…. |
version |
number |
Always | |
filter |
object |
Always | |
filter. |
string[] |
When set | 1–50 items. |
filter. |
string[] |
When set | 1–50 items. |
filter. |
object |
When set | Each value is a string or string[]. |
filter. |
string |
When set | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
filter. |
string |
When set | 1–500 characters. |
filter. |
object[] |
When set | 1–20 items. |
filter. |
string |
Always | 1–100 characters. |
filter. |
string |
When set | 1–500 characters. |
filter. |
object |
When set | Each value is a string or string[]. |
constraint |
object |
When set | |
constraint. |
string[] |
When set | 1–50 items. |
constraint. |
string[] |
When set | 1–50 items. |
constraint. |
object |
When set | Each value is a string or string[]. |
constraint. |
string |
When set | The workspace it belongs to, when the app groups its principals into workspaces; 1–200 characters. |
constraint. |
string |
When set | 1–500 characters. |
constraint. |
object[] |
When set | 1–20 items. |
constraint. |
string |
Always | 1–100 characters. |
constraint. |
string |
When set | 1–500 characters. |
constraint. |
object |
When set | Each value is a string or string[]. |
target |
object |
Always | |
target. |
string |
Always | One of "webhook" or "notification". |
target. |
string |
When set | With kind: "webhook". |
target. |
string |
When set | With kind: "notification". |
target. |
object |
When set | With kind: "notification". |
target. |
string[] |
When set | 1–100 items. |
target. |
string[] |
When set | 1–10 items. |
target. |
boolean |
When set | |
target. |
object |
When set | With kind: "notification". |
target. |
string |
Always | 1–500 characters. |
target. |
string |
When set | Up to 4000 characters. |
target. |
string |
When set | Up to 2048 characters. |
target. |
object |
When set | |
target. |
string |
When set | Up to 200 characters. |
target. |
string |
When set | Up to 1000 characters. |
target. |
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 |