Register webhook

Prev Next
Post
/api/webhooks-management/webhooks

Registers a webhook callback URL for the company.

Behavior:
- Checks whether another webhook with the same URL already exists for this company.
- If a duplicate exists, registration is rejected and no new webhook is created.
- If no duplicate exists, verifies the callback URL before saving.
- The callback URL must use HTTPS and include a valid hostname.
- Verification works by performing request to the callback URL via POST — the exact same delivery mechanism (HMAC-signed with X-Webhook-Signature/X-Webhook-Timestamp headers, JSON body in the same event format) used for every subsequent event.
- The verification event has event_type webhook.url.verification and a message in its data field, e.g. {"message":"This is webhook url verification request"}. It is signed with the secret being stored for this webhook.
- Verification is a single delivery attempt with no retries; it succeeds only if the callback accepts the request without a 4xx/5xx response and without a DNS, TLS, timeout, or other connection error.
- If verification fails, the webhook is not created.
- On success, the webhook is created as ACTIVE with failures_count set to 0.
- If secret is not provided, a secure secret is generated and stored for signature verification.

Delivered callback payload:
- After registration, matching events are sent to the callback URL as JSON payloads.
- Each payload contains id, event_type, api_version, created_at, company_id, event_id, and data.
- The event_type field identifies the notification and determines the contents of data:
- variant.added: A variant was added.
- variant.updated: An existing variant was updated.
- variant.upserted: A variant was created or updated.
- variant.deleted: A variant was deleted.
- variant.processing.failed: A variant could not be processed; data.error contains the error code and message.
- webhook.url.verification: A verification message checks that the callback URL accepts deliveries.
- Use event_type to interpret data. See Send a test webhook event for the payload structure and examples.
- Event id is stable across retries, so receivers can use it for deduplication.

Status lifecycle:
- New webhooks are created as ACTIVE.
- Events are delivered only to operational webhooks: ACTIVE and FAILING.
- PAUSED and ARCHIVED webhooks do not receive events.
- If delivery fails after all retry attempts, an ACTIVE webhook becomes FAILING.
- While FAILING, delivery continues for matching events and the failure counter is incremented on each failed delivery.
- A successful delivery resets failure counters and moves a FAILING webhook back to ACTIVE.
- Persistent failures automatically move a webhook to ARCHIVED when auto-archive is enabled.
- Current auto-archive defaults are 100 consecutive failures or failures lasting 48 hours.
- Use the update endpoint to manually pause or reactivate a webhook by changing status.

Webhook delivery headers

Notifications, including webhook.url.verification, are sent as HTTP POST requests with an application/json body to the registered receiver URL. Each delivery includes these headers:

  • X-Webhook-Timestamp: Unix timestamp in seconds for the current delivery attempt. Example: 1769529900. This is the delivery time; the payload's created_at records when the event occurred. A retry can have a new delivery timestamp and signature.
  • X-Webhook-Signature: Signature in the format t=timestamp,v1=signature. t matches X-Webhook-Timestamp. v1 is the 64-character lowercase hexadecimal HMAC-SHA256 of the UTF-8 string timestamp + "." + rawRequestBody, using the subscription's secret encoded as UTF-8 as the key.

Example delivery headers (the signature is illustrative):

  • X-Webhook-Timestamp: 1769529900
  • X-Webhook-Signature: t=1769529900,v1=8f2c1a4e9b6d7f0032a5c8e1d4b9f670a3e2c5d8b1f496007ead32c6f5b89014

To verify a delivery, check that both timestamp values match, recompute the signature using the original JSON body without parsing or reformatting it, and compare it with v1 using a constant-time comparison. Reject timestamps outside an acceptable clock-skew window (for example, five minutes) to limit replay attacks. Deduplicate notifications using the payload's id, which remains unchanged across retries.

These headers are sent to your receiver; they are not required on calls to this management API.

Security
HTTP
Type bearer
Body parameters
object

Register webhook request

url
string Required

Target URL to receive webhook events

Pattern^https?://.+
Examplehttps://api.yoursite.com/webhook
secret
string | null

Optional secret for signing payloads, if not provided a secure secret will be generated

Examplewhsec_77af8290bc...0192
event_types
Array of string Required

Event types to subscribe to

Example[ "variant.added", "variant.processing.failed" ]
string

Event types to subscribe to

Valid values[ "variant.added", "variant.updated", "variant.upserted", "variant.deleted", "variant.processing.failed", "webhook.url.verification" ]
Example["variant.added","variant.processing.failed"]
Responses
201

Webhook registered successfully. Returns the created webhook subscription.

{
  "id": 1,
  "creatorId": 300,
  "url": "https://api.yoursite.com/webhook",
  "eventTypes": [
    "variant.added"
  ],
  "status": "ACTIVE",
  "secret": "whsec_77af8290bc0192",
  "createdAt": "2026-01-27T16:05:00Z",
  "updatedAt": "2026-01-27T16:05:00Z",
  "failuresCount": 0
}
object
id
integer (int64)
creatorId
integer (int64)
url
string
eventTypes
Array of string
string
status
string
secret
string
createdAt
string (date-time)
updatedAt
string (date-time)
failuresCount
integer (int64)
firstFailureAt
string (date-time)
lastFailureAt
string (date-time)
lastSuccessAt
string (date-time)
400

Invalid request.

Returned when:
- Validation fails.
- event_types is empty.
- The URL format is invalid.
- A webhook with the same URL already exists for this company.

"Webhook with URL 'https://api.yoursite.com/webhook' already exists for this company and workspace"
422

Callback URL verification failed. The webhook is not created.

Possible causes:
- Non-HTTPS URL.
- Private or unresolvable host.
- TLS error.
- Timeout or connection failure.
- 4xx/5xx callback response.
- Any non-2xx verification response.

"Only HTTPS URLs are supported. Please use https:// scheme."