# Callbacks (Webhooks)

{% hint style="success" %}
Looking for Webhooks? You're on the right page!
{% endhint %}

Callbacks are used to send real-time notifications on the events that happen on a bunq account.&#x20;

To receive notifications for certain events on a bunq account, you need to create notification filters. It is possible to send the notifications to a provided URL and/or the user’s phone as push notifications.

## Notification FIlters

Use the `notification-filter-push` resource to create and manage *push notification filters*. Provide the type of events you want to receive notifications about in the `category` field.&#x20;

Example request body:

```
{
   "notification_filters":[
      {
         "category":"SCHEDULE_RESULT"
      }
   ]
}
```

Use the `notification-filter-url` resource to create and manage *URL notification filters*. The callback URL you provide in the notification\_target field must use HTTPS.&#x20;

Example request body:

```
{
   "notification_filters":[
      {
         "category":"PAYMENT",
         "notification_target":"{YOUR_CALLBACK_URL}"
      }
   ]
}
```

### Callback categories

| Category                      | Description                                                                                                                                                                                                                                            |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| BILLING                       | notifications for all bunq invoices                                                                                                                                                                                                                    |
| CARD\_TRANSACTION\_SUCCESSFUL | notifications for successful card transactions                                                                                                                                                                                                         |
| CARD\_TRANSACTION\_FAILED     | notifications for failed card transaction                                                                                                                                                                                                              |
| CHAT                          | notifications for received chat messages                                                                                                                                                                                                               |
| DRAFT\_PAYMENT                | notifications for creation and updates of draft payments                                                                                                                                                                                               |
| IDEAL                         | notifications for iDEAL-deposits towards a bunq account                                                                                                                                                                                                |
| SOFORT                        | notifications for SOFORT-deposits towards a bunq account                                                                                                                                                                                               |
| MUTATION                      | notifications for any action that affects a monetary account’s balance                                                                                                                                                                                 |
| OAUTH                         | notifications for revoked OAuth connections                                                                                                                                                                                                            |
| PAYMENT                       | notifications for payments created from, or received on a bunq account (doesn’t include payments that result out of paying a Request, iDEAL, Sofort or Invoice). Outgoing payments have a negative value while incoming payments have a positive value |
| REQUEST                       | notifications for incoming requests and updates on outgoing requests                                                                                                                                                                                   |
| SCHEDULE\_RESULT              | notifications for when a scheduled payment is executed                                                                                                                                                                                                 |
| SCHEDULE\_STATUS              | notifications about the status of a scheduled payment, e.g. when the scheduled payment is updated or cancelled                                                                                                                                         |
| SHARE                         | notifications for any updates or creation of Connects (ShareInviteBankInquiry)                                                                                                                                                                         |
| TAB\_RESULT                   | notifications for updates on Tab payments                                                                                                                                                                                                              |
| BUNQME\_TAB                   | notifications for updates on bunq.me Tab (open request) payments                                                                                                                                                                                       |
| SUPPORT                       | notifications for messages received from us through support chat                                                                                                                                                                                       |

### Mutation Category

A *Mutation* is a change in the balance of a monetary account. A *Mutation* is created for each payment-like object, such as a request, iDEAL-payment or a regular payment. Therefore, the `MUTATION`category can be used to keep track of a monetary account's balance change.

### Receiving Callbacks

* Callbacks for the sandbox environment will be made from different IP's at AWS.
* Callbacks for the production environment will be made from 185.40.108.0/22.

*The IP addresses might change*. We will notify you in a timely fashion if such a change is planned.

### Removing callbacks

To remove callbacks for an object, send a POST request to the `notification_filters` endpoint with a JSON request body with an emtpy list.&#x20;

```
{
    "notification_filters": []
}
```

## Retry Mechanisms

When the execution of a callback fails (e.g. the callback server is down or the response contains an error), we try to resend it for a maximum of 5 times, with an interval of one minute between each try. If your server is not reachable by the callback after the 6th total try, the callback is not sent anymore.

### Listing of failed callbacks

After the sixth attempt of callback executing, the failed entry is stored and can be listed by UserApiKey&#x20;

```
GET
/v1/user/762/notification-filter-failure
{
    "Response": [
        {
            "NotificationFilterFailure": {
                "id": 1,
                "created": "2023-05-22 06:47:22.043906",
                "updated": "2023-05-22 06:47:22.043906",
                "category": "MUTATION",
                "event_type": "MUTATION_CREATED",
                "object_id": 1278,
                "notification_filters": [
                    {
                        "notification_delivery_method": "URL",
                        "notification_target": "https://coolbank.com/notification",
                        "category": "MUTATION"
                    },
                    {
                        "notification_delivery_method": "URL",
                        "notification_target": "https://coolbank.com/notification",
                        "category": "CARD_TRANSACTION_SUCCESSFUL"
                    }
                ]
            }
        }
    ],
    "Pagination": {
        "future_url": "/v1/user/762/notification-filter-failure?newer_id=1",
        "newer_url": null,
        "older_url": null
    }
}
```

\* the category & object\_id can be used to verify if the callback has failed and should be retried

\*\* the id of the NotificationFilterFailure object should be used to trigger the retry

### Retry of failed callbacks

```
POST
/v1/user/762/notification-filter-failure
{
    "notification_filter_failed_ids": "1"
}
```

\* multiple ids can be given in the same field, comma separated. Maximum of 100 ids are allowed

\*\* response will be empty with code 200 (OK)

<br>

&#x20;

## Setting up a callback&#x20;

Check [Notification Filter](/notification-filter.md) for all possible callbacks, here we show one example API call to set up a new URL notification. For instance for succesful card transactions: \
\`\`\`

```json

{
    "notification_filters": [
        {"category": "CARD_TRANSACTIONSUCCESSFUL",
        "notification_target": "https://webhook.site/994966bb-7a4c-4be3-836a-da65231b907d"}
    ]
}

```

{% openapi src="/files/xJ3v0GinyfONRbxz8Srh" path="/user/{userID}/notification-filter-url" method="post" %}
[swagger.json](https://346554585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGE9Y1hc6C24r4Hen6KFH%2Fuploads%2FIUa888wk2qwhos5DXTS3%2Fswagger.json?alt=media\&token=020e751b-2a4b-4993-8247-1f0b9fab0bf5)
{% endopenapi %}

##

## Certificate Pinning

We recommend that you use certificate pinning as an extra security measure. We will check if the certificate of the recipient server matches the pinned certificate that you provided and cancel the callback if the check fails or we detect a mismatch.

### How to set up certificate pinning

1. Retrieve the SSL certificate of your server using the following command:

   `openssl s_client -servername www.example.com -connect www.example.com:443 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem`
2. `POST` the certificate to the `certificate-pinned`endpoint.

Once ready, every callback will be checked against the pinned certificate that you provided. Note that if the SSL certificate on your server expires or is changed, our callbacks will fail.

{% openapi src="/files/xJ3v0GinyfONRbxz8Srh" path="/user/{userID}/certificate-pinned" method="post" %}
[swagger.json](https://346554585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGE9Y1hc6C24r4Hen6KFH%2Fuploads%2FIUa888wk2qwhos5DXTS3%2Fswagger.json?alt=media\&token=020e751b-2a4b-4993-8247-1f0b9fab0bf5)
{% endopenapi %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.bunq.com/basics/callbacks-webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
