07 webhooks

Webhooks notify your server when events occur in Stablix. Use them to automate order fulfillment, update your database, and sync with your systems.

Setup

Configure Webhook URL

POST /merchants/webhook
{
  "url": "https://yoursite.com/webhooks/stablix",
  "events": [
    "invoice.paid",
    "invoice.released",
    "dispute.opened"
  ]
}

Response

{
  "success": true,
  "message": "Webhook configured. Save your webhook secret now.",
  "data": {
    "webhook_secret": "whsec_abc123def456..."
  }
}
circle-exclamation

Webhook Events

Invoice Events

Event
Description

invoice.created

Invoice created

invoice.paid

Payment received, funds in escrow

invoice.released

Funds released to merchant

invoice.refunded

Invoice refunded

invoice.expired

Payment deadline passed

Subscription Events

Event
Description

subscription.created

Subscription created

subscription.approved

Subscriber approved spending

subscription.activated

Subscription activated

subscription.charged

Successful charge

subscription.charge_failed

Charge failed

subscription.paused

Subscription paused

subscription.resumed

Subscription resumed

subscription.cancelled

Subscription cancelled

Dispute Events

Event
Description

dispute.opened

Dispute opened

dispute.evidence_submitted

Evidence added

dispute.status_changed

Status updated

dispute.resolved

Dispute resolved


Webhook Payload

All webhooks follow this structure:


Verifying Signatures

Every webhook includes a signature header. Always verify signatures before processing webhooks.

Headers

Header
Description

X-Stablix-Signature

HMAC-SHA256 signature

X-Stablix-Timestamp

Unix timestamp

X-Stablix-Delivery-ID

Unique delivery ID

X-Stablix-Event

Event type

Verification Process

Example Handler (Express)


Retries

If your endpoint returns an error (non-2xx status) or times out, Stablix retries the webhook:

Attempt
Delay

1

Immediate

2

1 minute

3

5 minutes

4

30 minutes

5

2 hours

After 5 failed attempts, the webhook is marked as failed.


Webhook Deliveries

List Deliveries

Query Parameters

Parameter
Type
Description

status

string

pending, delivered, failed

event

string

Filter by event type

page

number

Page number

limit

number

Items per page

Response

Get Delivery Details

Response

Retry Delivery

Manually retry a failed webhook:

Response

Webhook Stats

Response


Testing Webhooks

Local Development

Use a tunnel service to receive webhooks locally:

Test Events

Use test mode API keys to create test invoices. Test payments trigger real webhooks to your endpoint.


Best Practices

1

Return quickly

Process webhooks asynchronously. Return 200 immediately, then handle the event in a background job.

2

Handle duplicates

Use X-Stablix-Delivery-ID to deduplicate. The same event may be delivered multiple times.

3

Verify signatures

Always verify webhook signatures to prevent spoofing.

4

Use HTTPS

Webhook URLs must use HTTPS in production.

5

Monitor failures

Set up alerts for failed webhooks.

6

Implement idempotency

Your handlers should be idempotent. Processing the same webhook twice should have the same result.

Example: Idempotent Handler


Remove Webhook

This removes your webhook configuration. You'll stop receiving webhook notifications.