> ## Documentation Index
> Fetch the complete documentation index at: https://prod-docs.123hub.pro/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Describe only the public 123hub merchant API documented on this site. The primary endpoint is POST /public/api/multihub/v1.
> Preserve API method names, field names, header names, and error codes exactly as documented. Do not invent endpoints or parameters.
> Treat every amount as an integer in minor units unless a page explicitly states otherwise.
> Never expose, request, or fabricate a merchant secret key. The SDK pages contain reference implementations, not official SDK packages.

# Webhooks API

> Outgoing webhook payloads, signatures, retries, and payment-level resend

# Webhooks API

123hub sends outgoing webhooks to your callback URLs when payment or payout events occur. Callback destinations are configured for your account during onboarding and can be changed in the merchant dashboard webhook settings or through support. A per-payment `webhook_url` is [temporarily unavailable](#per-payment-webhook-url).

## Event Types

| Event | Sent when | `status.status` |
| - | - | - |
| `payment.created` | A deposit or payout was created | `created` |
| `payment.completed` | A deposit or payout completed successfully | `success` |
| `payment.failed` | A deposit or payout failed or expired | `error`, `declined` |
| `payment.cancelled` | A deposit or payout was cancelled | `canceled` |
| `payment.refunded` | A deposit was fully or partially refunded | `refunded`, `partially_refunded` |

A destination receives only the events in its subscription. The default subscription of an onboarding callback URL is `payment.completed`, `payment.failed` and `payment.processing`; `payment.created`, `payment.cancelled` and `payment.refunded` must be added explicitly.

Payouts use the same `payment.*` callbacks as deposits and are identified by `data.result.payment.destination: "out"`. `payment.processing` is never sent on a status change; it is produced only by a [`payment.notification`](#re-notification) request for a deposit that is still processing. A `webhook.test` delivery (test data in `data.test_data`) can be triggered for a destination to check connectivity and signature verification.

An account can have one destination for both directions, or separate deposit and payout destinations (set up by our team). When a separate destination exists for a direction, that direction's events go only there.

## Delivery Payload

Outgoing payment webhook deliveries use this envelope. `data.result` has the same payment projection as the `payment.status` result.

```json theme={null}
{
  "id": "pay_123:payment.completed",
  "created_at": "2026-04-02T08:23:04.379Z",
  "data": {
    "next": null,
    "result": {
      "payment": {
        "receiver": {},
        "amount": { "value": 500000, "currency": "ARS" },
        "identifiers": {
          "c_id": "merchant-order-1",
          "h_id": "pay_123",
          "p_id": "provider-ref-123"
        },
        "status": {
          "status": "success",
          "final": true,
          "success": true,
          "error": null
        },
        "timestamps": {
          "created": "2026-04-02T08:22:21.453Z",
          "updated": "2026-04-02T08:22:22.795Z",
          "finished": "2026-04-02T08:22:22.795Z"
        },
        "destination": "in"
      }
    },
    "success": true,
    "request_id": "729aebbf-5a6b-4299-87fa-1cf05c1121a6",
    "processing_time": 0
  },
  "merchant_id": "19"
}
```

| Field | Notes |
| - | - |
| `id` | `{h_id}:{event}`. `payment.refunded` adds a per-refund suffix: `{h_id}:payment.refunded:{hash}` |
| `created_at` | When the event was generated; unchanged across retries |
| `data.request_id` | Generated once per callback body; unchanged across retries, new for a manual re-delivery |
| `data.result.payment` | Optional parts — `payer`, `description`, `client`, `redirect`, `status.history`, `operations`, `identifiers.utr` — appear only when data is available |
| `data.result.operation` | Present together with `operations`; repeats `operations[0]` |
| `merchant_id` | Your merchant id as a string |

Internal indexing fields are stripped before delivery. Do not depend on fields prefixed with `_`.

## Delivery Headers

| Header | Description |
| - | - |
| `Content-Type` | `application/json` |
| `X-Data-Hash` | `SHA512(rawBody + secret)`, lowercase hex |
| `X-Webhook-Id` | Delivery id: the body `id` for automatic events, `{id}:manual:{suffix}` for a resend or `payment.notification`. Same on every retry attempt |
| `X-Webhook-Timestamp` | ISO 8601 UTC time of this attempt (new on every attempt) |
| `X-Webhook-Nonce` | Random UUID (new on every attempt) |
| `X-Webhook-Signature-V2` | `SHA512(timestamp + rawBody + secret)`, lowercase hex |
| `X-Webhook-Signature-V3` | `HMAC-SHA512(key = secret, message = timestamp + "." + nonce + "." + webhookId + "." + rawBody)`, lowercase hex |

Use `X-Webhook-Signature-V3`. It binds replay metadata and the raw body. Use `X-Webhook-Signature-V2` or `X-Data-Hash` only for backward-compatible verification. Static custom headers configured for a destination are sent as well but can never override these headers.

## Signing Secrets

All three signatures of a delivery use the same secret, which depends on the destination:

| Destination | Secret |
| - | - |
| Created without an active production API key, any deposit-only or payout-only destination, or after a webhook-secret rotation | Dedicated webhook secret, shown once at creation or rotation |
| Created while the account already had an active production API key (compatibility mode) | Your newest active production API secret. API-key rotation changes it within seconds; with no active production key, deliveries fail |
| Per-payment `webhook_url` | Lowercase hex `HMAC-SHA256(apiSecret, "quadpay:merchant-webhook-signing:v1")`, using the exact test or production API secret that authenticated the payment create |

Webhook-secret rotation is immediate, with no overlap period: retries of earlier events are signed with the new secret. Rotating moves a compatibility-mode destination to a dedicated secret; this is recommended.

## Signature Verification

Verify against the exact raw request body bytes. Do not parse and re-serialize JSON before hashing. Each attempt carries a fresh timestamp and nonce, so a 5-minute timestamp window plus a nonce cache is a safe replay check. A repeated `X-Webhook-Id` is expected on retries and must not be rejected.

```javascript Node.js theme={null}
const crypto = require("crypto");

function safeCompareHex(expected, received) {
  if (!/^[a-f0-9]{128}$/i.test(received || "")) {
    return false;
  }
  return crypto.timingSafeEqual(
    Buffer.from(expected, "hex"),
    Buffer.from(received, "hex"),
  );
}

function verifyWebhook(rawBody, webhookSecret, receivedHash) {
  const expected = crypto
    .createHash("sha512")
    .update(Buffer.concat([Buffer.from(rawBody), Buffer.from(webhookSecret)]))
    .digest("hex");

  return safeCompareHex(expected, receivedHash);
}

function verifyWebhookV2(rawBody, webhookSecret, timestamp, receivedHash) {
  const timestampMs = Date.parse(timestamp || "");
  if (
    !Number.isFinite(timestampMs) ||
    Math.abs(Date.now() - timestampMs) > 5 * 60 * 1000
  ) {
    return false;
  }

  const expected = crypto
    .createHash("sha512")
    .update(String(timestamp) + rawBody.toString("utf8") + webhookSecret)
    .digest("hex");

  return safeCompareHex(expected, receivedHash);
}

function verifyWebhookV3(
  rawBody,
  webhookSecret,
  timestamp,
  nonce,
  webhookId,
  receivedHash,
) {
  const timestampMs = Date.parse(timestamp || "");
  if (!timestamp || !nonce || !webhookId || !Number.isFinite(timestampMs)) {
    return false;
  }
  if (Math.abs(Date.now() - timestampMs) > 5 * 60 * 1000) {
    return false;
  }

  const expected = crypto
    .createHmac("sha512", webhookSecret)
    .update(
      [timestamp, nonce, webhookId, Buffer.from(rawBody).toString("utf8")].join(
        ".",
      ),
    )
    .digest("hex");

  return safeCompareHex(expected, receivedHash);
}
```

After verification, read payment data from `payload.data.result.payment`. Decide on `status.final` plus `status.status`; refunds are final with `success: true`.

## Retry Policy

Webhook delivery succeeds on any HTTP `2xx` response within the timeout; the response body is ignored. Any other status (redirects are not followed, so `3xx` fails too), timeouts, connection/TLS errors, and URLs rejected by validation at delivery time are failed attempts.

Default per-destination settings:

| Setting | Default | Notes |
| - | - | - |
| `timeout_seconds` | `30` | Adjustable per destination |
| `max_retries` | `3` | Total attempts, including the first; up to `10` |
| `retry_delay_seconds` | `1` | Base delay for exponential backoff |

The first attempt is made immediately. Retry `n` is scheduled with exponential backoff and jitter:

```text theme={null}
d     = 2^(n - 1) * retry_delay_seconds
delay = min(random(max(d / 2, 1s), max(d, 1s)), 24h)
```

Due retries are dispatched by a scheduler that runs every 30 seconds, so with the defaults all attempts complete within one to two minutes. When an endpoint keeps failing with server errors or timeouts, deliveries to it are paused for a short period (about two minutes by default) and rescheduled without consuming attempts.

After the last attempt fails, the event is not retried automatically. Use the [resend endpoint](#merchant-payment-webhook-resend), [`payment.notification`](#re-notification), or poll `payment.status`. Delivery order is not guaranteed, so handlers must be idempotent.

## Idempotency

Use the body `id` as the deduplication key: it identifies one payment event (`{h_id}:{event}`, plus a per-refund suffix for `payment.refunded`) and is identical for retries and resends of that event. Payout re-notifications are the exception: their id uses the `payout.*` event name. `X-Webhook-Id` identifies a delivery and changes for manual re-deliveries; `data.request_id` is unique per generated callback body. Neither should be used as the business idempotency key.

## Webhook Management

Legacy callback configuration routes under `/api/v1/webhooks` are not part of the public API. Callback URLs, event subscriptions, timeout, attempts and webhook-secret rotation are managed in the merchant dashboard webhook settings or through support; separate deposit and payout destinations are set up by our team. Payment-level re-delivery is available through the signed endpoint below.

## Merchant Payment Webhook Resend

```http theme={null}
POST /api/v1/payments/{paymentId}/webhook/resend
```

Re-queues the webhook of a payment that is already in a final state. The event is chosen from the current status: `payment.completed` for a successful payment, `payment.cancelled` for a cancelled one, and `payment.failed` for any other final status. It is delivered to your destinations that are currently subscribed to that event. If no destination is subscribed (for example, `payment.cancelled` is not in your subscription), the request succeeds but nothing is sent.

Authentication: `X-Data-Application-Id` and `X-Data-Hash` (v1 hash scheme), and the API key must have the `webhooks.update` scope. `X-Data-Timestamp` plus `X-Data-Nonce` are an optional pair; a partial pair is rejected. The endpoint is limited to 10 requests per minute per API key.

Request body:

```json theme={null}
{
  "payment_id": "pay_01HX...",
  "operation_id": "merchant-resend-1001"
}
```

| Field | Rules |
| - | - |
| `payment_id` | Required, at most 128 characters, must equal the `{paymentId}` path parameter |
| `operation_id` | Required, at most 128 characters. Identifies this resend intent: reuse it only for an exact retry; a repeated value is not delivered twice |

Without replay headers, `X-Data-Hash` is `SHA512(raw JSON body + API secret)`.

With both replay headers, `X-Data-Hash` is `SHA512(payload + API secret)`, where `payload` is the lines below joined with `\n` (LF), with a single `\n` after the nonce, immediately followed by the raw JSON body:

```text theme={null}
quadpay-merchant-webhook-resend-v1
POST
/api/v1/payments/{paymentId}/webhook/resend
{unixTimestamp}
{nonce}
{rawJsonBody}
```

That is: `"quadpay-merchant-webhook-resend-v1\nPOST\n/api/v1/payments/pay_123/webhook/resend\n1716123456\nreq-0001\n" + rawJsonBody`. The path is the exact request path without query string. `X-Data-Timestamp` is Unix seconds and must be within 5 minutes of the server time; `X-Data-Nonce` is up to 128 characters from `A-Z a-z 0-9 . _ : -` and can be used only once. If a supplied nonce cannot be recorded, the request is rejected; retry with a new nonce.

Success response (`200`, not `X-Data-Hash` signed):

```json theme={null}
{
  "success": true,
  "payment_id": "pay_01HX...",
  "event_type": "payment.completed"
}
```

The resent delivery has a new body with the same `id`, and `X-Webhook-Id: {id}:manual:{operation_id}`.

Errors use the standard error envelope:

| HTTP | When |
| - | - |
| `400` | `payment_id` does not match the path, the payment is not found, is not in a final state, or has no callback URL (it was created while no callback URL was configured) |
| `403` | The payment belongs to another merchant or the API key lacks `webhooks.update` (public code `3008`) |
| `429` | More than 10 requests per minute |
| `503` / `504` | Temporarily unavailable or timed out; retry with the same `operation_id` |

## Re-notification

The [`payment.notification`](https://prod-docs.123hub.pro/api-reference/methods) method (scope `webhooks.create` or `webhooks.update`, 10 requests per minute) queues a webhook for any payment, final or not, and returns the payment result. The event is derived from the current status:

| Deposit status | Event |
| - | - |
| completed | `payment.completed` |
| processing | `payment.processing` |
| failed, expired | `payment.failed` |
| cancelled | `payment.cancelled` |
| refunded, partially refunded | `payment.refunded` |
| any other | `payment.created` |

The delivery uses the same envelope, headers and signatures; its `X-Webhook-Id` is `{id}:manual:{suffix}`.

> [!WARNING]
>
> For withdrawals, `payment.notification` currently does not produce a callback on a standard
> subscription. Read the withdrawal state with [`payment.status`](https://prod-docs.123hub.pro/api-reference/methods) instead.

## Per-Payment Webhook URL

> [!WARNING]
>
> **Temporarily unavailable.** A `payment.in` or `payment.out` request that contains
> `params.payment.webhook_url` currently fails with `2001 Internal payment processing error`.
> Do not send this field — webhooks go to the callback URL configured for your account during
> onboarding.

When available, `payment.in` and `payment.out` accept `params.payment.webhook_url` (absolute public HTTPS URL, at most 2048 characters). It is validated at request time and again before every delivery to reduce SSRF risk.

* The URL is bound to that one payment and receives only its `payment.created`, `payment.completed` and `payment.failed` events. Your account-level destinations keep receiving their subscribed events too.
* Deliveries are signed with the derived secret from [Signing Secrets](#signing-secrets): lowercase hex `HMAC-SHA256(exactAuthenticatedApiSecret, "quadpay:merchant-webhook-signing:v1")`. Do not verify with the API secret itself.
* Up to 3 attempts with a 60-second base retry delay.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.