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

# Notifications

> Asynchronous notifications we send to your server when the status of a deposit or a cashout changes.

Every time a deposit or a cashout changes its status, we send an asynchronous notification to your server containing the ID of the transaction.

The webhooks are sent to:

1. the **`notification_url`** you sent in the request, or
2. the default URL set in Pandablue Connect: **Confirm URL** for deposits and **Withdrawal URL** for cashouts. See [Important configurations](https://docs.pandablue.com/getting-started/important-configurations.md).

**Once you receive the notification, check its new status with the** [Get deposit status](https://docs.pandablue.com/api-reference/deposits-api/manage-payments/get-deposit-status.md) **or** [Get cashout status](https://docs.pandablue.com/api-reference/cashouts-api/manage-cashouts/get-a-cashout-status.md) **endpoint and update it on your end accordingly.**

> [!NOTE]
>
> To test notifications in the Playground environment, see [On Playground](https://docs.pandablue.com/api-reference/references/notifications/on-playground.md).

> [!TIP]
>
> ### Firewall configurations
>
> Bear in mind we will only connect through ports 80 and 443.\
> Make sure your **`notification_url`** has one of those ports open accepting connections from us.

### Example notification

> [tab] Deposits
>
> Deposit notifications are sent as JSON and only carry the ID of the deposit.
>
> ```javascript theme={null}
> {
>     "deposit_id": 3000000001
> }
> ```
>
> | Field | Format | Description |
> | - | - | - |
> | **`deposit_id`** | Number | ID of the deposit. Use this ID to [check the status of the deposit.](https://docs.pandablue.com/api-reference/deposits-api/manage-payments/get-deposit-status.md) |

> [tab] Cashouts
>
> Cashout notifications are sent by **POST** in **x-www-form-urlencoded** format.
>
> ```http theme={null}
>     date=2020-03-12%2020%3A26%3A11
>     &bank_reference_id=
>     &comments=
>     &external_id=cashoutV35381
>     &control=<SIGNATURE>
>     &cashout_id=60067
>     &status_reason=
> ```
>
> | Field | Format | Description |
> | - | - | - |
> | `date` | Date. Format: YYYY-MM-DD HH:MM:SS (GMT) | Date the cashout changed its status |
> | `bank_reference_id` | String (max. 50 chars) | Reference ID of the bank if any |
> | `comments` | String (max. 200 chars) | Comments of the cashout if any |
> | `external_id` | String (max. 100 chars) | ID of the cashout you sent while creating the request |
> | `control` | String | Control signature of the notification |
> | `cashout_id` | Number | ID of the cashout on our end |
> | `status_reason` | String | Reason of the status if any |

### Control string

The `control` field is part of the **cashout** notifications.

The control string for the notifications is made up of some random characters at the beginning and the end of the request and the **`external_id`** received in the middle.

> [!NOTE]
>
> The control string should be generated using your own secret key (API Signature) and must be in upper case.
>
> Make sure you convert the message to hash to **UTF-8** to prevent errors.

Check the examples below on how to calculate the control string for the notifications:

> [tab] JAVA
>
> ```java theme={null}
> public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
>       String external_id = "cashoutID1234";
>       String message = "Be4" + external_id + "Bo7";
>       String apiSignature = "your_cashout_api_signature";
>
>       Mac hasher = Mac.getInstance("HmacSHA256");
>       hasher.init(new SecretKeySpec(apiSignature.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
>       byte[] result = hasher.doFinal(message.getBytes(StandardCharsets.UTF_8));
>
>       System.out.println(StringUtils.upperCase(DatatypeConverter.printHexBinary(result)));
> }
> ```

> [tab] PHP
>
> ```php theme={null}
> $external_id = 'cashoutID1234';
> $message = 'Be4' . $external_id . 'Bo7';
> $api_signature = 'cashout_api_signature';
>
> $hash = strtoupper(hash_hmac('sha256', pack('A*', $message), pack('A*', $api_signature)));
>
> ```

> [tab] C#
>
> ```csharp theme={null}
>  string external_id = "cashoutID1234";
>  string message = "Be4" + external_id + "Bo7";
>  string apiSignature = "your_cashouts_api_signature";
>
>  byte[] keyByte = new System.Text.Encoding.UTF8.GetBytes(apiSignature);
>  byte[] messageBytes = new System.Text.Encoding.UTF8.GetBytes(message);
>  byte[] hashmessage = new HMACSHA256(keyByte).ComputeHash(messageBytes);
>
>  string control = BitConverter.ToString(hashmessage).Replace("-", "").ToUpper();
>
> ```

### Retry logic

Every time a deposit or a cashout changes its status, we will send you a notification so you can check its status back.

In case that for some reason your server was unable to handle our notification and you returned an HTTP code different than **2XX**, we will retry the notification **up to 5 more times** **or until you respond with HTTP 2XX**, whatever comes first.

> [!TIP]
>
> In case of errors while handling the notification, make sure you will answer with an HTTP code distinct than 2XX, that way we will retry the notification.

The time between the 5 notification attempts depends on the API:

* **Deposits:** exponential, **5, 25, 125 and 625 minutes** accordingly.
* **Cashouts:** **5 minutes** each.

When a notification failed to be sent, it is shown with an error icon in the **Status history** of the transaction, in Pandablue Connect.

If you see these errors, it means the transaction was successfully completed (and, for a deposit, the money was credited to your account) but we **could not notify you**. Keep reading to know how to resend the notifications.

### Resend notifications

In case your system was unable to handle the notification in any of the 5 attempts, you can always check its status with the [Get deposit status](https://docs.pandablue.com/api-reference/deposits-api/manage-payments/get-deposit-status.md) or [Get cashout status](https://docs.pandablue.com/api-reference/cashouts-api/manage-cashouts/get-a-cashout-status.md) endpoint.

If you need to trigger the check status by receiving our notification, once the issue preventing you from receiving our notifications was fixed, go to Pandablue Connect, locate the transaction (**Transactions**), click on the three dotted button under the **Status history** section and then "**Resend notification**" to force a new notification to be sent.

![Transaction in Pandablue Connect with the Resend Notification option](https://mintcdn.com/pandablue/m9RsQ5H1Ao1dRBj9/images/methods/resend-notification.png?fit=max\&auto=format\&n=m9RsQ5H1Ao1dRBj9\&q=85\&s=257ba7961d2cf1d1281c88cdfd02f27e)

> [!TIP]
>
> 🕐 **It can take up to 1 minute for a deposit notification to be resent, and up to 2 minutes for a cashout notification.**


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