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

# Webhooks

> Configure Cashfree Payouts webhooks to receive HTTP callbacks for every transfer status change so your systems stay synced without polling the API.

Webhooks are events that notify you about the payment status. All Payout integrations should establish a webhook to listen to payout events, like status changes on payments. Webhooks are HTTP callbacks that receive notification messages for events.

Webhooks help you receive automatic updates and are significant for completing the integration with Cashfree. Webhooks are triggered with a request from your side, for example, when a transfer fails or when a daily report is available. Requests get processed both synchronously and asynchronously. In rare scenarios, for some payment methods, the outcome may take a longer duration to confirm. Cashfree notify you once we get updates from the bank about the payment status.

Do not go live without signature verification if you are using webhooks. For comprehensive security measures including IP whitelisting and signature verification, refer to the [Webhook Security Checklist](https://www.cashfree.com/docs/payments/online/webhooks/security-checklist.md).

Configure your webhook URL from the Payouts Dashboard to receive real-time notifications for payout events.

To configure webhooks:

1. Log in to the [Merchant Dashboard](https://merchant.cashfree.com/auth/login).
2. Go to **Payouts Dashboard** > **Developers** > click **Webhook** in the **Payouts** section.
3. In the **Developers - Payouts** screen, click **Add Webhook URL**.
4. Enter the URL where you want to receive the updates about the [payout events](https://www.cashfree.com/docs/payouts/payouts/make-payouts/webhooks.md#webhook-events).

![](https://mintcdn.com/cashfreepayments-d00050e9/_iQwC827ZHOkrGFs/static/payouts/payouts/make-payouts/Screenshot_2022-04-06_at_3.58.13_PM.png?fit=max\&auto=format\&n=_iQwC827ZHOkrGFs\&q=85\&s=46293b8d3994516d8f6f4a7e66770914)

5. Click **Test & Add Webhook**.

> [!NOTE]
>
> When you click **Test & Add Webhook**, Cashfree sends a `LOW_BALANCE_ALERT` event to the configured webhook URL to verify the webhook endpoint. The test event confirms that the endpoint is reachable, can process webhook requests successfully, and returns an HTTP `200 OK` response. After the endpoint is validated, Cashfree delivers all subsequent webhook events to the configured URL.
>
> For the `LOW_BALANCE_ALERT` test event, the signature and timestamp are included in the webhook payload. For all other V2 webhook events, the signature and timestamp are sent in the request headers.

## Webhook events

Payouts webhooks enable you to receive updates about all event-driven activities originating from your account. Below is the list of payouts webhooks:

| Events | Notifications |
| :- | :- |
| TRANSFER\_SUCCESS | Transfer successful at the bank and account debited. |
| [TRANSFER\_APPROVED](https://www.cashfree.com/docs/payouts/payouts/make-payouts/webhooks.md#transfer_approved) | Transfer approved by Approver through the API or dashboard |
| TRANSFER\_FAILED | Sent whenever a transfer attempt fails. |
| TRANSFER\_REVERSED | Transfer reversed by the beneficiary bank. |
| CREDIT\_CONFIRMATION | Confirmation of balance credit. |
| TRANSFER\_ACKNOWLEDGED | After the beneficiary bank has deposited the money it confirms the transfer. |
| TRANSFER\_REJECTED | Transfer rejected by Cashfree. |
| BENEFICIARY\_INCIDENT | Sent whenever a beneficiary incident is created/resolved. |
| LOW\_BALANCE\_ALERT | Payouts recharge account low balance alert. |

## TRANSFER\_SUCCESS​

Sent when a transfer is attempted successfully.

| Parameters | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = TRANSFER\_SUCCESS. |
| transferId | Id of the transfer passed by the merchant. |
| referenceId | Id of the transfer generated by Cashfree. |
| acknowledged | The flag indicates if the beneficiary bank has acknowledged the transfer. |
| eventTime | Transfer initiation time. |
| utr | Unique transaction reference number provided by the bank. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

### What does the response parameter 'acknowledged' mean

The acknowledged parameter value conveys if the beneficiary received the funds by checking its value. Ack = 1 or 0. 1 denotes the beneficiary received funds, and 0 denotes the beneficiary had not received funds.

The cash flow happens as explained below:

1. Debit: The debit of the transfers happens on the remitter account. After a successful debit, the beneficiary bank does further processing. When only the debit is successful, Ack = 0.

2. Credit: The beneficiary bank credits the fund to the account. The transfer is sent from the remitter bank to the beneficiary bank after a successful debit. When the credit to the end beneficiary is successful, Ack = 1.

To confirm the status of a payout, you need to check the acknowledged parameter value. If the value is 1, you can mark the transfer as successful. However, if the value is 0, you must either wait for the TRANSFER\_ACKNOWLEDGED webhook event or use the [Get Transfer Status](https://www.cashfree.com/docs/api-reference/payouts/v1/get-transfer-status.md) API and confirm the acknowledged value.

## TRANSFER\_APPROVED

The webhook is sent when Approver approves the transfer through the dashboard or via API.

| Parameters | Description |
| :- | :- |
| event | It displays the occurred event name. Value = TRANSFER\_APPROVED. |
| transferId | It displays the ID of the transfer created by you (merchants). |
| referenceId | It displays the ID of the transfer created by Cashfree. |
| approvedBy | It displays the username of the approver if done through the dashboard. It displays API if done via API. |
| approvedAt | It displays the time of the approval. |
| signature | It displays the unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

## ​TRANSFER\_FAILED

Sent when a transfer attempt fails.

| Parameters | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = TRANSFER\_FAILED. |
| transferId | Id of the transfer passed by the merchant |
| referenceId | Id of the transfer generated by Cashfree. |
| reason | Reason for failure. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

## TRANSFER\_REVERSED

Sent when the beneficiary bank reverses a transfer.

| Parameters | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = TRANSFER\_REVERSED. |
| transferId | Id of the transfer passed by the merchant. |
| referenceId | Id of the transfer generated by Cashfree. |
| eventTime | Time at which the transfer was reversed. |
| reason | Reason for failure. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

## CREDIT\_CONFIRMATION

Sent when the balance credit is confirmed.

| Parameters | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = CREDIT\_CONFIRMATION. |
| ledgerBalance | The overall balance of the ledger. |
| amount | Amount deposited. |
| utr | Unique transaction reference number provided by the bank. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

## TRANSFER\_ACKNOWLEDGED

Sent when the bank acknowledges a transfer.

| Parameters | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = TRANSFER\_ACKNOWLEDGED. |
| transferId | Id of the transfer passed by the merchant. |
| referenceId | Id of the transfer generated by Cashfree. |
| acknowledged | The flag illustrates if the beneficiary bank acknowledges the transfer. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

## TRANSFER\_REJECTED

Sent when a transfer is rejected.

| Parameter | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = TRANSFER\_REJECTED. |
| transferId | Id of the transfer passed by the merchant. |
| referenceId | Id of the transfer generated by Cashfree. |
| reason | Reason for rejection. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

## BENEFICIARY\_INCIDENT

Sent when a beneficiary incident is created or resolved.

| Parameter | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = BENEFICIARY\_INCIDENT. |
| beneEntity | The entity of the beneficiary (BANK). |
| id | Identifier of the incident. |
| mode | Mode of the incident (IMPS/NEFT) |
| startedAt | Start time of the incident. |
| status | Status of the incident (ACTIVE/RESOLVED). |
| isScheduled | Scheduled or unscheduled incident (true or false). |
| severity | The severity of the incident (LOW/HIGH). |
| entityName | Name of the entity on which the incident is created (Bank Name). |
| entityCode | Code of the entity on which the incident is created. |
| resolvedAt | Resolution time of the incident. |

## LOW\_BALANCE\_ALERT

Sent when the payout balance is low.

| Parameter | Description |
| :- | :- |
| event | It contains the name of the event which just occurred. Value = LOW\_BALANCE\_ALERT |
| currentBalance | The current balance of the beneficiary account |
| alertTime | Alert initiation time. |
| signature | A unique string that helps distinguish that the request is genuine and initiated by Cashfree. |

**Delay in Receiving the Response**

Cashfree receives a response from the bank with the status of the transfer instantly. At times the response may get delayed due to various reasons, and the transaction status will be marked as Pending, till we get a response.

Cashfree polls the transaction status from the bank for the next 72 hours. If we do not receive the status after 72 hours, you must manually reconcile the transaction.

## Signature verification

Cashfree sends a signature alongside every webhook, verifying this signature ( passed along with the POST parameters ) is mandatory before processing any response. It helps authenticate that the webhook is from Cashfree.

We strongly recommend whitelisting Cashfree production IP to help make your communication with us more secure.

Following are the steps to verify Cashfree signature:

1. Get all the POST parameters except ‘signature’ and assign it to an array as key-value pair.
2. Sort the array based on keys.
3. Concatenate all the values in this array and the resultant is the post data (say, postData).
4. Encrypt **postData** using SHA-256, then base64-encode it.
5. Now verify if both the signature calculated and the signature received a match.
6. Proceed further if it matches, else discard the request.

Our libraries also support signature verification. To verify the signature returned by Cashfree call the following methods from the library.

Below are the code snippets that can help you verify the signature:

```php PHP theme={"dark"}
<?php
  $data = $_POST;
  $signature = $_POST["signature"];
  unset($data["signature"]); // $data now has all the POST parameters except signature
  ksort($data); // Sort the $data array based on keys
  $postData = "";
  foreach ($data as $key => $value){
    if (strlen($value) > 0) {
      $postData .= $value;
    }
  }
  $hash_hmac = hash_hmac('sha256', $postData, $clientSecret, true) ;
  
  // Use the clientSecret from the oldest active Key Pair.
  $computedSignature = base64_encode($hash_hmac);
  if ($signature == $computedSignature) {
    // Proceed based on $event
  } else {
    // Reject this call
  }
?>
```

```java Java theme={"dark"}
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Mac;
import org.apache.commons.codec.binary.Base64;

public class ComputedSignature {

    public static boolean checkSignature(String clientSecret, String data) {

// write your code here
ObjectMapper objectMapper = new ObjectMapper();
String signatureKey = "signature";
String hash = "";
try {
Map<String, Object> jsonMap = objectMapper.readValue(data, new TypeReference<Map<String, Object>>(){});
String signature = jsonMap.get(signatureKey).toString();

            // remove the signature from map
            jsonMap.remove(signatureKey);
             Map<String, Object> sortedMap =  jsonMap.entrySet().
                     stream().
                     sorted(Map.Entry.comparingByKey()).
                     collect(Collectors.toMap(
                             Map.Entry::getKey,
                             Map.Entry::getValue,
                             (oldValue, newValue) -> oldValue, LinkedHashMap::new
                     ));

             // sort the map based on keys
             String postDataString = sortedMap.keySet().stream().map(key -> sortedMap.get(key).toString()).collect(Collectors.joining());

             // encode the post data on sha256
             Mac sha256HMAC = Mac.getInstance("HmacSHA256");
             SecretKeySpec secretKey  = new SecretKeySpec(clientSecret.getBytes(), "HmacSHA256");
             sha256HMAC.init(secretKey);

             hash = Base64.encodeBase64String(sha256HMAC.doFinal(postDataString.getBytes()));

             // check the hash generated with signature passed
             return hash.equals(signature);

        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

}

```

```javascript Node theme={"dark"}
const Cashfree = require("cashfree-sdk");
//convert post response recived in the notification end point to json
//and pass that to the SDK.
Cashfree.Payouts.VerifySignature(webhookPostDataJson, signature, clientSecret);
```

```python Python theme={"dark"}
from cashfree_sdk import verification

#webhook_data = response.content
webhook_data = '{"cashgramId": "5b8283182e0711eaa4c531df6a4f439b-28", "event": "CASHGRAM_EXPIRED", "eventTime": "2020-01-03 15:01:06", "reason": "OTP_ATTEMPTS_EXCEEDED", "signature": "TBpM+4nr1DsWsov7QiHSTfRJP4Z9BD8XrDgEhBlf9ss="}'
verification.verify_webhook(webhook_data, 'JSON')
```

> [!NOTE]
>
> To verify the signature, use the first active API key generated on the Merchant Dashboard (the oldest API key), not the latest API key. Using the oldest (first) active API key is mandatory for signature generation and verification.

## Webhook retries

Cashfree webhooks service does its best to deliver events to your webhook endpoint. It's best practice for your application to respond to the callback. Our webhook service may send many payloads to a single endpoint in quick succession. You will need to build an application and configure your server to receive the response we send when events get triggered during the payout process.

Your server should return a 200 HTTP status code to acknowledge that you received the webhook without any issues. Any other information you return in the request headers or request body is ignored. Any response code outside the 200 range, including 3xx codes, indicates that you didn't receive the webhook.

When Cashfree doesn't receive the acknowledgement for any reason, we retry to establish communication at regular intervals. If we don't receive the response after several attempts, we gradually decrease the rate of retries. Based on this count, the service is disabled if it fails more than five times.

If you don't receive notifications from Cashfree as expected, please fill out the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1).

## Development and testing webhooks

When you decide to use webhooks, first, you need to have a URL to receive notifications. This URL should be an HTTPS endpoint and accept JSON payload with the `POST` method. The easiest way to test out webhooks is with tools like Ngrok, Webhook.site, Beeceptor etc.

Simply use these services to create a new endpoint and put it in Cashfree. When a webhook has been sent through, you should see it on these tools. You can inspect the entire payload and share it with colleagues for further development and testing.

## IPs to whitelist

When you decide to consume the webhooks, first, you need to verify whether your systems need IP whitelisting to be done at your end or not. Accordingly, you can whitelist the below IPs of Cashfree:

| UAT |
| :- |
| 52.66.25.127 |
| 15.206.45.168 |

| Prod |
| :- |
| 52.66.101.190 |
| 3.109.102.144 |
| 18.60.134.245 |
| 18.60.183.142 |

| Port |
| :- |
| 443 (secured) |

## FAQs

> [accordion] Can I configure multiple webhook URLs for my Payouts account?
>
> Currently, you can configure only one webhook URL per Payout ID. If you require multiple webhook URLs, create a separate Payout ID and configure a different webhook URL for that account. Contact your Account Manager to help you create an additional Payout ID.

Related topics

<ul>
  <li>[Configure Webhooks API v2](https://www.cashfree.com/docs/api-reference/payouts/v2/webhooks/webhooks-v2.md)</li>
  <li>[Webhook Signature Verification](https://www.cashfree.com/docs/payouts/payouts/make-payouts/webhooks.md)</li>
  <li>[Get Transfer Status API v2](https://www.cashfree.com/docs/api-reference/payouts/v2/transfers-v2/get-transfer-status-v2.md)</li>
  <li>[Webhooks FAQs](https://www.cashfree.com/docs/help/payouts/general-faqs.md)</li>
</ul>


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