Webhooks API

Receive real-time notifications when remittance events occur. Register webhook endpoints, manage subscriptions, and verify event signatures.

Overview

Glin sends webhook events via HTTP POST to URLs you register. Each event contains a unique event ID, the event type, timestamps, and a remittance snapshot. Your endpoint should return a 2xx status code to acknowledge receipt.

Webhooks are the recommended way to track remittance status changes. Do not rely solely on redirect URLs or polling -- use webhooks for reliable server-side confirmation.

Event Types

Subscribe to any combination of the following event types:

Event TypeDescription
remittance_createdA new remittance was created.
remittance_paidCustomer payment was confirmed.
remittance_deliveredFunds have been delivered to the merchant.
remittance_canceledThe remittance was canceled.
remittance_expiredThe remittance expired before payment was completed.
remittance_payment_returnedMoney arrived for the sale and was sent back to the paying account — most often because the paying account is held by someone other than the registered payer. The sale does not change status: it stays payable and accepts another attempt until it expires. The envelope carries a reason field; GET /remittances/{id}/events has the full sequence.

Webhook Payload

Every webhook delivery sends a JSON payload with the following structure:

Webhook Payload
{
  "id": "9b5599d4-6800-4b5f-9e7d-67dff2d12a2f",
  "type": "remittance_paid",
  "happenedAt": "2026-02-25T14:30:00Z",
  "notifiedAt": "2026-02-25T14:30:01Z",
  "object": {
    "type": "target_amount_fixed",
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "paid",
    "clientReferenceId": "order-12345",
    "amount": 500.0,
    "currency": "USD",
    "offeringType": "PRODUCT",
    "payoutAmount": 500.0,
    "payoutCurrency": "USD",
    "exchangeRate": 5.12,
    "expiresAt": "2026-03-01T19:00:00Z",
    "successUrl": "https://your-site.com/order/success?id=12345",
    "cancelUrl": "https://your-site.com/order/cancel?id=12345",
    "checkoutUrl": "https://pay.glin.com.br/remittances/550e8400-e29b-41d4-a716-446655440000",
    "shortUrl": "https://www.glin.com.br/pay/K7M2QXPTRW",
    "payment": {
      "method": "card",
      "installments": 6
    }
  }
}

object is the same remittance object the Remittances API returns, so every field documented there arrives here too — including payoutAmount, payoutCurrency and exchangeRate. That makes the webhook the place to reconcile what you were paid: on remittance_paid those three are settled and final, with no second call needed.

Price a sale in BRL and remittance_created cannot carry them, because no rate is fixed until a payer starts checkout. It carries estimatedPayout instead — a quote at the rate of that moment, which is indicative and not something to reconcile against. The settled figures then arrive on remittance_paid.

remittance_created, priced in BRL
{
  "id": "9b5599d4-6800-4b5f-9e7d-67dff2d12a2f",
  "type": "remittance_created",
  "happenedAt": "2026-02-25T14:28:00Z",
  "notifiedAt": "2026-02-25T14:28:01Z",
  "object": {
    "type": "source_amount_fixed",
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "created",
    "clientReferenceId": "order-12345",
    "amount": 500.0,
    "currency": "BRL",
    "offeringType": "PRODUCT",
    "estimatedPayout": {
      "amount": 93.93,
      "currency": "USD",
      "exchangeRate": 5.0354
    },
    "expiresAt": "2026-03-01T19:00:00Z",
    "successUrl": "https://your-site.com/order/success?id=12345",
    "cancelUrl": "https://your-site.com/order/cancel?id=12345",
    "checkoutUrl": "https://pay.glin.com.br/remittances/550e8400-e29b-41d4-a716-446655440000",
    "shortUrl": "https://www.glin.com.br/pay/K7M2QXPTRW"
  }
}

Parse the amounts as numbers, not strings. The payload is queued before delivery and that normalises trailing zeros, so an amount the API returns as 500.00 arrives here as 500.0 — the same number, a different spelling.

Payload Fields

Name Type Required Description
idstring (UUID)Unique event identifier. It remains unchanged when the same event is retried; use it as the idempotency key.
typestringThe event type that triggered this webhook (e.g. "remittance_paid").
reasonstring—Only on remittance_payment_returned: why the money went back — "payer_account_owner_mismatch", "duplicate_payment" or "other". It sits on the envelope rather than inside object, which describes the sale and not the attempt.
happenedAtstringISO 8601 timestamp of when the event occurred.
notifiedAtstringISO 8601 timestamp of when the notification payload was prepared. It remains unchanged across retries.
objectobjectMerchant API remittance snapshot used for this event — the same object, with the same fields, that the Remittances API returns. object.id is the remittance ID, not the event ID. object.type is the pricing direction ("target_amount_fixed" or "source_amount_fixed"), not the word "remittance". Paid and delivered snapshots include the confirmed payment method and installments in object.payment.
object.payoutAmountnumber—What you receive, in your payout currency, with object.payoutCurrency and object.exchangeRate alongside it. This is where to reconcile a settled sale: it is present on remittance_paid and remittance_delivered, and on remittance_created only when you priced in your payout currency.
object.estimatedPayoutobject—A quote of what the sale would pay out, present instead of payoutAmount while no rate has been fixed — so a BRL-priced remittance_created carries this and no payoutAmount. Indicative only: do not reconcile against it.

Create Webhook

POST/merchant-api/webhooks/

Registers a new webhook endpoint to receive event notifications.

Request Body

Name Type Required Description
urlstringThe HTTPS URL where webhook events will be sent via POST.
eventTypesstring[]—Event types to subscribe to. Omit it or send an empty array to receive every supported event.

Example Request

cURL
curl --request POST \
  --url https://pay.staging.glin.com.br/merchant-api/webhooks/ \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "url": "https://your-site.com/webhooks/glin",
  "eventTypes": [
    "remittance_paid",
    "remittance_delivered",
    "remittance_canceled"
  ]
}'

Response

json
{
  "id": 42,
  "url": "https://your-site.com/webhooks/glin",
  "eventTypes": [
    "remittance_paid",
    "remittance_delivered",
    "remittance_canceled"
  ]
}

Response Fields

Name Type Required Description
idintegerUnique identifier for the webhook subscription.
urlstringThe registered webhook endpoint URL.
eventTypesstring[]Event types this webhook is subscribed to.

List Webhooks

GET/merchant-api/webhooks/

Returns all webhook subscriptions registered for the authenticated integration key.

cURL
curl --request GET \
  --url https://pay.staging.glin.com.br/merchant-api/webhooks/ \
  --header 'Authorization: Bearer YOUR_API_KEY'

Response

json
[
  {
    "id": 42,
    "url": "https://your-site.com/webhooks/glin",
    "eventTypes": [
      "remittance_paid",
      "remittance_delivered",
      "remittance_canceled"
    ]
  }
]

Delete Webhook

DELETE/merchant-api/webhooks/{id}

Removes a webhook subscription. Events will no longer be delivered to the specified endpoint.

Path Parameters

Name Type Required Description
idintegerThe unique identifier of the webhook subscription to delete.
cURL
curl --request DELETE \
  --url https://pay.staging.glin.com.br/merchant-api/webhooks/42 \
  --header 'Authorization: Bearer YOUR_API_KEY'

Delivery, Idempotency, and Retries

A delivery is acknowledged only when your endpoint returns a 2xx response. The complete HTTP call has a five-second timeout, so acknowledge quickly and process the event asynchronously when possible.

Any failed delivery is retried. Glin currently makes up to 15 redeliveries after the initial attempt, so an event is attempted at most 16 times. The backoff grows exponentially — nominally 1s, 4s, 16s, 64s, 256s, 1024s, then capped at one hour — but the actual spacing also depends on broker load, so it is not guaranteed. Sequences that used all 16 attempts have been observed to complete in anywhere from about 11 minutes to about 15 hours. Rely on the attempt count, not on a fixed schedule.

Responses in the 4xx range other than 408 and 429 are treated as permanent failures. The endpoint is suspended after five consecutive permanent failures or 50 consecutive transient failures. Suspensions start at 15 minutes and increase to one hour, six hours, and 24 hours after failed recovery attempts. Deliveries that reach an open circuit, and new events emitted while it remains open, are not queued for later replay. Poll the remittance endpoint after recovery to reconcile current state.

Every redelivery of an event carries the same top-level id; store that value before applying side effects.

JWS Signature Verification

Every webhook delivery includes a cryptographic signature in the x-jws-signature header. The signature uses the RS256 algorithm with an unencoded detached payload as defined in RFC 7797.

Verification Steps

  1. Extract the x-jws-signature header from the incoming request.
  2. Fetch the public JWK Set from Glin at /merchant-api/jwks.json, using the integration API key as a Bearer token.
  3. Preserve the exact raw request body bytes (do not parse the JSON first).
  4. Decode and validate the protected header: alg must be RS256, b64 must be false, crit contains only b64 and aud, and aud matches your integration account ID (the username portion of the decoded API credential).
  5. Verify RS256 over the ASCII bytes of the encoded protected header plus a period, followed directly by the unencoded raw request bytes.

Example (Node.js)

verify-webhook.js
import { createPublicKey, verify } from 'node:crypto';

function apiAccountIdFromKey(apiKey) {
  // Glin's Bearer value is the base64-encoded Basic credential "account-id:secret".
  const credentials = Buffer.from(apiKey, 'base64').toString('utf8');
  const separator = credentials.indexOf(':');
  const accountId = separator < 0 ? '' : credentials.slice(0, separator).toLowerCase();
  if (!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(accountId)) {
    throw new Error('The API key does not contain a valid integration account ID');
  }
  return accountId;
}

async function verifyWebhook(rawBody, jwsSignature, apiKey, glinBaseUrl) {
  if (!Buffer.isBuffer(rawBody)) {
    throw new Error('rawBody must contain the exact HTTP request bytes');
  }

  const parts = jwsSignature.split('.');
  if (parts.length !== 3) {
    throw new Error('Invalid detached JWS');
  }
  const [protectedHeaderPart, detachedPayloadPart, signaturePart] = parts;
  const isBase64url = value => /^[A-Za-z0-9_-]+$/.test(value);
  if (!isBase64url(protectedHeaderPart) || detachedPayloadPart !== ''
      || !isBase64url(signaturePart)) {
    throw new Error('Invalid detached JWS');
  }

  const header = JSON.parse(Buffer.from(protectedHeaderPart, 'base64url').toString('utf8'));
  const understoodCriticalHeaders = header && typeof header === 'object'
    && !Array.isArray(header)
    && Array.isArray(header.crit)
    && header.crit.length === 2
    && header.crit.every(name => name === 'b64' || name === 'aud')
    && header.crit.includes('b64')
    && header.crit.includes('aud');
  const expectedAudience = apiAccountIdFromKey(apiKey);
  if (!understoodCriticalHeaders || header.alg !== 'RS256' || header.b64 !== false
      || typeof header.kid !== 'string' || !header.kid || header.aud !== expectedAudience) {
    throw new Error('Unexpected protected JWS header');
  }

  const jwksResponse = await fetch(
    new URL('/merchant-api/jwks.json', glinBaseUrl),
    { headers: { Authorization: 'Bearer ' + apiKey } }
  );
  if (!jwksResponse.ok) {
    throw new Error('Could not fetch the Glin JWKS: HTTP ' + jwksResponse.status);
  }
  const jwks = await jwksResponse.json();
  const jwk = jwks.keys.find(candidate => candidate.kid === header.kid);
  if (!jwk) {
    throw new Error('No JWK matches the signature kid');
  }

  // RFC 7797: header + "." + the unencoded payload bytes. Do not base64url the body.
  const signingInput = Buffer.concat([
    Buffer.from(protectedHeaderPart + '.', 'ascii'),
    rawBody,
  ]);
  const publicKey = createPublicKey({ key: jwk, format: 'jwk' });
  const valid = verify(
    'RSA-SHA256',
    signingInput,
    publicKey,
    Buffer.from(signaturePart, 'base64url')
  );
  if (!valid) {
    throw new Error('Invalid Glin webhook signature');
  }

  return JSON.parse(rawBody.toString('utf8'));
}

Always verify webhook signatures in production. Without verification, an attacker could send forged webhook events to your endpoint. Cache the JWK Set response to avoid fetching it on every request, but refresh it immediately when the signature's kid is not present in the cached set.

The detached payload format (RFC 7797) means the payload is not included in the JWS token itself. You must use the raw HTTP request body as the payload when verifying. Do not base64url-encode it and do not re-serialize parsed JSON -- use the exact bytes received in the request.