Your systems can do everything the portal’s trunk pages do. Each call and its fields are in the full reference.
Scopes
voice:readlists and reads trunks, their IP list, source restrictions and registration.voice:createcreates a trunk, adds an IP entry, and gives a trunk its first SIP credential.voice:updatechanges a trunk, rotates its password, suspends and resumes it, cancels a booked plan change, sets source restrictions and releases a spend cap hold.voice:deletedeletes a trunk and removes an IP entry.secrets:readreveals a trunk’s current SIP password.voice:readnever does.
Naming a trunk
Every trunk has an id, and most have a sipUsername. Every
/trunks/{username} call takes either one. A trunk set up without a SIP
credential authenticates only by IP, and its sipUsername is null. Address
that trunk by its id. Trunk webhooks carry the id as trunkId.
Creating a trunk
- Send
POST /trunkswith anameand adefaultCallerId. Include anIdempotency-Keyso a retry never creates two. The caller ID must be a number on your account with an emergency address, or one approved withPOST /caller-id-authorisations. - Choose the plan with
type.paygis the default and meters outbound calls.ultimatebills each channel monthly and needschannels. To bill the trunk’s calls to one of your end users, sendendUser. - The
201answer has the trunk’sid, itssipUsernameand its SIP password. The password is in this answer only, so store it. - Read the trunk with
GET /trunks/{username}untilprovisioningStateisactive, then make a test call.connectiongives what the PBX needs: the registrar, ports, codecs and DTMF mode.connection.allowListgives the addresses to let through your firewall.
To order call recording with the trunk, send recordingEnabled: true and
acknowledgeRecording: true. Without the acknowledgement you get a 422
with the code charge_acknowledgement_required. error.consent holds the
text you are agreeing to, and error.charge the monthly price.
With bundleId, the trunk joins that bundle as a draft. It is set up when the
bundle is submitted. Get its password at that point with
POST /trunks/{username}/credential/rotate.
The SIP credential
| Call | What it does |
|---|---|
GET /trunks/{username}/credential |
Reveals the current username and password, so you can set up a PBX without changing the password. It needs secrets:read. Each reveal is recorded in the trunk’s history with the key that read it. |
POST /trunks/{username}/credential/rotate |
Sets a new password and returns it once. The old password stops working at once. Send an Idempotency-Key. A retry with the same key gives the same password instead of rotating again. |
POST /trunks/{username}/credential |
Gives a trunk with no credential its first one, so it can register. The trunk has no sipUsername yet, so address it by its id. A trunk that already has a credential answers 409. Rotate it instead. |
IP list and host names
A trunk accepts registration with its credential. It also accepts calls without registering from any address on its IP list.
GET /trunks/{username}/ipslists the entries.POST /trunks/{username}/ipsadds one.DELETE /trunks/{username}/ips/{ipId}removes one.
An entry is a public IPv4 address, an IPv4 range no wider than /24, a single
IPv6 address, or a host name such as pbx.example.com. We resolve a host name
when you add it and again on its DNS TTL. It is listed with type: host. The
source address tells us which trunk a call belongs to. So we refuse an address
or host name that is already on another trunk, whether yours or another
account’s.
Source restrictions are a separate thing. They limit where the trunk’s
credential may be used from. GET /trunks/{username}/source-restrictions
reads them. PUT /trunks/{username}/source-restrictions replaces both lists,
cidrs and countries. Empty lists lift every restriction you set. An entry
we added, for example to stop fraud, stays whatever you send.
Raise a support ticket about one.
We guard against a typo locking you out. A cidrs list that leaves out the
address your request came from answers 422 naming that address, and nothing
changes. Add the address, or send confirmLockout: true if you mean it. The
check doesn’t look up countries. If your address is let in by its country,
send confirmLockout too.
Registration
GET /trunks/{username}/registration gives the live registration state. It
says whether the trunk is registered, and lists the contacts registered
against it, which are PBXs and gateways. A trunk that sends calls only from
its IP list doesn’t register, so it reads registered: false.
Changing the plan or channels, and what is charged
Change type and channels with PATCH /trunks/{username}.
| Change | When it takes effect |
|---|---|
An upgrade: payg to ultimate, or more channels on ultimate |
At once, billed from today. |
A downgrade: fewer channels, or ultimate to payg |
At the start of your next billing cycle. Until then the trunk reads its current plan, and the booked change is in pendingPlanChange. |
The answer carries a planChange block. It says which way the change went,
whether it applied at once, and its effectiveOn date. A new request
replaces a change already booked. To cancel a booked change, use
DELETE /trunks/{username}/plan-change. DELETE /account/booked-changes/{id}
cancels it too. That endpoint lists it with your other
booked changes.
On payg, channels only caps concurrent calls. It changes nothing on your
bill.
Recording is a monthly charge per trunk. Turning it on with PATCH needs
acknowledgeRecording: true, as on create. Turning it off doesn’t.
DELETE /trunks/{username} deletes a trunk once its numbers are routed
elsewhere or cancelled. A trunk still in contract has an early termination
charge. The first request answers 422 charge_acknowledgement_required,
with the charge in error.charge. Send acknowledgeEarlyTermination=true to
accept it and delete the trunk.
Suspending and resuming
POST /trunks/{username}/suspend stops a trunk’s calls at once. Use it, for
example, to stop a compromised PBX. New outbound calls are refused. Calls to
its numbers are refused before they reach the PBX, and the caller hears that
the number can’t be reached. No failover step runs and voicemail takes no
message. The line’s forwarding and Do Not Disturb are not applied. Billing is
unchanged. The trunk reads status: suspended and suspendedBy: account.
A suspended trunk still places 000, 112 and 106 calls. For an hour after one of those calls, we deliver calls to its numbers so the emergency service can call back. They ring the trunk whatever its forwarding or Do Not Disturb says.
Calls already up carry on when you suspend a trunk. To end them too, send
POST /trunks/{username}/calls/hangup with an Idempotency-Key. It hangs up
every live call on the trunk and answers 202 with how many were ended,
skipped and failed. The skipped ones are calls to 000, 112 or 106, which
are never hung up. To retry the failed ones, send it again with a new key.
POST /trunks/{username}/resume reverses a suspension. A trunk we suspended,
for example for non-payment, reads suspendedBy: checkNetworks. Resuming it
answers 409 with the reason, and it stays suspended until we lift it.
If a trunk’s defaultCallerId ports to another carrier, the trunk keeps it.
We don’t change it for you. If the trunk still presents it 48 hours after the
port completes, we suspend the trunk with suspendedBy: checkNetworks. We
email your technical and primary contacts before that happens. 000 still connects. Set
another defaultCallerId with PATCH /trunks/{username} and the suspension
lifts within a couple of minutes.
Spend caps and holds
To limit what a trunk’s outbound calls may cost in a day, set
dailySpendCapExGst with PATCH /trunks/{username}. Send it as a dollar
string. null removes the cap. The trunk reads spendTodayExGst beside it.
A call counts toward it when the call ends, so calls still up aren’t in it
yet.
When a trunk reaches its cap, spendCapHeld is true. Its new outbound calls
stop until midnight Brisbane time, given in spendCapReleasesAt. Calls
already up carry on. 000 and inbound calls are never held. To let calls
through sooner, do one of these:
- Send
POST /trunks/{username}/spend-cap/release. It keeps the same cap for the rest of the day. - Raise the cap above
spendTodayExGst.
A cap set at or below spendTodayExGst, "0.00" included, holds the trunk at
once. The PATCH answer then reads spendCapHeld: true. While the trunk is
held, each outbound call it tries is refused with
403 Outbound calling suspended. The Retry-After header gives the seconds
until spendCapReleasesAt, so the PBX learns it without polling.
A trunk can also be held at its international minutes cap, shown as
internationalHold. Its international calls are refused until we release it,
so raise a support ticket. We can also hold your
whole account’s outbound calls for unusual spend or calling patterns.
Webhooks
| Event | When it fires |
|---|---|
trunk.down |
An active trunk has neither registered nor sent an OPTIONS keepalive for 10 minutes. |
trunk.up |
The trunk is back. |
trunk.planChangeScheduled |
A plan change is booked. |
trunk.planChangeCancelled |
A plan change is cancelled. |
trunk.planChanged |
A plan change is applied. |
voice.hold.placed |
A hold starts: a spend cap hold (dailySpendCap), an international cap hold (internationalCap), or an account hold. |
voice.hold.released |
Any of those holds ends. |
bookedChange.applied, bookedChange.cancelled and bookedChange.failed
fire beside the plan change events.
Sometimes one of our own SBCs stops recording trunks. That fault is ours and
we deal with it. We send no trunk.down until the SBC records again. A trunk
that really did go down in that time gets its trunk.down once it does.
Each event’s fields are in Webhook event types.