logoAccess

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

Create webhook 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

EventDescription
checkout.session.completedCheckout session payment succeeded
checkout.session.expiredCheckout session expired

Payments

EventDescription
payment.completedPayment was verified
payment.failedPayment verification failed

Crypto

EventDescription
crypto_payment.confirmingCrypto for a payment arrived and is being confirmed
crypto_payment.finishedA crypto payment was paid in full
crypto_payment.failedA crypto payment failed, like when too little was sent
crypto_payment.expiredA crypto payment ran out of time before it was paid
crypto_payout.paidA crypto payout or refund was sent
crypto_payout.failedA crypto payout or refund couldn't be sent
crypto_payout.rejectedA crypto payout or refund was rejected

Subscriptions

EventDescription
subscription.renewedSubscription period renewed
subscription.payment_failedSubscription renewal payment failed
customer.subscription.canceledSubscription was cancelled

Invoices

EventDescription
invoice.paidInvoice was paid
invoice.payment_failedInvoice payment failed
invoice.voidedInvoice was voided

Webhook Payload

Example 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:

Verify webhook signature
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

ActionMethodEndpoint
Create endpointPOST/api/v1/webhooks/endpoints
List endpointsGET/api/v1/webhooks/endpoints
Get endpointGET/api/v1/webhooks/endpoints/:id
Update endpointPATCH/api/v1/webhooks/endpoints/:id
Delete endpointDELETE/api/v1/webhooks/endpoints/:id
Roll secretPOST/api/v1/webhooks/endpoints/:id/roll-secret

Update an Endpoint

Disable 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:

Roll webhook secret
curl -X POST https://api.tryaccess.xyz/api/v1/webhooks/endpoints/we_01HXYZ.../roll-secret \
  -H "x-api-key: sk_..."

Webhook Events

List Events

List events
curl "https://api.tryaccess.xyz/api/v1/webhooks/events?type=checkout.completed&limit=20" \
  -H "x-api-key: sk_..."
ParameterDescription
cursorPagination cursor
limitResults per page (1–100, default 20)
typeFilter by event type
endpoint_idFilter 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:

Redeliver event
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:

AttemptDelay
1st retry1 minute
2nd retry5 minutes
3rd retry30 minutes
4th retry2 hours
5th retry24 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

  1. Return 2xx quickly - Process webhooks asynchronously. Return a 200 status immediately and handle the event in a background job.
  2. Verify signatures - Always verify the x-access-signature header before processing.
  3. Handle duplicates - Use the event id to deduplicate. The same event may be delivered more than once.
  4. Monitor failures - Check the webhook events list for failed deliveries and redeliver as needed.

How is this guide?