Everything the portal’s trunk pages do, your own systems can do through the API. The full reference lists every call and its fields. This page covers how they fit together.
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 has a null sipUsername, so address
it by its id. Trunk webhooks carry the id as trunkId.
Creating a trunk
- Send
POST /trunkswith anameand adefaultCallerId, with 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.payg, the default, meters outbound calls.ultimatebills each channel monthly and needschannels. SendendUserto bill the trunk’s calls to one of your end users. - 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, andconnection.allowListthe addresses to let through your firewall.
To order call recording with the trunk, send recordingEnabled: true and
acknowledgeRecording: true. Without the acknowledgement the answer is a
422 with the code charge_acknowledgement_required, the text you are
agreeing to in error.consent and the monthly price in error.charge.
With bundleId, the trunk joins that bundle as a draft and is set up when
the bundle is submitted. Take its password then with
POST /trunks/{username}/credential/rotate.
The SIP credential
GET /trunks/{username}/credentialreveals the current username and password, to set up a PBX without changing the password. It needssecrets:read, and each reveal is recorded in the trunk’s history with the key that read it.POST /trunks/{username}/credential/rotatesets a new password and returns it once. The old password stops working at once. Send anIdempotency-Key: a retry with the same key gives the same password instead of rotating again.POST /trunks/{username}/credentialgives a trunk with no credential its first one, so it can register. Address the trunk by itsidor its handle. A trunk that already has a credential answers409: rotate it instead.
IP list and host names
A trunk accepts registration with its credential, or calls from an address on its IP list without registering.
GET /trunks/{username}/ipslists the entries.POST /trunks/{username}/ipsadds one: a public IPv4 address or a range no wider than/24, a single IPv6 address, or a host name such aspbx.example.com. A host name is resolved now and again on its DNS TTL, and listed withtype: host. An address or host name already on another trunk, yours or another account’s, is refused, since the source address says which trunk a call belongs to.DELETE /trunks/{username}/ips/{ipId}removes one.
Source restrictions are a different thing: they limit where the trunk’s
credential may be used from. GET /trunks/{username}/source-restrictions
reads them, and 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.
So a typo cannot lock 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 does not look up countries, so send confirmLockout too when the
address is let in by its country instead.
Registration
GET /trunks/{username}/registration gives the live registration state:
whether the trunk is registered, and the contacts registered against it,
which are PBXs and gateways. A trunk that sends calls only from its IP list
does not register, so it reads registered: false.
Changing the plan or channels, and what is charged
Change type and channels with PATCH /trunks/{username}.
- An upgrade takes effect at once and is billed from today:
paygtoultimate, or more channels onultimate. - A downgrade takes effect at the start of your next billing cycle: fewer
channels, or
ultimatetopayg. Until then the trunk reads its current plan, and the booked change is inpendingPlanChange.
The answer carries a planChange block saying which way the change went,
whether it applied at once, and its effectiveOn date. A new request
replaces a change already booked. DELETE /trunks/{username}/plan-change
cancels a booked change, and so does DELETE /account/booked-changes/{id},
which lists it with your other booked changes.
On payg, channels is only a ceiling on concurrent calls and 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 does not.
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. Sending
acknowledgeEarlyTermination=true accepts it and deletes the trunk.
Suspending and resuming
POST /trunks/{username}/suspend stops a trunk’s calls at once, for example
to stop a compromised PBX. New outbound calls are refused and calls to its
numbers are refused before they reach the PBX. The caller hears that the
number can’t be reached. No failover step runs, voicemail takes no
message, and the line’s forwarding and Do Not Disturb are not applied. It
still places 000, 112 and 106 calls, and for an hour after one, calls to its
numbers are delivered so the emergency service can call back, ringing the
trunk whatever its forwarding or Do Not Disturb says. Billing is unchanged. The trunk reads
status: suspended and suspendedBy: account.
Calls already up carry on when a trunk is suspended. 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. Send it again with a new key to retry the
failed ones.
POST /trunks/{username}/resume reverses a suspension. A trunk we
suspended, for example for non-payment, reads suspendedBy: checkNetworks.
It answers 409 with the reason, and stays suspended until we lift it.
A trunk whose defaultCallerId ported to another carrier keeps it. We
don’t change it for you. 48 hours after the port completes, a trunk still
presenting it is suspended, with suspendedBy: checkNetworks. 000 still
connects. Setting another defaultCallerId with PATCH /trunks/{username}
lifts it within a couple of minutes. We email your technical and primary
contacts before then.
Spend caps and holds
Set dailySpendCapExGst with PATCH /trunks/{username}, as a dollar
string, to limit what the trunk’s outbound calls may cost in a day. null
removes the cap. The trunk reads spendTodayExGst beside it. A call counts
toward it when the call ends, so calls still up are not in it yet.
When a trunk reaches its cap, spendCapHeld is true and its new outbound
calls stop until midnight Brisbane time, given in spendCapReleasesAt.
Calls already up carry on. To let calls through sooner, send
POST /trunks/{username}/spend-cap/release, which keeps the same cap for
the rest of the day, or raise the cap above spendTodayExGst. A cap set at
or below spendTodayExGst, "0.00" included, holds the trunk at once, and
the PATCH answer reads spendCapHeld: true. 000 and inbound calls are
never held. While it is held, each outbound call the trunk tries is refused
with 403 Outbound calling suspended and a Retry-After header giving 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. Your whole account’s
outbound calls can be held for unusual spend or calling patterns.
Webhooks
trunk.downwhen an active trunk has neither registered nor sent an OPTIONS keepalive for 10 minutes, andtrunk.upwhen it is back. When one of our own SBCs stops recording trunks, we send notrunk.downuntil it records again: that fault is ours, and we deal with it. A trunk really down through it is senttrunk.downonce it does.trunk.planChangeScheduled,trunk.planChangeCancelledandtrunk.planChangedas a plan change is booked, cancelled and applied, withbookedChange.applied,bookedChange.cancelledandbookedChange.failedbeside them.voice.hold.placedandvoice.hold.releasedwhen a hold starts and ends: a spend cap hold (dailySpendCap), an international cap hold (internationalCap), or an account hold.
Webhook event types lists each event’s fields.