| версия от 2023-02-13 |
Группа методов позволяет настраивать отправку вебхуков для мониторинга звонков.
В рамках данной документации каждый настроенный триггер системы мониторинга так же называется «вебхук».
Адрес: https://restapi.plusofon.ru
GET api/v1/webhooks
Метод позволяет получить список всех вебхуков системы мониторинга.
Параметры Body
"type" |
string | код типа вебхука (по умолчанию — "lk", других вариантов пока нет) |
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/webhooks" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"type":"et"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/webhooks"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"type": "et"
}
fetch(url, {
method: "GET",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/webhooks',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'type' => 'et',
],
]
);
$body = $response->getBody();
print_r(json_decode(( * *string*{.caption}*) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/webhooks'
payload = {
"type": "et"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers, json=payload)
response.json()
В ответе возвращается список вебхуков:
"data" |
array | массив вебхуков |
"id" |
integer | ИД вебхука |
"url" |
string | адрес, на который отправляется вебхук |
"type_call" |
string | код отслеживаемого направления вызова возможные варианты:
|
"type" |
string | код типа вебхука |
"event" |
string | код отслеживаемого события возможные варианты:
|
{
"current_page": 1,
"data": [
{
"id": 5,
"url": "https:\/\/test.com\/hook-in",
"type_call": "inbound",
"type": "lk",
"event": "destroy"
},
{
"id": 6,
"url": "https:\/\/test.com\/hook-out",
"type_call": "outbound",
"type": "lk",
"event": "create"
}
],
"first_page_url": "http:\/\/localhost\/api\/v1\/webhooks?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http:\/\/localhost\/api\/v1\/webhooks?page=1",
"next_page_url": null,
"path": "http:\/\/localhost\/api\/v1\/webhooks",
"per_page": 15,
"prev_page_url": null,
"to": 2,
"total": 2
}
GET api/v1/webhooks/{webhook_id}
Метод позволяет получить данные конкретного вебхука системы мониторинга.
Параметры Path
"webhook_id" |
string | ИД вебхука (см. "id" в ответе на запрос получения списка вебхуков) |
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/webhooks/42" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}"
const url = new URL(
"https://restapi.plusofon.ru/api/v1/webhooks/42"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/webhooks/42',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
]
);
$body = $response->getBody();
print_r(json_decode(( * *string*{.caption}*) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/webhooks/42'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers)
response.json()
В ответе возвращается:
"id" |
integer | ИД вебхука |
"url" |
string | адрес, на который отправляется вебхук |
"event" |
string | код отслеживаемого события возможные варианты:
|
"type_call" |
string | код отслеживаемого направления вызова возможные варианты:
|
"type" |
string | код типа вебхука |
"type_style" |
string | код стиля именования направлений вызовов возможные варианты:
|
"template" |
string | используемый шаблон |
"fields" |
array | массив переименованных стандартных полей вебхука |
"before" |
string | стандартное имя поля |
"after" |
string | новое имя поля |
"headers" |
array | массив собственных HTTP-заголовков |
"name" |
string | имя собственного HTTP-заголовка |
"value" |
string | значение собственного HTTP-заголовка |
"params" |
array | массив произвольных параметров |
"name" |
string | имя произвольного параметра |
"value" |
string | значение произвольного параметра |
{
"id": 5,
"params": [
{
"name": "my-param",
"value": "my-param value"
}
],
"url": "https:\/\/test.com\/hook",
"type_call": "inbound",
"type": "lk",
"event": "destroy",
"fields": [
{
"before": "call_id",
"after": "my_call_id"
},
{
"before": "direction",
"after": "my_direction"
}
],
"type_style": "short",
"template": null,
"headers": [
{
"name": "my-header",
"value": "my_header_value"
}
]
}
POST api/v1/webhooks
Метод позволяет создать новый вебхук системы мониторинга.
Параметры Body
"url" |
string | адрес, на который отправляется вебхук |
"event" |
string | код отслеживаемого события возможные варианты:
|
"type_call" |
string | код отслеживаемого направления вызова возможные варианты:
|
"type_style" |
string | код стиля именования направлений вызовов возможные варианты:
|
"fields" |
array | массив переименованных стандартных полей вебхука |
"before" |
string | стандартное имя поля |
"after" |
string | новое имя поля |
"headers" |
array | массив собственных HTTP-заголовков |
"name" |
string | имя собственного HTTP-заголовка |
"value" |
string | значение собственного HTTP-заголовка |
"params" |
array | массив произвольных параметров |
"name" |
string | имя произвольного параметра |
"value" |
string | значение произвольного параметра |
"template" |
string | шаблон |
curl -X POST \
"https://restapi.plusofon.ru/api/v1/webhooks" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"url":"http:\/\/my-url.com","event":"create","type_call":"all","type_style":"long","headers":[{"name":"Special-Header","value":"header_value"}],"params":[{"name":"special_parameter","value":"123"}],"fields":[{"before":"to","after":"dest_number"}],"template":"quos"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/webhooks"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"url": "http:\/\/my-url.com",
"event": "create",
"type_call": "all",
"type_style": "long",
"headers": [
{
"name": "Special-Header",
"value": "header_value"
}
],
"params": [
{
"name": "special_parameter",
"value": "123"
}
],
"fields": [
{
"before": "to",
"after": "dest_number"
}
],
"template": "quos"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->post(
'https://restapi.plusofon.ru/api/v1/webhooks',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'url' => 'http://my-url.com',
'event' => 'create',
'type_call' => 'all',
'type_style' => 'long',
'headers' => [
[
'name' => 'Special-Header',
'value' => 'header_value',
],
],
'params' => [
[
'name' => 'special_parameter',
'value' => '123',
],
],
'fields' => [
[
'before' => 'to',
'after' => 'dest_number',
],
],
'template' => 'quos',
],
]
);
$body = $response->getBody();
print_r(json_decode(( * *string*{.caption}*) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/webhooks'
payload = {
"url": "http:\/\/my-url.com",
"event": "create",
"type_call": "all",
"type_style": "long",
"headers": [
{
"name": "Special-Header",
"value": "header_value"
}
],
"params": [
{
"name": "special_parameter",
"value": "123"
}
],
"fields": [
{
"before": "to",
"after": "dest_number"
}
],
"template": "quos"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
В ответе может возвращаться:
"success" |
bool | признак успешно выполненного запроса |
"message" |
string | сообщение об ошибке |
Вебхук успешно настроен:
{
"success": true
}
PUT api/v1/webhooks/{webhook_id}
Метод позволяет изменить конкретный вебхук системы мониторинга.
Параметры Path
"webhook_id" |
string | ИД вебхука (см. "id" в ответе на запрос получения списка вебхуков) |
Параметры Body
"url" |
string | адрес, на который отправляется вебхук |
"event" |
string | код отслеживаемого события возможные варианты:
|
"type_call" |
string | код отслеживаемого направления вызова возможные варианты:
|
"type_style" |
string | код стиля именования направлений вызовов возможные варианты:
|
"fields" |
array | массив переименованных стандартных полей вебхука |
"before" |
string | стандартное имя поля |
"after" |
string | новое имя поля |
"headers" |
array | массив собственных HTTP-заголовков |
"name" |
string | имя собственного HTTP-заголовка |
"value" |
string | значение собственного HTTP-заголовка |
"params" |
array | массив произвольных параметров |
"name" |
string | имя произвольного параметра |
"value" |
string | значение произвольного параметра |
"template" |
string | шаблон |
curl -X PUT \
"https://restapi.plusofon.ru/api/v1/webhooks/42" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"url":"http:\/\/my-url.com","event":"create","type_call":"all","type_style":"long","headers":[{"name":"Special-Header","value":"header_value"}],"params":[{"name":"special_parameter","value":"123"}],"fields":[{"before":"to","after":"dest_number"}],"template":"expedita"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/webhooks/42"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"url": "http:\/\/my-url.com",
"event": "create",
"type_call": "all",
"type_style": "long",
"headers": [
{
"name": "Special-Header",
"value": "header_value"
}
],
"params": [
{
"name": "special_parameter",
"value": "123"
}
],
"fields": [
{
"before": "to",
"after": "dest_number"
}
],
"template": "expedita"
}
fetch(url, {
method: "PUT",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->put(
'https://restapi.plusofon.ru/api/v1/webhooks/42',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'url' => 'http://my-url.com',
'event' => 'create',
'type_call' => 'all',
'type_style' => 'long',
'headers' => [
[
'name' => 'Special-Header',
'value' => 'header_value',
],
],
'params' => [
[
'name' => 'special_parameter',
'value' => '123',
],
],
'fields' => [
[
'before' => 'to',
'after' => 'dest_number',
],
],
'template' => 'expedita',
],
]
);
$body = $response->getBody();
print_r(json_decode(( * *string*{.caption}*) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/webhooks/42'
payload = {
"url": "http:\/\/my-url.com",
"event": "create",
"type_call": "all",
"type_style": "long",
"headers": [
{
"name": "Special-Header",
"value": "header_value"
}
],
"params": [
{
"name": "special_parameter",
"value": "123"
}
],
"fields": [
{
"before": "to",
"after": "dest_number"
}
],
"template": "expedita"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('PUT', url, headers=headers, json=payload)
response.json()
В ответе может возвращаться:
"success" |
bool | признак успешно выполненного запроса |
"message" |
string | сообщение об ошибке |
Вебхук успешно обновлён:
{
"success": true
}
DELETE api/v1/webhooks/{webhook_id}
Метод позволяет удалить конкретный вебхук системы мониторинга.
Параметры Path
"webhook_id" |
string | ИД вебхука (см. "id" в ответе на запрос получения списка вебхуков) |
curl -X DELETE \
"https://restapi.plusofon.ru/api/v1/webhooks/42" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}"
const url = new URL(
"https://restapi.plusofon.ru/api/v1/webhooks/42"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
fetch(url, {
method: "DELETE",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->delete(
'https://restapi.plusofon.ru/api/v1/webhooks/42',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
]
);
$body = $response->getBody();
print_r(json_decode(( * *string*{.caption}*) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/webhooks/42'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('DELETE', url, headers=headers)
response.json()
В ответе может возвращаться:
"success" |
bool | признак успешно выполненного запроса |
"message" |
string | сообщение об ошибке |
Вебхук успешно удалён:
{
"success": true
}