Skip to main content

Dial

The Dial endpoint originates a call between a source extension and a destination number. It is the OpenAPI equivalent of proxyapi.php?reqtype=DIAL and uses the same PBX dialplan contexts.

The endpoint requires a tenant context and a full API key. Read-only API keys cannot originate calls.

Endpoint

POST https://pbx.example.com/pbx/openapi.php/dial?tenant=CANISTRACCI
ParameterRequiredDescription
tenantYesTenant code or tenant name.
keyNo, if using headersFull API key. The key can also be sent with X-API-Key or Authorization: Bearer.

Request Body

FieldRequiredDescription
sourceYesSource extension. Compatibility aliases are exten and ?exten.
destYesDestination number. Compatibility alias is phone.
dialtimeoutNoOriginate timeout in seconds. Defaults to 30.
timeoutNoSets the dialplan variable SETTIMEOUT.
sourceclidNoSets SETSOURCECLID.
destclidNoSets SETDESTCLID.
logqueueoutboundNoSets SETLOGQUEUEOUTBOUND.
recordingNoSets SETRECORDING.
autoanswerNoSets AUTOANSWER.
nofollowNoSets SETNOFOLLOWEXTENSION.
accountNoPeer account name to set as SETPEERNAME. Use SOURCE to resolve it from the source extension.
serverNoPBX node peer name to use when the source or destination registration server cannot be found.
varNoComma-separated custom variables, for example campaign=summer,lead=42.
varsNoCustom variables as a JSON object. Variables are tenant-prefixed and listed in VARLIST.

Example

curl -X POST "https://pbx.example.com/pbx/openapi.php/dial?tenant=CANISTRACCI" \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source": "100",
    "dest": "39055123456",
    "dialtimeout": 30,
    "sourceclid": "100",
    "recording": "yes",
    "vars": {
      "campaign": "summer",
      "lead": "42"
    }
  }'

Response

The response includes the Asterisk manager originate result, the generated originate ID, and the selected PBX node.

{
  "Response": "Success",
  "Message": "Originate successfully queued",
  "ID": "6867c1c5.12345678",
  "source": "100",
  "dest": "39055123456",
  "server": "pbx-node-1",
  "node": "PBX Node 1"
}

Extension Dial API Key

Besides a tenant or global full API key, POST /dial accepts a Dial API Key configured on a SIP/PJSIP, Custom or Virtual extension. Enter a strong unique value in the extension's Dial API Key field and save the extension. The tenant and extension are inferred from the key, so tenant can be omitted. The key can originate calls and read the caller ID choices of its own tenant with GET /outbounddids; it cannot access any other object. Read-only API keys cannot originate calls.

One call leg is always the extension associated with the key, and the tenant and peer account are derived from that extension. A Dial API Key therefore cannot connect two unrelated numbers or select another extension's account. Use a different key on each extension: authentication is rejected as ambiguous if several extensions match the key.

FieldDescription
externalExternal number to call. Aliases: dest, phone, destination and number.
dialfirstextension (default) dials the key's extension first and then the external number; external dials the external number first. Aliases: dial_order and order.

Existing integrations can still send both source and dest; their order is honored when exactly one of them is the key's extension.

curl -X POST \
  -H "X-API-Key: EXTENSION_DIAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"external":"15551234567","dialfirst":"extension"}' \
  "https://pbx.example.com/pbx/openapi.php/dial"

Outbound Caller IDs

GET /outbounddids lists the caller IDs a click-to-call client can offer. Full and read-only keys must supply one exact tenant code or name; a global key receives 409 ambiguous_tenant when the value matches several tenants. An extension Dial API Key uses its own tenant when tenant is omitted.

curl -H "X-API-Key: TENANT_READONLY_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/outbounddids?tenant=CANISTRACCI"

[
  {"number":"+12025550123","description":"Reception","can_receive_sms":true},
  {"number":"0012345","description":"Sales","can_receive_sms":false}
]

Tenant DIDs follow the GUI caller ID format settings; verified outbound DIDs appear as entered. Each distinct number is returned once, including leading zeros or plus sign. A tenant without choices returns an empty array.

can_receive_sms is true when a DID of the tenant with inbound SMS configured matches the number, using the PBX prefixes. Spaces and hyphens are significant. The outbound DID option Allow SMS permits the number as an SMS sender and does not establish inbound capability.

Compatibility Notes

  • source=ACCOUNT resolves the source extension number from the account peer name.
  • account=SOURCE resolves the peer name from the source extension and sets SETPEERNAME.
  • If a source or destination registration server is found, that node is used. If no registration server is found, pass server with the node peer name.
  • The endpoint returns JSON only.