Create a webhook with the REST API v2 endpoint
Use this endpoint when an integration needs event callbacks delivered to an HTTPS address. A successful call creates an active webhook for the API key owner and returns the one-time signing secret needed to verify deliveries.
Request fields
The JSON body has three controls. url is required and must be an absolute HTTPS URL on a publicly reachable host. events is required, must contain at least one known event type, and cannot include webhook.test. description is optional, may be empty, and is capped at 200 characters. Unknown fields, a missing required field, or an overlong description produce a validation failure.
What a successful creation returns
Treat the 201 payload as the only chance to capture the full secret. It also identifies the webhook, owner, subscribed events, status, timestamps and last delivery state. The new webhook starts active, and an immediate webhook.test delivery is sent to the supplied endpoint. Idempotency-Key and X-On-Behalf-Of do not change this operation.
Pre-flight checklist and examples
Before calling, run this checklist: confirm the endpoint is publicly reachable over HTTPS; choose only event types the owner and key may receive; keep the description within 200 characters; prepare secure storage for the secret before the request; and plan to verify the automatic test delivery. The leaves example subscribes to leave.approved and leave.cancelled for payroll synchronization, while the operations example subscribes to operation.completed and operation.failed. Both use the same endpoint and field rules.
Failure distinctions
A 400 response can mean VALIDATION_ERROR, INVALID_REQUEST_BODY, WEBHOOK_URL_INVALID or WEBHOOK_EVENTS_INVALID. A 403 response can mean WEBHOOK_EVENTS_NOT_ALLOWED or FORBIDDEN when the key owner no longer exists. Authentication failures return 401, insufficient key scope is reported separately from event permission, and the endpoint also documents 429 and 500 responses. Error bodies follow the shared envelope with a stable code, human-readable name, explanation, suggested resolution and requestId; validation details identify the affected fields.
Frequently asked questions
Can I retrieve the signing secret later?
No. The full signing value appears in the 201 creation response and again only when the secret is rotated. Later reads do not return it, so save it in secure storage immediately and use the rotate-secret endpoint if it is lost.
Can I subscribe to webhook.test?
No. That event is reserved for test deliveries and cannot be included in a subscription list. A test delivery is nevertheless sent automatically when a new webhook is created.
Why did event selection fail?
An empty list or an unknown event type returns 400 WEBHOOK_EVENTS_INVALID. If a valid event exceeds the owner's role or the key's scopes, the request instead returns 403 WEBHOOK_EVENTS_NOT_ALLOWED.
curl -X POST "$API_BASE_URL/v2/webhooks" \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/vacation-tracker/webhooks",
"events": [
"leave.approved",
"leave.cancelled"
],
"description": "Example post details."
}'{
"data": {
"webhookId": "wh_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93",
"url": "https://example.com/vacation-tracker/webhooks",
"description": "Example post details.",
"events": [
"leave.approved",
"leave.cancelled"
],
"status": "active",
"pausedReason": null,
"pausedAt": null,
"revokedAt": null,
"revocationReason": null,
"ownerId": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14",
"secretPrefix": "whsec_AbCd",
"secret": "whsec_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789-_AbCd",
"lastDelivery": null,
"createdAt": "2026-09-01T08:00:00.000Z",
"updatedAt": "2026-09-01T08:00:00.000Z"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"name": "ValidationError",
"description": "Example post details.",
"resolution": "Fix the fields listed in details.fields and send the request again.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"fields": [
{
"path": "startDate",
"message": "\"startDate\" is required"
}
]
}
}
}{
"error": {
"code": "UNAUTHORIZED",
"name": "Unauthorized",
"description": "Example post details.",
"resolution": "Send a valid API key in the Authorization header as Bearer followed by the full vt_live_ key.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "INSUFFICIENT_SCOPE",
"name": "InsufficientScope",
"description": "Example post details.",
"resolution": "Add the scopes listed in details.requiredScopes to the key in the OnlyLeave dashboard.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"requiredScopes": [
"leaves:write"
]
}
}
}{
"error": {
"code": "RATE_LIMITED",
"name": "RateLimited",
"description": "Example post details.",
"resolution": "Wait a few seconds and retry, using the same Idempotency-Key for writes.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "INTERNAL_ERROR",
"name": "InternalError",
"description": "Example post details.",
"resolution": "Retry later, and if it keeps happening, contact OnlyLeave support and quote the requestId.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}body
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| body | object | Yes | ||
| body.url | string | Yes | an HTTPS URL. Other URLs fail with 400 WEBHOOK_URL_INVALID. | Format: uri |
| body.events | array<WebhookEventType> | Yes | the event types to receive. Each event's capability must be within the owner's role and the key's scopes, otherwise the request fails with 403 WEBHOOK_EVENTS_NOT_ALLOWED. webhook.test cannot be subscribed to. | 1 <= items |
| body.events[] | string | the event type. webhook.test is sent only by test deliveries and cannot be subscribed to. | Allowed values: $4e | |
| body.description | string | No | a description to help you recognize the webhook, up to 200 characters; may be empty | length <= 200 |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | |||
| response.data | object | No | ||
| response.data.webhookId | string | Yes | webhook ID | |
| response.data.url | string | Yes | the HTTPS URL deliveries are sent to | Format: uri |
| response.data.description | string | null | No | a description to help you recognize the webhook | |
| response.data.description[variant1] | string | a description to help you recognize the webhook | ||
| response.data.description[variant2] | null | a description to help you recognize the webhook | ||
| response.data.events | array<WebhookEventType> | Yes | the event types sent to this webhook | |
| response.data.events[] | string | the event type. webhook.test is sent only by test deliveries and cannot be subscribed to. | Allowed values: $7a | |
| response.data.status | string | Yes | active webhooks receive events; paused and revoked webhooks do not | Allowed values: "active" | "paused" | "revoked" |
| response.data.pausedReason | string | null | No | why the webhook is paused. manual means it was paused with the API or the dashboard, delivery-failures means every delivery failed for 72 hours, endpoint-gone means your endpoint returned 410. | Allowed values: "manual" | "delivery-failures" | "endpoint-gone" | null |
| response.data.pausedReason[variant1] | string | why the webhook is paused. manual means it was paused with the API or the dashboard, delivery-failures means every delivery failed for 72 hours, endpoint-gone means your endpoint returned 410. | Allowed values: "manual" | "delivery-failures" | "endpoint-gone" | null | |
| response.data.pausedReason[variant2] | null | why the webhook is paused. manual means it was paused with the API or the dashboard, delivery-failures means every delivery failed for 72 hours, endpoint-gone means your endpoint returned 410. | "manual" | "delivery-failures" | "endpoint-gone" | null | |
| response.data.pausedAt | string | null | No | a timestamp in the ISO 8601 format, set while the webhook is paused | date-time |
| response.data.pausedAt[variant1] | string | a timestamp in the ISO 8601 format, set while the webhook is paused | date-time | |
| response.data.pausedAt[variant2] | null | a timestamp in the ISO 8601 format, set while the webhook is paused | date-time | |
| response.data.revokedAt | string | null | No | a timestamp in the ISO 8601 format, set when the webhook is revoked | date-time |
| response.data.revokedAt[variant1] | string | a timestamp in the ISO 8601 format, set when the webhook is revoked | date-time | |
| response.data.revokedAt[variant2] | null | a timestamp in the ISO 8601 format, set when the webhook is revoked | date-time | |
| response.data.revocationReason | string | null | No | why the webhook was revoked | "manual" | "owner_permissions_reduced" | "owner_deactivated" | "owner_deleted" | null |
| response.data.revocationReason[variant1] | string | why the webhook was revoked | "manual" | "owner_permissions_reduced" | "owner_deactivated" | "owner_deleted" | null | |
| response.data.revocationReason[variant2] | null | why the webhook was revoked | "manual" | "owner_permissions_reduced" | "owner_deactivated" | "owner_deleted" | null | |
| response.data.ownerId | string | Yes | the ID of the user who owns the webhook. Events are filtered by this user's current permissions. | |
| response.data.secretPrefix | string | Yes | the first 10 characters of the signing secret, to help you tell secrets apart | |
| response.data.lastDelivery | WebhookLastDelivery | null | No | the most recent delivery, null before the first delivery | |
| response.data.lastDelivery[variant1] | object | the most recent delivery, null before the first delivery | ||
| response.data.lastDelivery[variant1].deliveryId | string | Yes | delivery ID, the same as the VT-Delivery-Id header | |
| response.data.lastDelivery[variant1].eventName | string | Yes | the event type. webhook.test is sent only by test deliveries and cannot be subscribed to. | Allowed values: $7a |
| response.data.lastDelivery[variant1].status | string | Yes | delivery status. SKIPPED means the webhook was paused, revoked or deleted before the delivery was sent. | "PENDING" | "RETRYING" | "SUCCEEDED" | "FAILED" | "SKIPPED" |
| response.data.lastDelivery[variant1].responseStatus | integer | No | the HTTP status your endpoint returned on the latest attempt, absent when no response was received | |
| response.data.lastDelivery[variant1].at | string | Yes | a timestamp in the ISO 8601 format of the latest attempt | date-time |
| response.data.lastDelivery[variant2] | null | the most recent delivery, null before the first delivery | ||
| response.data.createdAt | string | Yes | a timestamp in the ISO 8601 format | date-time |
| response.data.updatedAt | string | Yes | a timestamp in the ISO 8601 format | date-time |
| response.data.secret | string | Yes | the signing secret. Returned only when the webhook is created and when the secret is rotated; store it securely. |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |