You can test API methods on the interactive API browser page and without writing code
Some of the resources described on the page may not be available by default due to the type of application (see Creating and authorizing applications).
Description of Data Structures
Event
Expand | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||
|
Event Data
Expand | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If the request method is GET, the data will be in the request header; but if the request method is POST, the data will be in the request body. In both cases, the data is in the format application/x-www-form-urlencoded.
|
Generation Features
Voice menu (IVR): when a call comes in, a dial-in event is generated, when a call is released, a hangup event is generated (thus, there are no events dial-out and answer).
The queue works with two threads:
Thread | Description |
---|---|
in | When a call is put in the queue this option has the value dial-in, when the connection ends this option has the value hangup (there is no answer event) |
out | When calling each of the queue agents this option has the value dial-in; if the call was answered this option has the value answer; when the connection ends this option has the value hangup |
If the call is forwarded to a number outside the PBX using incoming call rules (the extension number type does not matter), then a dial-out event is generated from this extension number to the corresponding number with the option Transfered: "yes".
Let's say the following call initiation (callback) is used:
|
---|
If at the same time the internal number “200” is the owner of the call and makes a call to itself, then for optimization there will be no call events for the internal number itself. For example, connecting the extension number "200" with the number "+79817654321" on behalf of the extension number "200" initiates the "dial-out" from "200" to "+79817654321" (there will be no "dial-in" from "200" to " 200 "and" dial-out "from" 200 "to" 200 ").
Info |
---|
Events message-in и message-out available only for internal numbers of the “phone” type |
Example
For extension number 000*099 with ID 175 and call recording enabled, let’s add events 'dial-out', 'answer', 'hangup'. The options "?myid=175" are added to all URLs to make it clear on the side https://somehost.com/ who owns the event if the events are generated from different extension numbers.
Tabs |
---|
[{"content":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"In the "},{"type":"text","text":"authentication ","marks":[{"type":"strong"}]},{"type":"text","text":"section enter the "},{"type":"text","text":"Application_ID","marks":[{"type":"strong"}]},{"type":"text","text":" and "},{"type":"text","text":"Application_Secret","marks":[{"type":"strong"}]},{"type":"text","text":" values obtained during the application registration in the "},{"type":"text","text":"client_id ","marks":[{"type":"strong"}]},{"type":"text","text":"and "},{"type":"text","text":"client_secret","marks":[{"type":"strong"}]},{"type":"text","text":" fields, then click on the \""},{"type":"text","text":"Try it out!","marks":[{"type":"strong"}]},{"type":"text","text":"\" button. If the application data is correct, an access token ("},{"type":"text","text":"access_token","marks":[{"type":"strong"}]},{"type":"text","text":") will be returned in response. The received access token should be entered into the \""},{"type":"text","text":"Access Token Field","marks":[{"type":"strong"}]},{"type":"text","text":"\" at the top of the page and saved by clicking the \""},{"type":"text","text":"Set Token","marks":[{"type":"strong"}]},{"type":"text","text":"\" button."}]},{"type":"table","attrs":{"isNumberColumnEnabled":false,"layout":"default"},"content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Method","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Resource","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Data","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"POST"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"/extension/175/event/"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"{"},{"type":"hardBreak"},{"type":"text","text":"\"url\": \""},{"type":"text","text":"https://somehost.com/fordel/show.php?myid=175","marks":[{"type":"link","attrs":{"href":"https://somehost.com/fordel/show.php?myid=175"}}]},{"type":"text","text":"\","},{"type":"hardBreak"},{"type":"text","text":"\"method\": \"GET\","},{"type":"hardBreak"},{"type":"text","text":"\"event_type\": \"dial-out\""},{"type":"hardBreak"},{"type":"text","text":"}"}]}]}]}]},{"type":"paragraph","content":[]}]},"id":"be851b15-6460-4049-a125-d6c576a4db46","label":"Interactive API Browser","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"To send requests using the cURL program, set the values of the "},{"type":"text","text":"url ","marks":[{"type":"strong"}]},{"type":"text","text":"and "},{"type":"text","text":"access_token","marks":[{"type":"strong"}]},{"type":"text","text":" variables:"}]},{"type":"paragraph","content":[{"type":"text","text":"export url=\"https://<hostname>/api/ver1.0\"","marks":[{"type":"code"}]},{"type":"text","text":" "},{"type":"hardBreak"},{"type":"text","text":"(where the hostname — is the hostname of the API-server provider of IP-telephony),"}]},{"type":"paragraph","content":[{"type":"text","text":"export access_token=\"8SNsrS0jV35vfmKqKeKtRrHfpbg4UX\"","marks":[{"type":"code"}]},{"type":"text","text":" "},{"type":"hardBreak"},{"type":"text","text":"(the received access token)."}]},{"type":"paragraph","content":[{"type":"text","text":"Send a request:"}]},{"type":"codeBlock","attrs":{"language":"shell"},"content":[{"type":"text","text":"curl \\\n-H \"Authorization: Bearer ${access_token}\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"url\": \"https://somehost.com/fordel/show.php?myid=175\",\n \"method\": \"GET\",\n \"event_type\": \"dial-out\"\n}' \\\n-X POST ${url}/extension/175/event/"}]}]},"id":"737a8c55-9ae5-4b82-8f47-dc6439feb333","label":"cURL Program","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"To send requests in Python, set the values of the variables URL and ACCESS_TOKEN:"}]},{"type":"paragraph","content":[{"type":"text","text":"URL = \"https://<hostname>/api/ver1.0\"","marks":[{"type":"code"}]},{"type":"hardBreak"},{"type":"text","text":"(where the hostname — is the hostname of the API-server provider of IP-telephony),"}]},{"type":"paragraph","content":[{"type":"text","text":"ACCESS_TOKEN = \"8SNsrS0jV35vfmKqKeKtRrHfpbg4UX\"","marks":[{"type":"code"}]},{"type":"hardBreak"},{"type":"text","text":"(the received access token)."}]},{"type":"codeBlock","attrs":{"language":"python"},"content":[{"type":"text","text":"#!/usr/bin/python\n\nimport requests\n\nurl = f'{URL}/extension/175/event/'\nheaders = {\n 'Authorization': f'Bearer {ACCESS_TOKEN}',\n 'Content-Type': 'application/json'\n}\ndata = '''{\n \"url\": \"https://somehost.com/fordel/show.php?myid=175\",\n \"method\": \"GET\",\n \"event_type\": \"dial-out\"\n }'''\nresponse = requests.post(url, headers=headers, data=data)\nprint(response.text)"}]}]},"id":"3e376471-cfcb-4425-b1d0-7e05153ce340","label":"In Python3","type":"tab"}] |
System response:
Code Block | ||
---|---|---|
| ||
{ "url": "https://somehost.com/fordel/show.php?myid=175", "method": "GET", "event_type": "dial-out", "id": 72 } |
Tabs |
---|
[{"content":{"version":1,"type":"doc","content":[{"type":"table","attrs":{"isNumberColumnEnabled":false,"layout":"default"},"content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Method","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Resource","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Data","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"POST"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"/extension/175/event/"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"{"},{"type":"hardBreak"},{"type":"text","text":"\"url\": \""},{"type":"text","text":"https://somehost.com/fordel/show.php?myid=175","marks":[{"type":"link","attrs":{"href":"https://somehost.com/fordel/show.php?myid=175"}}]},{"type":"text","text":"\","},{"type":"hardBreak"},{"type":"text","text":"\"method\": \"GET\","},{"type":"hardBreak"},{"type":"text","text":"\"event_type\": \"answer\""},{"type":"hardBreak"},{"type":"text","text":"}"}]}]}]}]},{"type":"paragraph","content":[]}]},"id":"2ca15d35-6928-4223-a7b0-3478d2193286","label":"Interactive API Browser","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"codeBlock","attrs":{"language":"python"},"content":[{"type":"text","text":"curl \\\n-H \"Authorization: Bearer ${access_token}\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"url\": \"https://somehost.com/fordel/show.php?myid=175\",\n \"method\": \"GET\",\n \"event_type\": \"answer\"\n}' \\\n-X POST ${url}/extension/175/event/"}]}]},"id":"a8e45825-7983-4d88-aaf2-1c221ea0fef2","label":"cURL Program","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"codeBlock","attrs":{"language":"python"},"content":[{"type":"text","text":"#!/usr/bin/python\n\nimport requests\n\nurl = f'{URL}/extension/175/event/'\nheaders = {\n 'Authorization': f'Bearer {ACCESS_TOKEN}',\n 'Content-Type': 'application/json'\n}\ndata = '''{\n \"url\": \"https://somehost.com/fordel/show.php?myid=175\",\n \"method\": \"GET\",\n \"event_type\": \"answer\"\n }'''\nresponse = requests.post(url, headers=headers, data=data)\nprint(response.text)"}]}]},"id":"88fe62c9-06a6-4dc3-b5e4-92797f158516","label":"In Python3","type":"tab"}] |
System response:
Code Block | ||
---|---|---|
| ||
{ "url": "https://somehost.com/fordel/show.php?myid=175", "method": "GET", "event_type": "answer", "id": 73 } |
Tabs |
---|
[{"content":{"version":1,"type":"doc","content":[{"type":"table","attrs":{"isNumberColumnEnabled":false,"layout":"default"},"content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Method","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Resource","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Data","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"POST"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"/extension/175/event/"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"{"},{"type":"hardBreak"},{"type":"text","text":"\"url\": \""},{"type":"text","text":"https://somehost.com/fordel/show.php?myid=175","marks":[{"type":"link","attrs":{"href":"https://somehost.com/fordel/show.php?myid=175"}}]},{"type":"text","text":"\","},{"type":"hardBreak"},{"type":"text","text":"\"method\": \"GET\","},{"type":"hardBreak"},{"type":"text","text":"\"event_type\": \"hangup\""},{"type":"hardBreak"},{"type":"text","text":"}"}]}]}]}]},{"type":"paragraph","content":[]}]},"id":"6e115913-2cd8-485a-ad8d-d105229831a1","label":"Interactive API Browser","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"codeBlock","attrs":{"language":"shell"},"content":[{"type":"text","text":"curl \\\n-H \"Authorization: Bearer ${access_token}\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"url\": \"https://somehost.com/fordel/show.php?myid=175\",\n \"method\": \"GET\",\n \"event_type\": \"hangup\"\n}' \\\n-X POST ${url}/extension/175/event/"}]}]},"id":"578cbcce-4df4-4af4-8a7a-34ef92b3bb38","label":"cURL Program","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"codeBlock","attrs":{"language":"python"},"content":[{"type":"text","text":"#!/usr/bin/python\n\nimport requests\n\nurl = f'{URL}/extension/175/event/'\nheaders = {\n 'Authorization': f'Bearer {ACCESS_TOKEN}',\n 'Content-Type': 'application/json'\n}\ndata = '''{\n \"url\": \"https://somehost.com/fordel/show.php?myid=175\",\n \"method\": \"GET\",\n \"event_type\": \"hangup\"\n }'''\nresponse = requests.post(url, headers=headers, data=data)\nprint(response.text)"}]}]},"id":"93199f00-50d0-449b-8392-f9e772c4a9f6","label":"In Python3","type":"tab"}] |
System response:
Code Block | ||
---|---|---|
| ||
{ "url": "https://somehost.com/fordel/show.php?myid=175", "method": "GET", "event_type": "hangup", "id": 74 } |
If the script show.php on the side somehost.com looks like:
|
then, after a call from the extension number 000*099 to the number 00010005, you may see in the web server log file the records of the form:
Expand | ||
---|---|---|
| ||
|
"Extension Number” Section Resources
Expand | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||
POST /extension/{extension_id}/event/ Add the extension number event URL Options
JSON Options
Response Fields
|
Expand | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
GET /extension/{extension_id}/event/ Get the extension number event list URL Options
Response Fields
|
Expand | ||||
---|---|---|---|---|
| ||||
DELETE /extension/{extension_id}/event/ Delete all events of the extension number URL Options
|
Expand | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||
PUT /extension/{extension_id}/event/{id} Update the extension number event URL Options
JSON Options
Response Fields
|
Expand | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
GET /extension/{extension_id}/event/{id} Get the extension number event URL Options
Response Fields
|
Expand | ||||||
---|---|---|---|---|---|---|
| ||||||
DELETE /extension/{extension_id}/event/{id} Delete the extension number event URL Options
|