POST
request to a URL you register.
This page explains how to receive and validate events. To create, list,
and delete webhook endpoints, see Core API: Webhooks.
For the full list of available events, see Events.
How it works
Register an endpoint
Register a public URL (HTTPS) and, optionally, a
secret. You also choose
which events you want to receive — an empty list means “all events”. See
Core API: Webhooks.An event occurs
Something changes in your account (e.g., a transaction is paid). Z2Pay selects
your active webhooks that are listening for that event type.
Z2Pay POSTs to your endpoint
For each matching webhook, Z2Pay sends a
POST with the event’s JSON envelope
in the request body along with identification and signature headers.The event envelope
Every webhook arrives in the same envelope format. The resource-specific content is always nested insidedata.
Unique identifier for this delivery (prefix
whd_). Every attempt to deliver the same
event to the same endpoint uses the same id — use it as an idempotency key (see below).The resource object related to the event (the transaction, refund, subscription, etc.).
The shape of
data depends on the type.The date and time the event was dispatched, in ISO 8601 with timezone (UTC).
Your company identifier (prefix
comp_).Request headers
Every webhookPOST includes:
| Header | Always present | Description |
|---|---|---|
Content-Type | Yes | application/json |
User-Agent | Yes | Z2Pay-Webhooks/1.0 |
X-Webhook-Event-Id | Yes | Identifier of the originating event. Used for correlation. |
X-Webhook-Timestamp | Only with secret | Signature timestamp, in ISO 8601 with timezone. |
X-Webhook-Signature | Only with secret | HMAC-SHA256 signature of the body, in hexadecimal. |
The
X-Webhook-Timestamp and X-Webhook-Signature headers are only sent when you
registered a secret on the webhook. Without a secret, there is no signature to
validate — which is why we recommend always configuring a secret.Verifying the signature
When the webhook has asecret, Z2Pay computes the signature as follows:
payload is the entire envelope (the JSON with id, type, data, occurredAt, and
companyId) — exactly the body received in the request.
Node.js example
Idempotency in your receiver
The same event may arrive more than once (due to internal reprocessing or a slow response from your server). Your endpoint must be idempotent.Use the delivery id as a key
Store the
id from the envelope (prefix whd_) when processing the event. It is stable
across retries of the same delivery.Skip already-processed events
Before applying side effects, check whether that
id has already been processed. If so,
respond with 2xx and do nothing further.The
X-Webhook-Event-Id identifies the originating event and can also be used for
correlation and deduplication. The envelope id, on the other hand, is specific to the
delivery to your endpoint.Timeout and retries
Timeout
Each
POST has a timeout of 30 seconds. If your server does not respond within
that window, the attempt is considered a failure.What counts as success
Only HTTP responses in the 2xx range are considered a successful delivery.
Redirects,
4xx, and 5xx all count as failures.Z2Pay logs the result of each delivery attempt (the HTTP status returned by your server,
the response body, and the attempt count). A delivery only needs a
2xx response from
you to be marked as successful.Best practices
Always configure a secret
Always configure a secret
Without a
secret, there are no signature headers and you cannot guarantee that the
request actually came from Z2Pay. Set a strong secret when registering the webhook in
Core API: Webhooks.Validate the signature before processing
Validate the signature before processing
Reject with
401 any request whose signature does not match. Do not process the event
before validating it.Process asynchronously
Process asynchronously
Enqueue the event and respond with
2xx promptly. Slow processing increases the risk of
hitting the 30s timeout and triggering redeliveries.Treat the event as a hint, not ground truth
Treat the event as a hint, not ground truth
In critical flows (e.g., fulfilling an order), confirm the state by querying
Core API: Transactions with the
id received in data.See also
Events
The list of event types (
type) that Z2Pay sends.Core API: Webhooks
Create, list, and delete webhook endpoints.
Errors
API error format and error codes.
Conventions
Prefixed IDs, values in cents, and ISO 8601 dates.

