Subscribe to a Trigger of a Connection
POST /v1/trigger-subscriptions
| Property | Value |
|---|---|
| Operation | create_trigger_subscription |
| Group | Triggers |
| Scope | integrations:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited integrations.trigger_subscription.create (mutation) |
| Released in | 1.60.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates a subscription at revision 1 and answers its subscription_token once (1.60.0). The filter is linted over the Trigger's data schema and every pointer checked (TriggerSubscriptionIssueCode); a revoked Connection is connection_revoked; an action 1.60.0 does not build is capability_not_available; a start_call set by a Member who is neither an owner nor an admin, or by an API key, is forbidden with owner_or_admin_required.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the integrations:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/trigger-subscriptions" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>",
"connection_id": "con_...",
"event_type": "<event_type>",
"action": {
"type": "start_call",
"agent_id": "agt_...",
"to": "<to>"
}
}'const response = await fetch(`${process.env.VOCAL_API}/v1/trigger-subscriptions`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "<name>",
"connection_id": "con_...",
"event_type": "<event_type>",
"action": {
"type": "start_call",
"agent_id": "agt_...",
"to": "<to>"
}
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/trigger-subscriptions",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"name": "<name>",
"connection_id": "con_...",
"event_type": "<event_type>",
"action": {
"type": "start_call",
"agent_id": "agt_...",
"to": "<to>",
},
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: TriggerSubscriptionCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
action | TriggerActionInput | yes | |
connection_id | ConnectionId | yes | |
enabled | boolean | no | True when omitted. |
event_type | TriggerEventTypeName | yes | |
filter | ZenExpression | no | |
name | string | yes | |
rate_limit_per_minute | integer | no | 60 when omitted (a target). |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | TriggerSubscription | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
409 | application/json | ErrorEnvelope | connection_revoked, idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed, capability_not_available |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is TriggerSubscription.
| Field | Type | Required | Description |
|---|---|---|---|
action | TriggerAction | yes | |
connection_id | ConnectionId | yes | |
connector_id | ConnectorId | yes | |
created_at | Timestamp | yes | |
enabled | boolean | yes | |
event_type | TriggerEventTypeName | yes | |
filter | ZenExpression or null | yes | A ZEN expression over the event's typed fields; null acts on every event. |
id | TriggerSubscriptionId | yes | |
name | string | yes | |
object | "trigger_subscription" | yes | |
organization_id | OrganizationId | yes | |
previous_token_expires_at | Timestamp or null | no | After a token rotation (1.61.0), when the previous token stops verifying, 24 hours later (a target); null otherwise, absent from an api before 1.61.0. |
rate_limit_per_minute | integer | yes | |
revision | integer | yes | |
status | TriggerSubscriptionStatus | yes | |
subscription_token | string (password) or null (password) | yes | The token of the edge path /v1/triggers/{connector_id}/{subscription_token}, 32 random bytes in base64url: answered once by the create, null in every other answer. |
token_hint | string | yes | The last characters of the subscription token. |
updated_at | Timestamp | yes |