api:pbx:events:update
Table of Contents
API : PBX : Events Update
Introduction
A PBX event is a rule that runs actions - a webhook, an SMS, a call, setting a variable or a switch, or changing the members of a queue - when something happens on the PBX. See PBX events for the triggers, the variables and the limits.
Request
This request will update an event. All properties are optional, and a property that is left out keeps its value:
- The action objects (webhook, sms, call, setVariable, setSwitch, queue) are merged into the ones the event has, so
{ webhook: { url: 'https://hooks.example.com/v2' } }changes only the URL. null removes the action, and so does an empty main property: webhook.url, sms.recipients, call.destination, setVariable.target, setSwitch.target or queue.action. - target null or empty removes the limit. For type, enabled, timers and notes, null keeps the value.
- webhook.secret left out, null or empty keeps the secret. Use Secret to have a new one generated.
- Changing type to anything but TIMER removes the timers, and the target must fit the new type - and so must a TRIGGER in the queue action.
- The queue action keeps only what its action uses: with anything but JOIN it has no priority and exclusive, and with LEAVE_ALL no queue.
- The customer of an event cannot be changed. Properties that cannot be set, such as _id, customer, createdAt and updatedAt, are ignored - so the event can be sent back as Get returned it.
The event is checked as a whole after the change, with the same rules as when it is created.
| URL | https://api.telecomx.dk/pbx/events/EVENT_ID | |||
|---|---|---|---|---|
| Method | POST | |||
| Access level | MANAGER or OWNER if user belongs to the customer. RESELLER if customer belongs to the reseller. ADMIN. |
|||
| Param | EVENT_ID | Id | Id of the event to update (24 hex-char string). | |
| Body | type | String | What triggers the event: CALL, CALL_START, CALL_RING, CALL_ANSWER, CALL_END, SWITCH, SWITCH_ON, SWITCH_OFF, QUEUE, QUEUE_MEMBER_JOIN, QUEUE_MEMBER_LEFT, CONFERENCE, HOTDESK or TIMER - see Triggers. The old names CALL_RINGING and CALL_ANSWERED are accepted and saved as CALL_RING and CALL_ANSWER. | |
| enabled | Boolean | False to keep the event without it being triggered. | ||
| target | String | What the trigger is limited to, at most 64 characters. Empty or null for no limit. Depending on type: | ||
| CALL CALL_START CALL_RING CALL_ANSWER CALL_END | A phone number or the start of one: digits with an optional leading +. Matched against the calling and the called number. | |||
| SWITCH SWITCH_ON SWITCH_OFF | Required. The exact name of the switch: letters, digits, _ and -, prefixed with SHARED: for a shared switch or <employee-id>: for a personal switch. | |||
| QUEUE QUEUE_MEMBER_JOIN QUEUE_MEMBER_LEFT | Id of a queue of the customer. | |||
| CONFERENCE | Id of a conference of the customer. | |||
| HOTDESK | Id of an extension of the customer, or the MAC address of a SIP phone written as 00:15:65:AA:BB:CC (upper or lower case). | |||
| TIMER | Not used. | |||
| timers | Array | When a TIMER event runs, at most 100 timers. Replaces all the timers of the event. Ignored for the other types. | ||
| timers[].day | Number | Weekly timer: day of the week, 0-6, 0 is Sunday. Requires time. | ||
| timers[].time | Number | Weekly timer: minutes since midnight, Danish time, 0-1439 - e.g. 480 is 08:00. Requires day. | ||
| timers[].date | Date | One-off timer: the date and time to run, as an ISO 8601 string. A timer with neither date nor both day and time is dropped. | ||
| webhook | Object | Call a URL - see Webhook. Merged into the webhook of the event, null removes it. | ||
| webhook.method | String | GET, POST or POSTJSON. A new webhook defaults to GET. | ||
| webhook.url | String | URL to call, at most 1024 characters. Must be http or https, and may not point at a private, loopback or otherwise non-public address or a Telecom X address - also not an IPv6 address that carries such an IPv4 address. May hold variables in the path and the query string, not in the host name. Empty removes the webhook. | ||
| webhook.json | String | The JSON to post, at most 8192 characters. Required when method is POSTJSON. May hold variables - put each one inside a JSON string. | ||
| webhook.secret | String | Your own secret to sign the requests with, 16-128 printable characters without spaces. Left out, null or empty keeps the secret. | ||
| sms | Object | Send an SMS - see SMS. Merged into the SMS action of the event, null removes it. | ||
| sms.message | String | The message, at most 1024 characters. May hold variables. | ||
| sms.recipients | String | Comma separated list of phone numbers in E.164 format, at most 10. Empty removes the SMS action. | ||
| sms.from | String | Sender: an E.164 number, or 1-11 letters, digits, spaces, dots, underscores or dashes. A number is sent without its + and cut to 11 digits. Null or empty for the customer's name, cut to 11 characters. | ||
| call | Object | Place a call - see Call. Merged into the call action of the event, null removes it. | ||
| call.destination | String | Number to ring. It must be an extension, a group or an external number - another destination, or an emergency number, is refused when the event runs. Digits with an optional leading +, at most 20 characters. Empty removes the call action. | ||
| call.source | String | Number the destination is connected to when a person answers, called as an internal call. Digits with an optional leading +, at most 20 characters. | ||
| call.autoAnswer | Boolean | True to make the SIP phones of the destination answer by themselves, for announcements. | ||
| setVariable | Object | Set a PBX variable. Merged into the action of the event, null removes it. | ||
| setVariable.target | String | Name of the variable, prefixed with SHARED: if shared or <employee-id>: if personal. Empty removes the action. | ||
| setVariable.value | String | Value to set, at most 1024 characters. May hold variables. | ||
| setSwitch | Object | Turn a PBX switch on or off. Merged into the action of the event, null removes it. | ||
| setSwitch.target | String | Name of the switch, prefixed with SHARED: if shared or <employee-id>: if personal. Empty removes the action. | ||
| setSwitch.value | Boolean | True to turn the switch on, false to turn it off. | ||
| queue | Object | Change the members of a queue - see Queue. Merged into the queue action of the event, null removes it. | ||
| queue.action | String | JOIN, LEAVE, LEAVE_ALL or EMPTY. Null or empty removes the queue action. | ||
| queue.queue | String | Id of a queue of the customer, or TRIGGER for the queue of what triggered the event. Required for JOIN, LEAVE and EMPTY. | ||
| queue.extension | String | Id of an extension of the customer, or TRIGGER for the extension of what triggered the event. Required for JOIN, LEAVE and LEAVE_ALL. For EMPTY, the member to keep - null or empty to keep no one. | ||
| queue.priority | Number | JOIN only: priority of the new member, 1-20. Null for 1. | ||
| queue.exclusive | Boolean | JOIN only: true to also take every other member who is not permanent out of the queue. Null keeps the value. | ||
| notes | String | Notes about the event, at most 4096 characters. | ||
Request body example - disable the event
{ enabled: false }
Request body example - change the webhook URL and remove the SMS
{ webhook: { url: 'https://hooks.example.com/pbx/v2' }, sms: null }
Request body example - make the queue JOIN exclusive, with priority 5
{ queue: { priority: 5, exclusive: true } }
Response
The updated event, in the same format as Get - including the webhook secret.
Errors
| Error code | Message | Description |
|---|---|---|
| 403 | access_denied | Insufficient access level |
| 404 | id | Event not found |
| 422 | id | Invalid ObjectId |
| 422 | type | Not one of the permitted values |
| 422 | enabled | Not a boolean |
| 422 | target | Invalid phone number or start thereof (CALL types) |
| 422 | target | Invalid switch name (SWITCH types - the target is missing or not a valid switch name) |
| 422 | target | Queue not found / Conference not found / Extension not found |
| 422 | target | MAC address or Extension not found (HOTDESK) |
| 422 | target | Longer than 64 characters |
| 422 | timers[n].day | Not a whole number 0-6 |
| 422 | timers[n].time | Not a whole number 0-1439 |
| 422 | webhook.method | Not one of the permitted values |
| 422 | webhook.url | Invalid URL |
| 422 | webhook.url | The URL must be http or https |
| 422 | webhook.url | The URL may not point at a private, loopback or Telecom X address |
| 422 | webhook.json | JSON missing (method POSTJSON) |
| 422 | webhook.secret | The secret must be 16-128 printable characters without spaces |
| 422 | sms.recipients | Invalid phone number(s) |
| 422 | sms.recipients | At most 10 recipients |
| 422 | sms.message | Message is missing |
| 422 | sms.from | The sender must be an E.164 number or 1-11 letters, digits, spaces, dots, underscores or dashes |
| 422 | call.destination | Invalid phone number |
| 422 | call.source | Invalid phone number |
| 422 | setVariable.target | Invalid variable name |
| 422 | setSwitch.target | Invalid switch name |
| 422 | setSwitch.value | On or off is missing |
| 422 | queue.action | Not one of the permitted values |
| 422 | queue.queue | Must be an id or TRIGGER |
| 422 | queue.queue | Queue is missing (JOIN, LEAVE and EMPTY) |
| 422 | queue.queue | A type event has no queue to take (TRIGGER with a type whose events have no queue) |
| 422 | queue.queue | Queue not found |
| 422 | queue.extension | Must be an id or TRIGGER |
| 422 | queue.extension | Extension is missing (JOIN, LEAVE and LEAVE_ALL) |
| 422 | queue.extension | A type event has no extension to take (TRIGGER with a type whose events have no extension) |
| 422 | queue.extension | Extension not found |
| 422 | queue.priority | Not a whole number 1-20 |
| 422 | queue.exclusive | Not a boolean |
| 500 | internal_error | <Unspecified> |
api/pbx/events/update.txt · Last modified: by Telecom X AI
