WebHooks

Поддерживаемые в текущий момент webhooks, связанные со звонками:

· CHANNEL_CREATE (новый звонок)

· CHANNEL_ANSWER (абонент поднял трубку)

· CHANNEL_DESTROY (звонок завершен)

REST API

/v1/kazoos/accounts/{account_id}/webhooks

Операции

Тип запроса

Входящие

Исходящие

Описание

GET

ALL

Получить список текущих webhooks

PUT

ANY

ALL

Создать новый webhook

Коды ответов

Успешные коды ответов: 200, 201

Коды ошибок: 400, 401, 404, 415, 500, 503, 504

Примеры

Получить список webhooks

curl -X GET -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks

Cоздать новый webhook

curl -X PUT -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks -d '{"data":{"name":"New Calls", "uri":"http://my.server.com/calls/new.php", "http_verb":"post", "hook":"channel_create", "retries":1}}'
/v1/kazoos/accounts /{account_id}/webhooks/{webhook_id}

Операции

Тип запроса

Входящие

Исходящие

Описание

GET

ALL

Получить webhook с указанным ID

POST

ANY

ALL

Изменить webhook с указанным ID

DELETE

ALL

Удалить webhook с указанным ID

Коды ответов

Успешные коды ответов: 200, 201

Коды ошибок: 400, 401, 404, 415, 500, 503, 504

Примеры

Получить нужный webhook

curl -X GET -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks/{webhook_id}

Изменить webhook с указанным ID

curl -X POST -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks{webhook_id} -d '{"data":{"name":"New Calls", "uri":"http://my.server.com/calls/new_call.php", "http_verb":"post", "hook":"channel_create", "retries":1}}'

Удалить webhook с указанным ID

curl -X DELETE -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks/{webhook_id}
/v1/kazoos/accounts/{account_id}/webhooks/attempts

Операции

Тип запроса

Входящие

Исходящие

Описание

GET

ALL

Получить список последних обращений к webhooks (может быть полезно при отладке)

Коды ответов

Успешные коды ответов: 200

Коды ошибок: 400, 401, 404, 415, 500, 503, 504

Примеры

Получить список обращений к webhooks

curl -X GET -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks/attempts
/v1/kazoos/accounts/{account_id}/webhooks/{webhook_id}/attempts

Операции

Тип запроса

Входящие

Исходящие

Описание

GET

ALL

Получить список последних обращений к webhook c указанным ID

Коды ответов

Успешные коды ответов: 200

Коды ошибок: 400, 401, 404, 415, 500, 503, 504

Примеры

Получить список обращений к webhooks

curl -X GET -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks/{webhook_id}/attempts

В случае необходимости помещения дополнительных (статических) данных в событие, вы должны будете добавить объект “custom_data” в webhook.

Схема работы Виртуальной АТС с плечами звонков:

Пример

сurl -X PUT -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks -d '{"data":{"name":"New Calls", "uri":"http://my.server.com/calls/new.php", "http_verb":"post", "hook":"channel_create", "retries":1, "custom_data": {"account_id": "my_crm_account_id", "screen_pop": true}}}'

После выполнения запроса на создание channel create

сurl -X PUT -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks -d '{"data":{"name":"New Calls", "uri":"http://my.server.com/calls/new.php", "http_verb":"post", "hook":"channel_create", "retries":1}}'

Вы создадите следующее события:

{
  "name": "CHANNEL_CREATE",
  "args": {
    "Answer-State": "ringing",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "From-Tag": "2630308320-3859921251-67134891-83276323",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "74957410037@213.145.43.44",
    "Request": "74953699014@213.145.53.135",
    "From": "74957410037@213.145.43.44",
    "To": "74953699014@213.145.53.135",
    "From-Uri": "74957410037@213.145.43.44:5061",
    "To-Uri": "74953699014@213.145.53.135",
    "Disposition": "DELAYED NEGOTIATION",
    "Call-Direction": "inbound",
    "Timestamp": 63638575004,
    "Custom-Channel-Vars": {
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb"
    },
    "Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Node": "ecallmgr@logic2.vpbx.local",
    "Msg-ID": "1471355804008200",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_CREATE",
    "Event-Category": "call_event"
  }
}
{
  "name": "CHANNEL_CREATE",
  "args": {
    "Answer-State": "ringing",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "From-Tag": "2630308320-3859921251-67134891-83276323",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "74957410037@213.145.43.44",
    "Request": "74953699014@213.145.53.135",
    "From": "74957410037@213.145.43.44",
    "To": "74953699014@213.145.53.135",
    "From-Uri": "74957410037@213.145.43.44:5061",
    "To-Uri": "74953699014@213.145.53.135",
    "Disposition": "DELAYED NEGOTIATION",
    "Call-Direction": "inbound",
    "Timestamp": 63638575004,
    "Custom-Channel-Vars": {
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb"
    },
    "Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Node": "ecallmgr@logic1.vpbx.local",
    "Msg-ID": "1471355804008200",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_CREATE",
    "Event-Category": "call_event"
  }
}
{
  "name": "CHANNEL_CREATE",
  "args": {
    "Answer-State": "ringing",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "From-Tag": "2630308320-3859921251-67134891-83276323",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "74957410037@213.145.43.44",
    "Request": "74953699014@213.145.53.135",
    "From": "74957410037@213.145.43.44",
    "To": "74953699014@213.145.53.135",
    "From-Uri": "74957410037@213.145.43.44:5061",
    "To-Uri": "74953699014@213.145.53.135",
    "Disposition": "DELAYED NEGOTIATION",
    "Call-Direction": "inbound",
    "Timestamp": 63638575004,
    "Custom-Channel-Vars": {
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb"
    },
    "Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Node": "ecallmgr@logic3.vpbx.local",
    "Msg-ID": "1471355804008200",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_CREATE",
    "Event-Category": "call_event"
  }
}
{
  "name": "CHANNEL_CREATE",
  "args": {
    "Answer-State": "ringing",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Callee-ID-Name": "ALEKSANDR",
    "Callee-ID-Number": "4953699014",
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "manager2@10222.ztpbx.ru",
    "Request": "manager2@10222.ztpbx.ru",
    "From": "74957410037@213.145.43.44:5061",
    "To": "manager2@10222.ztpbx.ru",
    "Other-Leg-Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Other-Leg-Destination-Number": "74953699014",
    "Other-Leg-Caller-ID-Number": "74957410037",
    "Other-Leg-Caller-ID-Name": "74957410037",
    "Other-Leg-Direction": "inbound",
    "Call-Direction": "outbound",
    "Timestamp": 63638575004,
    "Custom-Channel-Vars": {
      "Username": "manager2",
      "Realm": "10222.ztpbx.ru",
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Owner-ID": "a9b3d008bdeead4a7acc6eb1eef57629",
      "Authorizing-ID": "a927e4b8c00136011fd86fb72d2bab48",
      "Inception": "74953699014@213.145.53.135",
      "Ecallmgr-Node": "ecallmgr@logic3.vpbx.local",
      "Bridge-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44"
    },
    "Call-ID": "b569f62a-c7c0-4e56-874d-566a311e7b3b",
    "Node": "ecallmgr@logic3.vpbx.local",
    "Msg-ID": "1471355804628201",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_CREATE",
    "Event-Category": "call_event"
  }
}

После выполнения запроса на создание channel answer

сurl -X PUT -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks -d '{"data":{"name":"New Calls", "uri":"http://my.server.com/calls/new.php", "http_verb":"post", "hook":"channel_answer", "retries":1}}'

Вы создадите следующее события:

{
  "name": "CHANNEL_ANSWER",
  "args": {
    "Answer-State": "answered",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "To-Tag": "354c4108",
    "From-Tag": "XZ1tcZ909tg1B",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Callee-ID-Name": "ALEKSANDR",
    "Callee-ID-Number": "4953699014",
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "manager2@10222.ztpbx.ru",
    "Request": "manager2@10222.ztpbx.ru",
    "From": "74957410037@213.145.43.44:5061",
    "To": "manager2@10222.ztpbx.ru",
    "From-Uri": "74957410037@213.145.53.135",
    "To-Uri": "manager2@213.145.43.66:30148",
    "Other-Leg-Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Other-Leg-Destination-Number": "74953699014",
    "Other-Leg-Caller-ID-Number": "74957410037",
    "Other-Leg-Caller-ID-Name": "74957410037",
    "Other-Leg-Direction": "inbound",
    "Call-Direction": "outbound",
    "Timestamp": 63638575007,
    "Custom-Channel-Vars": {
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Channel-Authorized": "true",
      "Username": "manager2",
      "Realm": "10222.ztpbx.ru",
      "Owner-ID": "a9b3d008bdeead4a7acc6eb1eef57629",
      "Authorizing-ID": "a927e4b8c00136011fd86fb72d2bab48",
      "Inception": "74953699014@213.145.53.135",
      "Ecallmgr-Node": "ecallmgr@logic3.vpbx.local",
      "Bridge-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44"
    },
    "Call-ID": "b569f62a-c7c0-4e56-874d-566a311e7b3b",
    "Node": "ecallmgr@logic3.vpbx.local",
    "Msg-ID": "1471355807848204",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_ANSWER",
    "Event-Category": "call_event"
  }
}
{
  "name": "CHANNEL_ANSWER",
  "args": {
    "Answer-State": "answered",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "To-Tag": "SUvQ5j6jNQQpD",
    "From-Tag": "2630308320-3859921251-67134891-83276323",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Callee-ID-Name": "ALEKSANDR",
    "Callee-ID-Number": "4953699014",
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "74957410037@213.145.43.44",
    "Request": "74953699014@213.145.53.135",
    "From": "74957410037@213.145.43.44",
    "To": "74953699014@213.145.53.135",
    "From-Uri": "74957410037@213.145.43.44:5061",
    "To-Uri": "74953699014@213.145.53.135",
    "Disposition": "failure",
    "Call-Direction": "inbound",
    "Timestamp": 63638575007,
    "Custom-Channel-Vars": {
      "Inception": "74953699014@213.145.53.135",
      "Authorizing-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Originator-Type": "PSTN",
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Fetch-ID": "95eb5099-fa56-42f7-b051-8ad7117d41c4",
      "Channel-Authorized": "true",
      "Reseller-Billing": "limits_disabled",
      "Reseller-ID": "368a97f7ebc974687d6aa7364a0ecce3",
      "Account-Billing": "limits_disabled",
      "Global-Resource": "false",
      "Ecallmgr-Node": "ecallmgr@logic3.vpbx.local",
      "Bridge-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44"
    },
    "Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Node": "ecallmgr@logic3.vpbx.local",
    "Msg-ID": "12471355807868203",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_ANSWER",
    "Event-Category": "call_event"
  }
}

После выполнения запроса на создание channel destroy

сurl -X PUT -H "X-Auth-Token: f0d3d3280f3ab5494c529570c0a6fe28" -H "Content-Type: application/json" https://api.zebratelecom.ru/v1/kazoos/accounts/{account_id}/webhooks -d '{"data":{"name":"New Calls", "uri":"http://my.server.com/calls/new.php", "http_verb":"post", "hook":"channel_destroy", "retries":1}}'

Вы создадите следующее события:

{
  "name": "CHANNEL_DESTROY",
  "args": {
    "Answer-State": "hangup",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "To-Tag": "354c4108",
    "From-Tag": "XZ1tcZ909tg1B",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Callee-ID-Name": "ALEKSANDR",
    "Callee-ID-Number": "4953699014",
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "manager2@10222.ztpbx.ru",
    "Request": "manager2@10222.ztpbx.ru",
    "From": "74957410037@213.145.43.44:5061",
    "To": "manager2@10222.ztpbx.ru",
    "From-Uri": "74957410037@213.145.53.135",
    "To-Uri": "manager2@213.145.43.66:30148",
    "Ringing-Seconds": "0",
    "Billing-Seconds": "4",
    "Duration-Seconds": "7",
    "Remote-SDP": "v=0\r\no=- 7 2 IN IP4 213.145.43.66\r\ns=CounterPath eyeBeam 1.5\r\nc=IN IP4 213.145.43.66\r\nt=0 0\r\nm=audio 57790 RTP/AVP 8 101\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=oldmediaip:10.100.0.64\r\na=oldmediaip:10.100.0.64\r\n",
    "User-Agent": "eyeBeam release 1102u stamp 52345",
    "Hangup-Code": "sip:200",
    "Hangup-Cause": "NORMAL_CLEARING",
    "Disposition": "ANSWER",
    "Other-Leg-Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Other-Leg-Destination-Number": "74953699014",
    "Other-Leg-Caller-ID-Number": "74957410037",
    "Other-Leg-Caller-ID-Name": "74957410037",
    "Other-Leg-Direction": "inbound",
    "Call-Direction": "outbound",
    "Timestamp": 63638575011,
    "Custom-Channel-Vars": {
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Channel-Authorized": "true",
      "Username": "manager2",
      "Realm": "10222.ztpbx.ru",
      "Owner-ID": "a9b3d008bdeead4a7acc6eb1eef57629",
      "Authorizing-ID": "a927e4b8c00136011fd86fb72d2bab48",
      "Inception": "74953699014@213.145.53.135",
      "Ecallmgr-Node": "ecallmgr@logic3.vpbx.local",
      "Bridge-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44"
    },
    "Call-ID": "b569f62a-c7c0-4e56-874d-566a311e7b3b",
    "Node": "ecallmgr@logic3.vpbx.local",
    "Msg-ID": "1471355811908194",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_DESTROY",
    "Event-Category": "call_event"
  }
}
{
  "name": "CHANNEL_DESTROY",
  "args": {
    "Answer-State": "hangup",
    "Switch-URI": "sip:213.145.53.152:11000",
    "Switch-URL": "sip:mod_sofia@213.145.53.152:11000",
    "To-Tag": "SUvQ5j6jNQQpD",
    "From-Tag": "2630308320-3859921251-67134891-83276323",
    "Custom-SIP-Headers": {
      "X-AUTH-IP": "213.145.43.44"
    },
    "Callee-ID-Name": "ALEKSANDR",
    "Callee-ID-Number": "4953699014",
    "Caller-ID-Name": "74957410037",
    "Caller-ID-Number": "74957410037",
    "Media-Server": "fs5.vpbx.ztel.ru",
    "Presence-ID": "74957410037@213.145.43.44",
    "Request": "74953699014@213.145.53.135",
    "From": "74957410037@213.145.43.44",
    "To": "74953699014@213.145.53.135",
    "From-Uri": "74957410037@213.145.43.44:5061",
    "To-Uri": "74953699014@213.145.53.135",
    "Ringing-Seconds": "0",
    "Billing-Seconds": "4",
    "Duration-Seconds": "7",
    "Remote-SDP": "v=0\r\no=- 1471355804 1471355804 IN IP4 213.145.43.44\r\ns=-\r\nc=IN IP4 213.145.43.44\r\nt=0 0\r\nm=audio 28146 RTP/AVP 8 101\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=silenceSupp:off - - - -\r\n",
    "User-Agent": "MERA MVTS3G v.4.4.0-20",
    "Hangup-Code": "sip:200",
    "Hangup-Cause": "NORMAL_CLEARING",
    "Disposition": "SUCCESS",
    "Other-Leg-Call-ID": "b569f62a-c7c0-4e56-874d-566a311e7b3b",
    "Other-Leg-Destination-Number": "manager2",
    "Other-Leg-Caller-ID-Number": "74957410037",
    "Other-Leg-Caller-ID-Name": "74957410037",
    "Other-Leg-Direction": "outbound",
    "Call-Direction": "inbound",
    "Timestamp": 63638575011,
    "Custom-Channel-Vars": {
      "Inception": "74953699014@213.145.53.135",
      "Authorizing-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Originator-Type": "PSTN",
      "Account-ID": "39260d3b2ee89bdfdc9d2e05a05159bb",
      "Fetch-ID": "95eb5099-fa56-42f7-b051-8ad7117d41c4",
      "Channel-Authorized": "true",
      "Reseller-Billing": "limits_disabled",
      "Reseller-ID": "368a97f7ebc974687d6aa7364a0ecce3",
      "Account-Billing": "limits_disabled",
      "Global-Resource": "false",
      "Ecallmgr-Node": "ecallmgr@logic3.vpbx.local",
      "Bridge-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44"
    },
    "Call-ID": "e051c7f663b911e6ab65000423b2f604@213.145.43.44",
    "Node": "ecallmgr@logic3.vpbx.local",
    "Msg-ID": "1471355811908194",
    "App-Version": "0.8.0",
    "App-Name": "ecallmgr",
    "Event-Name": "CHANNEL_DESTROY",
    "Event-Category": "call_event"
  }
}