# Notifications

Notifications should be understood as state change alerts for a specific entity. Once a notification is received, you must perform a **GET** request to the corresponding entity in order to obtain the latest version.

For example, when a successful payment notification is received, you will get something like this:

```
{
  "id": "uCEarm1kXJsroMQ6dt",
  "event_type": "PAYMENT_ORDER.CLOSED",
  "entity_type": "PAYMENT_ORDER",
  "entity_id": "rcAaNfKdKJRmrnj4l5"
}
```

It is with the `entity_id` that you should perform a **GET** request to:

```
/v1/payment_orders/<id>
```

***

In order to receive notifications, you must set the webhook URL through the parameter `custom_urls.status_changes_webhook` when creating a **Checkout Preference**.

***

### Notifications for Payment Orders

Each status change of the **Payment Order** is sent as a POST Request to the URL specified in **status\_changes\_webhook** with the following body:

```json
{
  "id": "uCEarm1kXJsroMQ6dt",
  "event_type": "PAYMENT_ORDER.OPENED",
  "entity_type": "PAYMENT_ORDER",
  "entity_id": "rcAaNfKdKJRmrnj4l5"
}
```

It is important that the service that consumes the webhook is idempotent. The **`id`** attribute is unique for each webhook.

#### Event types

`PAYMENT_ORDER.OPENED` \
`PAYMENT_ORDER.EXPIRED` \
`PAYMENT_ORDER.CLOSED` \
`PAYMENT_ORDER.REJECTED` \
`PAYMENT_ORDER.REFUNDED`

###
