Webhooks
Receive real-time event notifications for payments, subscriptions, and invoices.
Webhooks deliver real-time HTTP POST notifications to your server when events occur in your Access account.
Register an Endpoint
curl -X POST https://api.tryaccess.xyz/api/v1/webhooks/endpoints \
-H "Content-Type: application/json" \
-H "x-api-key: sk_..." \
-d '{
"url": "https://yourapp.com/webhooks/access",
"enabled_events": ["checkout.session.completed", "invoice.paid"]
}'Response:
{
"id": "we_01HXYZ...",
"url": "https://yourapp.com/webhooks/access",
"secret": "whsec_01HXYZ...",
"status": "active",
"enabled_events": ["checkout.session.completed", "invoice.paid"],
"created_at": "2025-01-15T10:00:00.000Z",
"updated_at": "2025-01-15T10:00:00.000Z"
}The signing secret is returned only at creation time. Store it securely.
Leave enabled_events empty to receive all events.
Event Types
Checkout
| Event | Description |
|---|---|
checkout.session.completed | Checkout session payment succeeded |
checkout.session.expired | Checkout session expired |
Payments
| Event | Description |
|---|---|
payment.completed | Payment was verified |
payment.failed | Payment verification failed |
Crypto
| Event | Description |
|---|---|
crypto_payment.confirming | Crypto for a payment arrived and is being confirmed |
crypto_payment.finished | A crypto payment was paid in full |
crypto_payment.failed | A crypto payment failed, like when too little was sent |
crypto_payment.expired | A crypto payment ran out of time before it was paid |
crypto_payout.paid | A crypto payout or refund was sent |
crypto_payout.failed | A crypto payout or refund couldn't be sent |
crypto_payout.rejected | A crypto payout or refund was rejected |
Subscriptions
| Event | Description |
|---|---|
subscription.renewed | Subscription period renewed |
subscription.payment_failed | Subscription renewal payment failed |
customer.subscription.canceled | Subscription was cancelled |
Invoices
| Event | Description |
|---|---|
invoice.paid | Invoice was paid |
invoice.payment_failed | Invoice payment failed |
invoice.voided | Invoice was voided |
Webhook Payload
{
"id": "evt_01HXYZ...",
"type": "checkout.completed",
"created_at": "2025-01-15T10:30:00Z",
"data": {
"sessionId": "cs_01HXYZ...",
"mode": "payment",
"customerId": "cus_01HXYZ...",
"amount": 15000,
"currency": "ETB"
}
}Signature Verification
All webhook deliveries include an x-access-signature header. Verify it using HMAC-SHA256 with your webhook secret:
import { createHmac } from 'crypto';
function verifyWebhook(body: string, signature: string, secret: string): boolean {
const computed = createHmac('sha256', secret)
.update(body)
.digest('hex');
return computed === signature;
}Always verify signatures before processing webhook payloads to prevent spoofing.
Matching a Webhook to Your Request
When one of your API requests caused the event, the delivery carries an
access-request-id header with that request's id: the same req_… value
the API returned in its X-Request-Id header. Retries carry it too, and so
does work the request scheduled: the invoice, reminder and renewal events
of a subscription carry the id of the request that created it (or of the
payment that started its current period). Log it next to the event to tie
the webhook back to the call that caused it, or paste it into the
Workbench to see the request and everything that followed. Events Access
starts on its own, with no request behind them, have no header.
Managing Endpoints
| Action | Method | Endpoint |
|---|---|---|
| Create endpoint | POST | /api/v1/webhooks/endpoints |
| List endpoints | GET | /api/v1/webhooks/endpoints |
| Get endpoint | GET | /api/v1/webhooks/endpoints/:id |
| Update endpoint | PATCH | /api/v1/webhooks/endpoints/:id |
| Delete endpoint | DELETE | /api/v1/webhooks/endpoints/:id |
| Roll secret | POST | /api/v1/webhooks/endpoints/:id/roll-secret |
Update an Endpoint
curl -X PATCH https://api.tryaccess.xyz/api/v1/webhooks/endpoints/we_01HXYZ... \
-H "Content-Type: application/json" \
-H "x-api-key: sk_..." \
-d '{ "status": "disabled" }'You can update url, enabled_events, and status (active or disabled).
Roll Secret
Generate a new signing secret. The old secret is immediately invalidated:
curl -X POST https://api.tryaccess.xyz/api/v1/webhooks/endpoints/we_01HXYZ.../roll-secret \
-H "x-api-key: sk_..."Webhook Events
List Events
curl "https://api.tryaccess.xyz/api/v1/webhooks/events?type=checkout.completed&limit=20" \
-H "x-api-key: sk_..."| Parameter | Description |
|---|---|
cursor | Pagination cursor |
limit | Results per page (1–100, default 20) |
type | Filter by event type |
endpoint_id | Filter by endpoint |
Get Event Details
Returns the event with its delivery attempts:
curl https://api.tryaccess.xyz/api/v1/webhooks/events/evt_01HXYZ... \
-H "x-api-key: sk_..."The response includes the full payload and an array of deliveries with status, response code, and timestamps for each attempt.
Redeliver an Event
Queue a failed event for redelivery:
curl -X POST https://api.tryaccess.xyz/api/v1/webhooks/events/evt_01HXYZ.../redeliver \
-H "x-api-key: sk_..."Cannot redeliver to a disabled endpoint.
Retry Policy
Failed deliveries are retried with exponential backoff:
| Attempt | Delay |
|---|---|
| 1st retry | 1 minute |
| 2nd retry | 5 minutes |
| 3rd retry | 30 minutes |
| 4th retry | 2 hours |
| 5th retry | 24 hours |
After 5 failed attempts, the endpoint is marked as failing. No further retries are attempted until manually re-enabled or the event is redelivered.
If your endpoint answers 429 Too Many Requests, 502 Bad Gateway or 504 Gateway Timeout, Access slows down: it holds all deliveries to that endpoint for 30 seconds, doubling with each such answer in a row up to 15 minutes, or for as long as your Retry-After asks. Held deliveries don't use up any of their 10 attempts; they go out when the hold ends. The first successful delivery lifts it.
Best Practices
- Return 2xx quickly - Process webhooks asynchronously. Return a 200 status immediately and handle the event in a background job.
- Verify signatures - Always verify the
x-access-signatureheader before processing. - Handle duplicates - Use the event
idto deduplicate. The same event may be delivered more than once. - Monitor failures - Check the webhook events list for failed deliveries and redeliver as needed.
How is this guide?