Skip to main content
The Webhooks API allows you to manage webhook endpoints that receive real-time event notifications when activities occur in your account.

List webhook endpoints

Returns a paginated list of webhook endpoints for the current account.
integer
default:"1"
Page number for pagination.
Response

Get webhook endpoint

Returns details of a specific webhook endpoint.
string
required
The webhook endpoint’s ID (e.g., we_xxx).
Response

Create webhook endpoint

Creates a new webhook endpoint.
string
required
The URL where webhook events will be sent via HTTP POST. Must use HTTPS.
array
required
Event types to subscribe to. Use ["*"] for all events, or specify individual events like ["invoice.created", "invoice.paid"].
boolean
default:"true"
Whether the endpoint is active.
string
Optional description for the endpoint.
The signing secret is only returned in full once — at creation time. Store it securely as you will need it to verify webhook signatures.
The response includes the full signing_secret (returned as 201 Created).

Update webhook endpoint

Updates an existing webhook endpoint.
string
required
The webhook endpoint’s ID.
string
The endpoint URL.
array
Event types to subscribe to.
boolean
Whether the endpoint is active.
string
Optional description.
Returns the updated webhook endpoint.

Delete webhook endpoint

Deletes a webhook endpoint. This also deletes all associated webhook events.
string
required
The webhook endpoint’s ID.
Returns 204 No Content.

Regenerate signing secret

Regenerates the signing secret for a webhook endpoint. The previous secret is immediately invalidated.
string
required
The webhook endpoint’s ID.
Returns the webhook endpoint with the new full signing_secret.
After regenerating the secret, you must update your integration to use the new secret. Webhooks signed with the old secret will fail verification.

Webhook security

TRXN signs all webhook requests with HMAC-SHA256 signatures, allowing you to verify that webhooks are genuinely from TRXN.

Signature header format

Every webhook request includes an X-Trxn-Signature header:
Example:

Signing secret format

Signing secrets use the format whsec_<64_hex_chars>:

Verifying signatures

To verify a webhook signature:
  1. Extract the timestamp (t) and signature (v1) from the header.
  2. Check the timestamp is within 5 minutes of current time (prevents replay attacks).
  3. Compute the expected signature: HMAC-SHA256(secret, "<timestamp>.<raw_body>").
  4. Compare signatures using constant-time comparison.
Use the full signing secret (including the whsec_ prefix) as the HMAC key. This matches Stripe’s implementation.

Available events

Webhook payload format

When an event occurs, TRXN sends a POST request to your endpoint with the following format:

Subscription phase payload example

Response handling

Your endpoint should respond with a 2xx status code to indicate successful receipt. If your endpoint returns a non-2xx status code, TRXN will retry the delivery with exponential backoff (up to 11 attempts).

Error handling

If your endpoint cannot be reached, TRXN will:
  1. Connection error: Disable the endpoint to prevent further delivery attempts.
  2. Timeout error: Retry with exponential backoff.
  3. TLS error: Retry with exponential backoff.
  4. Non-2xx response: Retry with exponential backoff.

Event retention

TRXN retains webhook events for 30 days.

Best practices

Return a 2xx response before any complex logic to avoid timeouts. Process the event asynchronously after responding.
  1. Respond quickly: Return a 2xx response before any complex logic that could cause a timeout. Process the event asynchronously after responding.
  2. Handle duplicates: Webhook endpoints may occasionally receive the same event more than once. Make your event processing idempotent by tracking the id from the payload. If you have already processed an event for that resource, skip it and return a 2xx response.
  3. Handle out-of-order delivery: Events may not arrive in chronological order. Use the timestamp field to determine the sequence of events rather than assuming arrival order.
  4. Always verify signatures: Use the X-Trxn-Signature header to verify all incoming webhooks. Reject any webhook that fails signature verification.
  5. Use HTTPS: Always use HTTPS endpoints for security.
  6. Store secrets securely: Store your signing secrets in environment variables or a secrets manager, never in source code.
  7. Monitor failures: Check webhook events in the dashboard to monitor delivery status.
  8. Regenerate compromised secrets: If you suspect your signing secret has been compromised, regenerate it immediately.