Skip to main content
A SIP trunk is the SIP endpoint an organization points its PBX or carrier at so calls reach a Lua voice agent. These routes create trunks, manage the IP allow list (ACL) and digest-authentication users that secure them, and set the default agent for a trunk. For the setup walkthrough, see Voice calls. Verified against lua-cli 3.33.0.

Base URL and authentication

Every route sits under https://api.heylua.ai/developer/orgs/:orgId/sip-trunks and takes Authorization: Bearer <<YOUR_API_KEY>>; the REST API overview covers keys, scopes, and the error envelope. Every route checks a telephony scope on the organization in the path except agent linking, which checks telephony:write on the agent and telephony:read on the organization: telephony:read lists and inspects, telephony:write creates trunks, ACL entries, and credentials and rotates passwords, and telephony:manage deletes trunks, ACL entries, credentials, and the agent link. There is no CLI equivalent for this family. A POST answers 201.

SIP trunk object

string
Trunk ID; use it in the path of the other routes.
string
SIP domain assigned to the trunk.
string
sip:*@<domain>.sip-<region>.vonage.com, the endpoint to send calls to.
string
One of us, eu, ap.
string
One of provisioning, active, failed, suspended, deleted.
string
TLS requirement: optional, always, or never.
string
SRTP requirement: optional, always, or never.
boolean
Whether digest-authentication users can be created.
string[]
Digest usernames on the trunk. Passwords are never returned here.
object[]
Allowed source addresses.
string
The agent that answers calls on this trunk, once linked.
number
Unix time in milliseconds.
string
User ID of the creator.
string
Creator email, when known.
object
What to configure on your PBX.

Endpoints

POST /developer/orgs/:orgId/sip-trunks

Provisions a trunk. Scope telephony:write. A trunk must have at least one ACL entry or digest authentication enabled; otherwise the trunk is recorded as failed and the call answers 400. Answers 201 with the SIP trunk object.
string
default:"us"
One of us, eu, ap.
string[]
Source addresses in CIDR notation; not validated locally, the carrier rejects malformed entries.
boolean
default:false
Allow digest-authentication users on this trunk.
string
default:"optional"
optional, always, or never.
string
default:"optional"
optional, always, or never.

GET /developer/orgs/:orgId/sip-trunks

Lists the organization’s trunks, failed ones included and deleted ones excluded. Scope telephony:read. Response 200 with { trunks: SipTrunk[], count }, where count is the page length.

GET /developer/orgs/:orgId/sip-trunks/:trunkId

Returns one SIP trunk object. Scope telephony:read. 404 when unknown or deleted.

DELETE /developer/orgs/:orgId/sip-trunks/:trunkId

Deletes the trunk at the carrier and marks the record deleted, so it no longer appears in list or get; its credentials and ACL entries go with it. Scope telephony:manage. Response 200 with { "success": true }.

POST /developer/orgs/:orgId/sip-trunks/:trunkId/acl

Adds an address to the allow list. Scope telephony:write. A trunk holds at most 16 ACL entries. Answers 201 with the updated SIP trunk object.
string
required
CIDR, for example 203.0.113.0/24.
string
Label for the entry.

DELETE /developer/orgs/:orgId/sip-trunks/:trunkId/acl/:ip

Removes an address from the allow list. Scope telephony:manage. URL-encode the CIDR in the path (/ becomes %2F). The last entry cannot be removed, even on a trunk with digest authentication; add its replacement first. Answers 200 with the updated object.

POST /developer/orgs/:orgId/sip-trunks/:trunkId/credentials

Creates a digest-authentication user. Scope telephony:write. Requires digestAuthEnabled; a trunk holds at most 200 users. The password, 24 letters and digits, is returned once, in this response only.
string
required
5 to 32 characters, alphanumeric and dashes, starting and ending with an alphanumeric character.
Response 201 with { username, password }.

GET /developer/orgs/:orgId/sip-trunks/:trunkId/credentials

Lists digest usernames as { users: string[] }. Scope telephony:read.

DELETE /developer/orgs/:orgId/sip-trunks/:trunkId/credentials/:username

Deletes a digest user. Scope telephony:manage. Response 200 with { "success": true }.

POST /developer/orgs/:orgId/sip-trunks/:trunkId/credentials/:username/rotate

Generates a new password for a digest user, returned once. Scope telephony:write. Response 201 with { username, password }.

POST /developer/orgs/:orgId/sip-trunks/:trunkId/agents/:agentId

Sets the agent that answers calls on the trunk. Scope telephony:write on the agent, plus telephony:read on the organization. The agent must belong to the organization, and that is checked before the trunk lookup: a foreign agent answers 403 even for an unknown trunk. The route takes no body; per-URI-user and header routing are not available through this API. Answers 201 with the updated object and defaultAgentId set.

DELETE /developer/orgs/:orgId/sip-trunks/:trunkId/agent

Removes the default agent. Scope telephony:manage. 400 when no agent is linked. Answers 200 with the updated object.

Errors

Example

Create a trunk that accepts calls from one address range, then read the endpoint to configure on the PBX.

See also