Changing notifications of a client
Every customer has notification settings, and Asaas always refers to these when a new charge is created. You can turn notifications on or off, change how many days in advance they will be sent, or define what types of notifications will occur whenever you create a new customer.
The first step, after creating your customer, is to check which notifications were created. To do this, simply call the "Retrieve a customer's notifications" endpoint.
GET
/v3/customers/{id}/notifications
Check the full reference for this endpoint.
Calling this endpoint will return a list of all notifications created for this customer:
{
"object": "list",
"hasMore": false,
"totalCount": 8,
"limit": 10,
"offset": 0,
"data": [
{
"object": "notification",
"id": "not_000042762597",
"customer": "cus_000005358829",
"enabled": true,
...
},
...
]
}
With the ID of each notification in hand, you can edit it.
Notifications are fixed and created by Asaas. It is not possible to delete them or create new ones, only to modify them.
You can choose to edit just one notification, by calling the "Update existing notification" endpoint:
POST
/v3/notifications/not_000042762599
Check the full reference for this endpoint.
{
"enabled": true,
"emailEnabledForProvider": false,
"smsEnabledForProvider": false,
"emailEnabledForCustomer": true,
"smsEnabledForCustomer": false,
"phoneCallEnabledForCustomer": false,
"whatsappEnabledForCustomer": false
}
In the example above, we modified the payment creation notification to send only an email to the customer.
You can also change all notifications together and only leave the notifications you want activated, for example, using the "Batch update notifications" endpoint:
POST
/v3/notifications/batch
Check the full reference for this endpoint.
{
"customer": "cus_Y4AEif5zrMGK",
"notifications": [
{
"id": "not_f8JpoWuEjEKd",
"enabled": true,
"emailEnabledForProvider": true,
"smsEnabledForProvider": true,
"emailEnabledForCustomer": true,
"smsEnabledForCustomer": true,
"phoneCallEnabledForCustomer": false,
"whatsappEnabledForCustomer": false
},
...
]
}
In this example, you can modify the notification settings in bulk to fit your specific needs.
Updated 7 months ago