GladysDevelopers

Receiving webhooks

Be told when a payment changes, instead of asking.

When a payment changes state, Gladys sends an HTTP POST to the endpoints your app has registered. Use webhooks to finish orders: the payer may never come back to your site, but the webhook always arrives.

Events

EventSent when
payment.authorizedThe payer approved. With manual capture, the money is now held for you to capture.
payment.capturedThe money moved to your business. Ship the order.
payment.cancelledYou cancelled, or the payer declined.
payment.expiredThe payer didn't approve within 15 minutes, or you didn't capture within 7 days.
payment.refundedA refund was made. Sent once per refund.

With automatic capture, a payer's approval sends payment.authorized and then payment.captured, straight after each other.

Registering an endpoint

curl https://api.joingladys.com/api/v1/webhook-endpoints \
  -H "Authorization: Bearer access_…" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://shop.example/webhooks/gladys",
    "events": ["payment.captured", "payment.cancelled", "payment.expired", "payment.refunded"],
    "description": "Order fulfilment"
  }'
{
  "success": true,
  "message": "Endpoint registered. Store the secret now — it is not shown again.",
  "data": {
    "id": "6d0c…",
    "url": "https://shop.example/webhooks/gladys",
    "events": ["payment.captured", "payment.cancelled", "payment.expired", "payment.refunded"],
    "environment": "TEST",
    "is_active": true,
    "secret": "whsec_…",
    …
  }
}

Store the secret: you need it to verify signatures, and it is never shown again.

  • Leave out events to receive every event, including any added later.
  • The endpoint belongs to your app and its environment: a TEST app's endpoints hear only about TEST payments.
  • LIVE endpoints must use https. TEST endpoints may use http.
  • The URL must be publicly reachable. Private, loopback and link-local addresses, and hosts such as .internal or .local, are refused. To receive TEST webhooks on your own machine, expose it with a tunnel.

Registering, changing and removing endpoints needs the payments:capture scope; listing them needs payments:read.

What arrives

POST /webhooks/gladys HTTP/1.1
Content-Type: application/json
User-Agent: Gladys-Webhooks/1
Gladys-Signature: t=1791201600,v1=5f2b8c…
Gladys-Event-Id: evt_Qm9yZXN0LXRlc3Q
Gladys-Event-Type: payment.captured
Gladys-Delivery-Attempt: 1

{
  "version": 2,
  "event_id": "evt_Qm9yZXN0LXRlc3Q",
  "event_type": "payment.captured",
  "created_at": "2026-10-05T12:00:00.123456Z",
  "payment": {
    "reference": "pay_yM5jfhPZAGaJPTSMrSVpklbh",
    "status": "CAPTURED",
    "checkout_url": "https://api.joingladys.com/pay/pay_yM5jfhPZAGaJPTSMrSVpklbh",
    "amount": "1500.00",
    "fee": "15.00",
    "net_amount": "1485.00",
    "refunded_amount": "0.00",
    "refundable_amount": "1500.00",
    "currency": "KES",
    "merchant_reference": "order_1042",
    "capture_method": "AUTOMATIC",
    "environment": "TEST",
    "authorized_at": "2026-10-05T11:59:58Z",
    "captured_at": "2026-10-05T11:59:59Z",
    …
  }
}

Version 2 uses major-unit decimal strings at the currency's precision. Replaying a stored unversioned delivery retains its original integer-cent body and signature scheme; process its units according to that older contract.

payment is the full payment object, as it was when the event happened. A payment.refunded event also has a refund object.

Responding

  1. Verify the signature before trusting anything in the body. See Verifying signatures.
  2. Answer quickly with any 2xx. Gladys waits up to 10 seconds; anything else, including a redirect, counts as a failure and is retried. Do slow work, such as sending emails, after you've answered.
  3. Expect duplicates. The same event can arrive more than once; use event_id to skip ones you've handled. See Retries and replay.

Managing endpoints

GET /webhook-endpointsList your app's endpoints.
PATCH /webhook-endpoints/{id}Change url, events, description, or is_active. Sending "events": [] subscribes to everything.
DELETE /webhook-endpoints/{id}Remove it.
POST /webhook-endpoints/{id}/rotate-secretIssue a new secret. The old one stops immediately: deploy the new secret as soon as you have it.

Setting is_active to false pauses an endpoint without losing its settings.

On this page