Webhook Create
The Webhook Create method allows you to create a WebHook without using the admin panel. With webhooks, you can receive callbacks with data on almost any event that occurred with your messages.
Request
IMPORTANT: Do not send more than 10 concurrent API requests.
Body Example
{
"title": "YOUR_WEBHOOK_TITLE",
"url": "YOUR_WEBHOOK_URL",
"domainId": "YOUR_DOMAINID"
"domain": "YOUR_DOMAIN",
"events": [
"Object of Webhook Events",
]
}
Parameters
Title | Type | Default | Description |
---|---|---|---|
title required
|
string |
Title of Webhook. |
|
domainId optional
|
string |
Domain identifier for which the webhook will be created. One of the parameters (domainId or domain) is required. |
|
domain optional
|
string |
Domain for which the webhook will be created. One of the parameters (domainId or domain) is required. |
|
url required
|
string |
The URL to which all requests with data will be sent. |
|
events required
|
array |
An array of events that will trigger data requests to be sent to the specified URL. List of all events you can specify in the array:
|
Response
{
"result": true,
"config": {
"id": "YOUR_WEBHOOK_ID",
"title": "YOUR_WEBHOOK_TITLE",
"url": "YOUR_WEBHOOK_URL",
"domain": { "id": "YOUR_DOMAIN_ID", "name": "YOUR_DOMAIN_NAME" },
"events": [ "Selected WebHook Events" ]
}
}
Parameters
Title | Type | Description |
---|---|---|
result |
boolean |
Indicated that the query was successful or not:
|
config |
object |
An object of a successful webhook creation request with detailed description. |
config.id |
integer |
ID of the created webhook |
config.title |
string |
Title of the created webhook |
config.url |
string |
The URL used in the webhook to which requests will be sent. |
config.domain |
string |
An object with the data about the domain for which the webhook was created. |
config.domain.id |
string |
The domain ID for which the webhook was created. |
config.domain.name |
string |
The domain for which the webhook was created. |
config.events |
array |
An array of events specified during creation, indicating when requests with data will be sent to the provided URL. |
Method Errors
{
"result": false,
"errors": [
"Error description text"
]
}
Error |
---|
"Argument title must be a string" |
"Argument title must be a non-empty string" |
"Argument title must be a string with max length within 250 characters" |
"Argument domainId must be a non-empty string" |
"Domains limit {limit} is reached" |
"Domain {id} not found" |
"Domain {id} is not verified" |
"Domain was already verified. Please contact our support" |
"Domain has not subdomain for DNS. Please contact our support" |
"Argument domain must be a non-empty string" |
"Argument domain must be a valid domain name" |
"Domain {domain} is already registered" |
"Domain {domain} is on removing stage. Try to create it later" |
"Domain {domain} is a registered ESP" |
"Domain {domain} has unknown TLD" |
"Domains limit {limit} is reached" |
"Argument url must be a non-empty string" |
"Argument url must be a valid URI" |
"Argument url can not be longer than 2048" |
"Argument events must be an array of allowed event names" |
"Each event must be a not empty string with registered event type" |
"Event type {event} is duplicated as {double}" |
"Event type {event} is not registered" |
"Minimum one unique domain identification (domainId or domain) is required." |
"Only one domain identifier is allowed" |
"Web hook with such URL is already registered for selected domain" |
"Domain {id} not found" |
"Domain {id} is not verified" |
"Invalid authorization token!" |
"Internal server error" |
"Bad Request" |
"no matches found for access token {accessToken}" |
"user {id} not enabled" |
"no data found for key {userId}" |
"access token check failed for key/secret $key/$accessToken" |
"Argument {argument} required" |
Code Examples
$accessToken = 'YOUR_API_KEY';
$url = 'https://api.wooxy.com/v3/webhook/create';
$body = json_encode([
'title' => 'YOUR_WEBHOOK_TITLE',
'url' => 'YOUR_WEBHOOK_URL',
'domainId' => 'YOUR_DOMAIN_ID',
'domain' => 'YOUR_DOMAIN',
'events' => [
'Object of Webhook Events',
],
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Access-Token: $accessToken",
'Content-Type: application/json',
'Content-Length: ' . strlen($body),
]);
$result = curl_exec($ch);
if ($result === false) {
echo 'cURL error: ' . curl_error($ch) . PHP_EOL;
} else {
echo strval($result) . PHP_EOL;
}
curl_close($ch);