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

# Subscribe to Webhooks

> Subscribe to RazorpayX webhook events to receive the status of payouts and fund account validations.

Available in
🇲🇾 Malaysia

> [!NOTE]
>
> RazorpayX payouts in Malaysia are available on request. RazorpayX is not enabled on Razorpay Curlec accounts by default. To enquire about RazorpayX for your business, [contact our Support team](https://curlec.com/docs/payments/dashboard/support.md).

Webhooks (Web Callback, HTTP Push API or Reverse API) are one of the ways in which one web application can send information to another application in real time when a specific event happens. Know more about [Webhooks](https://curlec.com/docs/webhooks).

## Set Up Payout Webhooks

To set up a webhook:

1. Log in to the [RazorpayX Dashboard](https://x.razorpay.com/auth).
2. Navigate to **My Account & Settings** → **Developer Controls** → **Webhooks**.
3. Add your webhook URL and a secret.
4. Select the events you want to receive.
5. Save the webhook.

> [!NOTE]
>
> **Handy Tips**
>
> If anything about the set-up is unclear, contact your account manager.

## Webhook Events and Descriptions

The table below lists the webhook events available for RazorpayX in Malaysia.

| Webhook Event | Description |
| - | - |
| `payout.pending` | Triggered when a payout above the approval amount is created and is waiting for approval. |
| `payout.rejected` | Triggered when a checker rejects the payout on the Dashboard. |
| `payout.queued` | Triggered when the payout is queued, for example for low balance. |
| `payout.initiated` | Triggered when the payout is sent to the bank. |
| `payout.processed` | Triggered when the beneficiary is credited. |
| `payout.failed` | Triggered when the payout fails. The reason is in `status_details`. |
| `payout.reversed` | Triggered when the bank returns the payout and the amount is credited back to your balance. The reason is in `status_details`. |
| `payout.updated` | Triggered when a payout detail changes without a change of status. |
| `fund_account.validation.completed` | Triggered when a fund account validation completes. |
| `fund_account.validation.failed` | Triggered when a fund account validation cannot be completed. |

> [!WARNING]
>
> **Watch Out!**
>
> Subscribe to the `payout.failed` event. If you do not, a failed payout is reported to you as `payout.reversed` instead.

Failure and reversal reasons come in the `status_details` object of the payout, on API responses and webhooks. It carries the `reason`, the `description` and the `source`. Know more about [payout status details](https://curlec.com/docs/x/payouts/status-details.md).

## Verify the Signature

When your webhook secret is set, Razorpay Curlec uses it to create a hash signature with each payload. This hash signature is passed with each request under the `X-Razorpay-Signature` header. Validate it at your end and discard the webhook if the signatures differ.

`X-Razorpay-Signature`
: The hash signature is calculated using HMAC with the SHA-256 algorithm, your webhook secret set as the key and the raw webhook request body as the message.

> [!WARNING]
>
> **Watch Out!**
>
> While generating the signature at your end, ensure that the webhook body passed as an argument is the raw webhook request body. Do not parse or cast the webhook request body.

```
key                = webhook_secret
message            = webhook_body // raw webhook request body
received_signature = webhook_signature

expected_signature = hmac('sha256', message, key)

if expected_signature != received_signature
    throw SecurityError
end
```

## Respond and Handle Retries

* Respond with HTTP 200 within 5 seconds. A webhook that does not receive a 2xx response is sent again.
* The same event can arrive more than once or out of order. Use the payout `id` and `status` to decide the current state.
* Match the webhook against the [Fetch a Payout With ID](https://curlec.com/docs/api/x/payouts/fetch-with-id.md) API if you are unsure of the latest status.

## Sample Payload

The following is a sample `payout.processed` payload for a payout to a DuitNow proxy:

```json payout.processed theme={null}
{
  "entity": "event",
  "account_id": "acc_BFQ7uQEaa7j2z7",
  "event": "payout.processed",
  "contains": ["payout"],
  "payload": {
    "payout": {
      "entity": {
        "id": "pout_F681qslJ3ba70q",
        "entity": "payout",
        "fund_account_id": "fa_F681qr6Bqy1Je8",
        "amount": 5000,
        "currency": "MYR",
        "notes": {},
        "fees": 0,
        "tax": 0,
        "status": "processed",
        "purpose": "payout",
        "utr": "20261120XXXXMYKL010OBB12345678",
        "mode": "DUITNOW",
        "reference_id": "INV-1042",
        "narration": "Acme Vendor Payment",
        "batch_id": null,
        "status_details": {
          "description": "Payout is processed and the amount has been credited.",
          "reason": "payout_processed",
          "source": "beneficiary_bank"
        },
        "created_at": 1795089601
      }
    }
  },
  "created_at": 1795089601
}
```

### Related Information

* [About Webhooks](https://curlec.com/docs/webhooks)
* [Payout APIs](https://curlec.com/docs/api/x/payouts.md)
* [Payout States and Life Cycle](https://curlec.com/docs/x/payouts/states-life-cycle.md)
