Create a Webhook subscription
POST /v1/webhooks
| Property | Value |
|---|---|
| Operation | create_webhook |
| Group | Webhooks |
| Scope | webhooks:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited webhooks.subscription.create (mutation) |
| Released in | 1.63.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates an active subscription at revision 1 and answers it with its new secret, which no later read shows (1.63.0; api.md section 7). The URL passes the egress guard's save-time rules (egress_denied at /url) and the selection its rules (WebhookSelectionIssueCode), each a detail of 422 validation_failed; a filter the Organization lacks is not_found. Deliveries start with the next event it selects, signed with Vocal-Signature. From 1.64.0, stated as the api built it: a request repeated under the same Idempotency-Key by the same credential answers the stored answer with the secret again while it is still the subscription's current secret, and writes the Audit event webhooks.subscription.secret_read; once the subscription is deleted the repeat is not_found, and once the secret is rotated it is 409 idempotency_key_reused, the secret never shown again.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the webhooks:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/webhooks" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.test/a" }'const response = await fetch(`${process.env.VOCAL_API}/v1/webhooks`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"url": "https://example.test/a"
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/webhooks",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"url": "https://example.test/a",
},
)
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: WebhookSubscriptionCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
compliance_policy_firings | boolean | no | The opt-in to the record form of a compliance-tagged Policy firing, policy.compliance_fired (1.63.0): true delivers each to this subscription; false by default. From 1.64.0, stated: the subscription's event filter narrows it as it narrows every other type, since a filter the customer set holds. |
event_types | array of EventTypeName | no | None when omitted. |
families | array of EventFamily | no | |
filter_id | EventFilterId or null | no | |
include | array of WebhookInclude | no | |
purpose | WebhookPurpose | no | general when omitted at creation. |
url | string | yes | The https URL deliveries are posted to, checked by the egress guard when saved and at every delivery (egress_denied). |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | WebhookSubscriptionCreated | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is WebhookSubscriptionCreated.
| Field | Type | Required | Description |
|---|---|---|---|
api_version | "v1" | yes | The envelope version, fixed at creation. |
compliance_policy_firings | boolean | yes | The opt-in to the record form of a compliance-tagged Policy firing, policy.compliance_fired (1.63.0): true delivers each to this subscription; false by default. From 1.64.0, stated: the subscription's event filter narrows it as it narrows every other type, since a filter the customer set holds. |
created_at | Timestamp | yes | |
disabled_at | Timestamp or null | yes | |
disabled_reason | WebhookDisabledReason or null | yes | Why the platform disabled it; null unless disabled. |
event_types | array of EventTypeName | yes | The record types the subscription receives, beside its families. |
families | array of EventFamily | yes | Whole families the subscription receives, beside event_types; at least one of the two is non-empty (1.52.0). |
filter_id | EventFilterId or null | yes | The event filter that narrows the selection, or null (1.52.0). |
id | WebhookId | yes | |
include | array of WebhookInclude | yes | Opt-in additions to a post_call delivery; empty for a general one (1.52.0). |
last_delivery | WebhookLastDelivery or null | no | The newest delivery of the subscription, of any kind (1.64.0), so a list shows it without a read per subscription; null when the 30-day log holds none. Absent from an api older than 1.64.0. |
object | "webhook_subscription" | yes | |
previous_secret_expires_at | Timestamp or null | yes | When the secret before the last rotation stops signing; null outside the window. |
purpose | WebhookPurpose | yes | |
revision | integer | yes | Counts configuration writes; returned as the ETag and required in If-Match. |
secret | WebhookSecret | yes | The secret, shown in this answer only. |
secret_hint | string | yes | The last four characters of the secret. |
status | WebhookSubscriptionStatus | yes | |
updated_at | Timestamp | yes | |
url | string | yes | The https URL deliveries are posted to, checked by the egress guard when saved and at every delivery (egress_denied). |