Overview
Call this endpoint as a POST request to register a webhook using the URL that you have provided in the body.
Endpoint
Method | URL |
---|---|
POST |
https:// {{your_url}} /api/2.0/production/sms/webhooks/create |
Properties
Property |
Sub-Property |
Description |
Data Type |
Parameters |
Validation Rules |
---|---|---|---|---|---|
event_types |
These are the types of events that you are able to track from the transactional SMS |
Array |
|
|
|
url |
|
This is the URL of the webhook that the data will be passed to |
String |
|
|
verb |
This is the method that is used for data requesting and receiving data |
String |
|
|
|
auth_details |
This is an array of authentication details, if the webhook needs basic authentication |
Array |
|
||
auth_details |
username |
This is the username required if the webhook has authentication |
String |
|
|
auth_details |
password |
This is the password required if the webhook has authentication |
String |
|
|
auth_type |
This field is used to select the authentication type of the webhook |
String |
basic |
|
|
status |
This field is used to set if the webhook is enabled or disabled |
String |
|
|
Requests
{ "webhook": { "event_types": [ "sent" ], "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "username", "password": "password" }, "auth_type": "basic", "status": "enabled" } }
curl --location 'https://{{your_url}}/api/2.0/production/sms/webhooks/create' \ --data '{ "webhook": { "event_types": [ "sent" ], "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "username", "password": "password" }, "auth_type": "basic", "status": "enabled" } }'
Responses
Status Code |
Explanation |
---|---|
200 OK |
Webhook was created successfully |
400 Bad Request |
The request body was formatted improperly. If there are keys missing, then the message returned will let you know that the request body was not formatted properly as well as what is missing or what is incorrect. |
401 Unauthorized |
The provided authorization credentials are incorrect |
200 OK
{ "webhook": { "event_types": [ "sent" ], "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "administrator", "password": "password" }, "auth_type": "basic", "status": "enabled" } }
{ "status": "success", "data": { "webhook": { "id": "9edf82f9-fb6b-4427-a494-919957d17b3b", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "verb": "POST", "auth_details": { "username": "administrator", "password": "password" }, "auth_type": "basic", "status": "enabled", "updated_timestamp": "2023-09-12T12:05:49+02:00", "created_timestamp": "2023-09-12T12:05:49+02:00", "event_types": [ "sent" ] } } }
400 Bad Request
Invalid body (missing event_types) { "webhook": { "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "administrator", "password": "password" }, "auth_type": "basic", "status": "enabled" } }
{ "status": "error", "data": "The payload for the webhook is not in the correct format. {\"webhook.event_types\":[\"The webhook.event types field is required.\"]}" }
401 Unauthorized
"Invalid credentials."
Validation Errors
Status Code |
Explanation |
---|---|
Data Type Validation |
If a field is given data of the incorrect type, such as status, the response will return an error status with data that shows which field is the issue and what the data type should be. |
Required Validation |
If a field is required, but is missing from the request body, then the response will return an error and return a message that lets you know which field is missing, and is required. In this case the verb key is missing and will produce an error message with information that the webhook.verb field is missing and is required. |
Conditionally Required Validation |
If the field is conditionally required, then it means that the field is required only if it meets a specific requirement In this case, auth_details , auth_details.username and auth_details.password fields are conditionally required if auth_type is basic |
Data Type Validation
{ "webhook": { "event_types": [ "sent" ], "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "administrator", "password": "password" }, "auth_type": "basic", "status": 123 } }
{ "status": "error", "data": "The payload for the webhook is not in the correct format. {\"webhook.status\":[\"validation.string\"]}" }
Required Validation
{ "webhook": { "event_types": [ "sent" ], "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "administrator", "password": "password" }, "auth_type": "basic", "status": "enabled" } }
{ "status": "error", "data": "The payload for the webhook is not in the correct format. {\"webhook.verb\":[\"The webhook.verb field is required.\"]}" }
Conditionally Required Validation
{ "webhook": { "event_types": [ "sent" ], "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_type": "basic", "status": "enabled" } }
{ "webhook": { "event_types": [ "sent" ], "verb": "POST", "url": "https://webhook.site/f0fc8147-0a1a-4e6b-b070-b872812d6649", "auth_details": { "username": "administrator" }, "auth_type": "basic", "status": "enabled" } }
{ "status": "error", "data": "The payload for the webhook is not in the correct format. {\"webhook.auth_details\":[\"The webhook.auth details field is required when webhook.auth type is basic.\"]}" }
{ "status": "error", "data": "The payload for the webhook is not in the correct format. {\"webhook.auth_details.password\":[\"The webhook.auth details.password field is required when webhook.auth type is basic.\"]}" }