Skip to content
SwapWalletDocs
فارسیGet an API key

Webhook events

What SwapWallet sends to your webhook URL, field by field.

Invoice paid

POSTINVOICE

SwapWallet sends a POST request to the invoice's webhookUrl, or to your business webhook URL if the invoice has none, whenever a payment for the invoice is processed:

  • each confirmed blockchain transfer to the invoice's temporary wallet, including one that doesn't cover the invoice yet (its status is still ACTIVE) and one that arrives after it's paid;
  • a payment from a SwapWallet account, or of a Toman receipt;
  • a call to Retry a webhook delivery.

event.invoice is the invoice as it was when the payment was processed. Its status is PAID once the invoice is paid, or SETTLED if the funds had already moved to your SwapWallet account.

Responding. Answer with a 2xx status within 10 seconds. A 4xx or 5xx status, a timeout or a connection error is a failure; when SwapWallet can't connect at all, it tries once more right away through its server in Iran. Failed deliveries are retried after 1, 2, 4, 8, 16 and 32 minutes, then every hour, up to 72 attempts over about three days. Each attempt has a new requestId, event.time and hmac; the invoice in it stays the same.

Verifying. There's no signature header. hmac is HMAC-SHA256 of the event object, keyed with your business API key (the whole key, business- included), in lowercase hex. It's computed over event exactly as it appears in the body, so take that part of the raw body rather than re-encoding parsed JSON. The webhooks guide has code for this. If you'd rather not check the signature, fetch the invoice with Retrieve an invoice and act on that response instead of the body.

Check event.invoice.status before you fulfill: a transfer that doesn't cover the invoice also sends this webhook, with status still ACTIVE.

The same payment can be delivered more than once: after a timeout, a retry or a manual resend. requestId changes on every attempt, so make your handler idempotent on event.invoice.id and event.invoice.paidAmount.

The hmac in the example is real: it was computed with the example key business-vBExgheIWAcggPDCdyLYFqOuAX3pkP7X2V71X5F04zWAiMUyCzRPoxbFibTtAjV6, so you can test your verification code against it. Each attempt is signed with the key your business has at that moment: after you regenerate the key, retries use the new one.

Headers

  • Content-Typestring

    Always application/json.

  • User-Agentstring

    Always SwapWallet.

Payload

  • requestIdUUID

    Unique ID of this delivery attempt. It changes on every attempt, so don't use it to detect duplicates.

  • hmacstring

    Signature of event: HMAC-SHA256 keyed with your business API key, in lowercase hex.

  • eventobject

    The event. hmac is computed over this object as sent.

    Show child attributesHide child attributes
    • timeISO 8601 timestamp

      When this attempt was sent.

    • typeenum

      Kind of event.

      Possible values

      • INVOICEA payment for an invoice. The only type.
    • invoiceobject

      The Invoice object as it was when the payment was processed. wallet is always null and paymentLinks always empty.

      Show child attributesHide child attributes
      • idUUID

        Unique identifier of the invoice.

      • supportCodestring

        Short code to quote to SwapWallet support, such as AI-8LEYRQH-G8HM.

      • statusenum

        Where the invoice is in its lifecycle.

        Possible values

        • ACTIVEWaiting for payment. Transfers so far, if any, don't cover it yet.
        • PAIDPaid. The funds are in your business balance.
        • SETTLEDPaid, and the funds have moved to the owner's SwapWallet account.
        • EXPIREDexpiredAt passed before the invoice was paid.
        • CANCELEDCanceled. Not used for invoices created through this API.
      • descriptionstringnullable

        The description you sent.

      • customDatastringnullable

        The customData you sent, unchanged.

      • walletobjectnullable

        The temporary wallet the customer pays into; for a Toman receipt, deepLinks holds the SwapWallet payment link. Returned only by Retrieve an invoice; null in lists, by order ID and in webhooks.

        Show child attributesHide child attributes
        • networkstring

          Network of the address, such as BSC.

        • tokenstring

          Token to send, such as USDT.

        • addressstring

          Address to send to.

        • validUntilISO 8601 timestamp

          Same as the invoice's expiredAt.

      • ownerIdinteger

        SwapWallet user ID of the business owner.

      • telegramInlineMessageIdstringnullable

        Used by SwapWallet's Telegram bot. Always null for invoices created through this API.

      • userLanguageenumnullable

        The language you sent.

        Possible values

        • FAPersian
        • ENEnglish
        • RURussian
        • ZHChinese
        • FRFrench
        • ITItalian
        • DEGerman
        • ESSpanish
        • KOKorean
      • returnUrlstringnullable

        The return URL you sent.

      • webhookUrlstringnullable

        This invoice's webhook URL. When null, webhooks go to your business webhook URL, if it's set.

      • orderIdstringnullable

        Your order ID.

      • amountMoneynullable

        What the customer pays: for a temporary-wallet invoice, the token amount to send; for a Toman receipt, the Toman amount (IRT). null only while a customer still has to choose the token.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

      • valueMoneynullable

        amount valued in US dollars (USD).

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

      • feePayerenum

        Who pays SwapWallet's fee. Temporary-wallet invoices always use APPLICATION.

        Possible values

        • APPLICATIONYour business: deducted from what you receive.
        • USERThe customer: added to what they pay.
      • feeAmountMoneynullable

        SwapWallet's fee on this invoice, in the unit of paidAmount. Final once the invoice is paid; null or an estimate before that.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

      • paidAmountMoneynullable

        Total received so far, before SwapWallet's fee. For blockchain payments it adds up every confirmed transfer, so it can be below amount (a partial payment) or above it. For a Toman receipt it's in the token the payment was converted to. null until the first payment.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

      • paidAtISO 8601 timestampnullable

        When the first payment arrived. It's set by a transfer that doesn't cover the invoice too, so decide on status, not on paidAt.

      • blockchainStatusenumnullable

        What SwapWallet sees on the network for this invoice. null when it was paid from a SwapWallet account.

        Possible values

        • NOT_SEENNo transfer to the address yet.
        • NOT_CONFIRMA transfer is on the network but isn't confirmed yet.
        • CONFIRMEDA transfer is confirmed.
      • userIdstringnullable

        The userId you sent.

      • userEmailstringnullable

        The userEmail you sent.

      • userPhoneNumberstringnullable

        The userPhoneNumber you sent.

      • userTelegramIdintegernullable

        The userTelegramId you sent.

      • userDisplayNamestringnullable

        The userDisplayName you sent.

      • lockHoursinteger

        Hours the payment stays in your business balance before it's settled to the owner's account. Set when the invoice is paid; 0 before that.

      • expiredAtISO 8601 timestamp

        When the invoice stops accepting payment.

      • createdAtISO 8601 timestamp

        When the invoice was created.

Example payload
{
  "requestId": "a7d0cb53-b035-44b4-b48e-4b04a59d5f97",
  "hmac": "e14c8f2ae561e80d64faffc2274c823c2b0aedc4bb9e32918fafe991f6d43bf6",
  "event": {
    "time": "2026-11-23T09:20:43.004871392Z",
    "type": "INVOICE",
    "invoice": {
      "id": "bcbb332e-0bf8-4da2-a42f-a75a0be6c36f",
      "supportCode": "AI-8LEYRQH-G8HM",
      "status": "PAID",
      "description": "Spotify Premium, 1 month",
      "customData": "{\"cartId\":\"c-88412\"}",
      "wallet": null,
      "ownerId": 905513,
      "telegramInlineMessageId": null,
      "userLanguage": "FA",
      "returnUrl": "https://pixelshop.example/orders/1042",
      "webhookUrl": "https://pixelshop.example/webhooks/swapwallet",
      "orderId": "ORD-1042",
      "amount": {
        "number": "9.18",
        "unit": "USDT"
      },
      "value": {
        "number": "9.18",
        "unit": "USD"
      },
      "feePayer": "APPLICATION",
      "feeAmount": {
        "number": "0.0918",
        "unit": "USDT"
      },
      "paymentLinks": [],
      "paidAmount": {
        "number": "9.18",
        "unit": "USDT"
      },
      "paidAt": "2026-11-23T09:19:41.552904Z",
      "blockchainStatus": "CONFIRMED",
      "userId": "u-58213",
      "userEmail": "parsa@example.com",
      "userPhoneNumber": "+989123334455",
      "userTelegramId": 974181500,
      "userDisplayName": "Parsa",
      "lockHours": 0,
      "expiredAt": "2026-11-23T10:12:04.318227Z",
      "createdAt": "2026-11-23T09:12:04.318512Z"
    }
  }
}