From Zero to Trunk: Creating a Trunk Group via API (curl)
Steps to go from nothing to a SIP trunk group with an access trunk. The example values are placeholders.
Setup
# Ask for those requirements to our team
BASE="https://<backend-url>"
DRAAS="<draas_instance>"0. Login (get a token)
curl -X POST "$BASE/auth/login" \
-H "Content-Type: application/json" \
-d '{ "username": "admin@example.com", "password": "********" }'
# → { "access_token": "...", "refresh_token": "..." } (or a 2fa_payload if 2FA is on)
TOKEN="<access_token>"
AUTH=(-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -H "Accept: application/json")1. Create a tenant
POST /{draas}/tenants.
curl -X POST "$BASE/$DRAAS/tenants" "${AUTH[@]}" \
-d '{
"name": "Acme Corp",
"billingId": "ACME-001",
"markup": 0,
"owner": { "type": "reseller", "uuid": "<reseller-uuid>" }
}'
# → { "uuid": "<tenant-uuid>" }
TENANT="<tenant-uuid>"owner is optional. It sets the parent entity (distributor or reseller).
2. Create a subscription in the tenant
POST /{draas}/tenants/{tenant}/subscriptions.
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions" "${AUTH[@]}" \
-d '{ "name": "Acme HQ", "billingId": "ACME-HQ-001" }'
# → { "id": "<subscription-id>" }
SUB="<subscription-id>"3. Place an order (entitlements and SIP licenses)
First list the products available to the tenant to find the SKUs.
curl "$BASE/$DRAAS/tenants/$TENANT/products" "${AUTH[@]}"Then POST /{draas}/tenants/{tenant}/subscriptions/{sub}/orders.
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/orders" "${AUTH[@]}" \
-d '{
"name": "Acme HQ",
"products": [
{ "sku": "SIP-TRUNK-CHANNEL", "quantity": 10 },
{ "sku": "BE-GEO-NUMBER", "quantity": 10 }
]
}'The SKUs above are examples, so use the ones returned by /products.
Optional check of what was granted:
curl "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/entitlements" "${AUTH[@]}"4. Assign numbers to the subscription
Find free numbers that match the entitlements.
curl "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/free_numbers?page_size=100" "${AUTH[@]}"Then POST /{draas}/tenants/{tenant}/subscriptions/{sub}/numbers.
Option A: by range ([start, end] NSN pairs, inclusive):
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/numbers" "${AUTH[@]}" \
-d '{ "countryCode": "+32", "ranges": [[22001000, 22001009]] }'Option B: individual numbers.
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/numbers" "${AUTH[@]}" \
-d '{ "countryCode": "+32", "numbers": [22001000, 22001001] }'5. Create the SIP trunk (trunk group)
Optional: list the trunk types enabled for the subscription.
curl "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunkgroups_types" "${AUTH[@]}"
# → { "trunkTypes": ["sip", ...] }5a. Create the trunk group. POST .../trunkgroups.
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunkgroups" "${AUTH[@]}" \
-d '{
"name": "acme-hq-trunk",
"billingId": "ACME-TG-001",
"calledFormat": "e164",
"callingFormat": "e164",
"maxCalls": 10,
"maxIncomingCalls": 10,
"maxOutgoingCalls": 10,
"region": "<region>"
}'
# → { "id": "<trunk-id>" }
TRUNK="<trunk-id>"- Format values:
e164,national_with_0,international_with_00,international_without_00. - For a non-
siptrunk type, add"type": "<trunkType>". You can leavetypeout for plainsip.
5b. Attach DIDs to the trunk. POST .../trunkgroups/{trunk}/numbers.
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunkgroups/$TRUNK/numbers" "${AUTH[@]}" \
-d '{ "numbers": ["+3222001000", "+3222001001"] }'5c. Set the pilot number. Look up the DID's connectionId, then set it as pilot.
curl "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunkgroups/$TRUNK/numbers?page_size=1000" "${AUTH[@]}"
# → { "numbers": [ { "fullNumber": "+3222001000", "connectionId": 4711, ... } ] }
curl -X PUT "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunkgroups/$TRUNK" "${AUTH[@]}" \
-d '{ "pilot": 4711 }'6. Create an access trunk in the trunk group
List the POPs available to the subscription to get their ids.
curl "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunking_pops" "${AUTH[@]}"POST .../trunkgroups/{trunk}/access_trunks.
curl -X POST "$BASE/$DRAAS/tenants/$TENANT/subscriptions/$SUB/trunkgroups/$TRUNK/access_trunks" "${AUTH[@]}" \
-d '{
"name": "acme-hq-access-1",
"billingId": "ACME-AT-001",
"priority": 1,
"weight": 100,
"trunkLocale": "BE",
"authRequired": false,
"pops": [
{
"id": 1,
"inboundCalls": true,
"outboundCalls": true,
"transport": "UDP",
"sipOptions": true,
"privateRealm": false
}
],
"primaryPeerIp": "203.0.113.10",
"primaryPeerPort": 5060,
"ipWhitelist": "203.0.113.0/28"
}'priority: 1 to 5.transport:UDPorTCP.- Include only the POPs you want enabled.
