Setting up Credit Notifications
All notifications are setup for accounts via our Notification API. You must have created an account in order to register a notification for it.
Create the notification
Notifications can be created by making a request to the create-credit-notification endpoint.
POST
https://mplus.instagiv.com/notification/creditjson
{
"account_uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"email_addresses": ["noreply@cymba.co.uk"],
"webhook_url": "https://my.website.com/notify?k=123",
"threshold_type": "packaged_percentage",
"threshold_value": 0.25
}response body
json
{
"status": "success",
"notification_uuid": "fc56b88c-b9f1-4d58-b561-c4ac94b13524"
}In this example, I am:
- Attaching the notification to the account with uuid
3fa85f64-5717-4562-b3fc-2c963f66afa6 - Triggering a notification when the account falls below 25% remaining packaged credits
- Sending a notification email to
noreply@cymba.co.uk - Sending a notification webhook to
https://webhooks.my-website.com/credit-notifications
Receiving webhook requests
If or when the account falls below the threshold I specified, I will receive a HTTP request to the endpoint I specified with the details of what occured.
Credit notification wehook reference
POST
<the webhook URL specified>json
{
"notification_uuid": "fc56b88c-b9f1-4d58-b561-c4ac94b13524",
"account_uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"threshold_type": "packaged_percentage",
"threshold_value": 0.25,
"paid_credit_balance": 120,
"packaged_credit_balance": 99
}In this example:
- The account still has Paid credits remaining. The notification was only configured to trigger on packaged credit balance.
- The packaged credit
scheduled_refresh_amountis400, meaning the 25% threshold is100. The account reached99remaining packaged credits, triggering the notification.
If we receive a non-200 response from the endpoint you specified, we will retry the request up to 6 times, with a minimum 30 second delay between each request.