How It Works
1
Register a webhook endpoint
Create a webhook via the Dashboard or the API, specifying the URL and which events to subscribe to.
2
AnySpend sends events
When a subscribed event occurs, AnySpend sends a
POST request to your URL with a JSON payload and a signature header.3
Verify and process
Your server verifies the HMAC-SHA256 signature, processes the event, and responds with a
200 status within 30 seconds.4
Automatic retries
If your server does not respond with a
2xx status, AnySpend retries up to 3 times with exponential backoff.Supported Events
Creating a Webhook
- SDK
- cURL
- Dashboard
Webhook Payload
Every webhook delivery sends aPOST request with the following JSON body:
Headers
Reconciling Payments with Your System
Thepayment.completed webhook always includes a checkoutSession block containing clientReferenceId, metadata, customerEmail, and customerName — everything you need to match payments to your internal records.
Using client_reference_id
Pass your order or user ID when creating the checkout (via URL parameter or API):Using metadata
For richer data, use metadata key-value pairs:Verifying Signatures
The signature is computed as:Express.js (Node.js)
Python (Flask)
Retry Policy
If your endpoint does not respond with a2xx status code within 30 seconds, AnySpend marks the delivery as failed and retries.
After 3 failed retries, the delivery is marked as
failed permanently. You can still manually retry it from the Dashboard or API.
If your endpoint consistently fails (10+ consecutive failed deliveries), the webhook will be automatically disabled and you will receive an email notification. Re-enable it from the Dashboard after fixing the issue.
Viewing Delivery History
- SDK
- cURL
Retrying Failed Deliveries
Testing Webhooks
Use the test endpoint to send a synthetic event to your webhook URL. This helps verify your endpoint is reachable and your signature verification logic is correct.- SDK
- cURL
payment.completed event type with mock data. Your handler should process it like any other event, but you can check for the X-AnySpend-Test: true header if you want to skip side effects during testing.
Best Practices
Respond quickly
Return a
200 immediately and process the event asynchronously (e.g., in a background job queue). Webhook deliveries time out after 30 seconds.Handle duplicates
Use the
X-AnySpend-Delivery-Id header or data.id field to deduplicate events. Retries may deliver the same event more than once.Verify signatures
Always verify the
X-AnySpend-Signature header. Never trust the payload without verification.Use HTTPS
Webhook URLs must use HTTPS in production. HTTP URLs are only allowed for
localhost during development.
HypeDuel