Skip to main content

Create Trunk

Endpoint

POST /v1/trunks

Method

POST

Auth requirement

Bearer application API key.

Business example: configure a BYOC trunk for outbound sales calls or inbound carrier traffic before moving production callers to the route.

Request body

{
"name": "primary-outbound",
"proxy": "sip.example.net",
"username": "user1",
"password": "secret",
"realm": "sip.example.net",
"from_domain": "sip.example.net",
"is_active": true,
"gateway_name": "primary"
}

Response body

{
"id": "trunk_20260529T120000.000000000",
"customer_id": "cust_123",
"name": "primary-outbound",
"direction": "outbound",
"gateway_name": "primary",
"proxy": "sip.example.net",
"username": "user1",
"is_active": true,
"created_at": "2026-05-29T12:00:00Z",
"updated_at": "2026-05-29T12:00:00Z"
}

Errors

400 invalid_request. 401 unauthorized. 409 gateway_name_exists or inbound_ip_exists.

Common Error Example

{
"error": {
"code": "gateway_name_exists",
"message": "gateway_name already exists"
}
}

Example curl

curl -sS -X POST https://api.minivoice.eu/v1/trunks \
-H 'Authorization: Bearer $MINIVOICE_API_KEY' \
-H 'Content-Type: application/json' \
--data @- <<'JSON'
{
"name": "primary-outbound",
"proxy": "sip.example.net",
"gateway_name": "primary"
}
JSON

Test procedure

Create the trunk, list trunks, and place a test outbound call.

Integration guidance

Use this page as part of a complete MiniVoice integration, not as an isolated reference. Start by wiring the smallest possible version in a test application, then add business logic after you can reproduce the behaviour reliably. Keep the MiniVoice call ID in your own records, because that ID is the easiest way to connect API responses, webhook events, recordings, AI results, and billing details.

When you build the workflow, separate caller experience from backend processing. The caller should hear short prompts and reach a destination quickly. Longer work, such as updating a CRM or creating a support ticket, should happen after your webhook endpoint has accepted the event. This keeps the voice flow responsive and makes retry handling easier.

For manual testing, use one known DID, one known destination number, and one webhook receiver where you can inspect request headers and bodies. Run the same test at least three times: one normal path, one invalid input path, and one timeout or no-answer path. Save the examples that worked as fixtures for future regression tests.

Integration checklist

Use trunks when you want MiniVoice to send or receive traffic through your own carrier path. Store the trunk ID with any application or routing rule that depends on it, and test both an accepted call and a failed destination before moving real traffic.

For outbound traffic, verify caller ID, destination formatting, and account limits. For inbound traffic, confirm that calls entering through the trunk reach the same webhook and action handling logic as calls from a MiniVoice DID. Keep failures visible in your monitoring so carrier or credential changes are noticed quickly.

Copy/Paste Examples

Real Request

curl -sS https://api.minivoice.eu/v1/trunks \
-H 'Authorization: Bearer $MINIVOICE_API_KEY'

Real Response

{
"data": [
{
"id": "trunk_123",
"customer_id": "cust_123",
"name": "primary",
"direction": "outbound",
"gateway_name": "primary",
"proxy": "sip.example.net",
"is_active": true,
"registration_status": "REGED"
}
],
"count": 1
}

Real Webhook Example

{
"event": "call.completed",
"created_at": "2026-05-29T12:10:00Z",
"call": {
"id": "call_123",
"customer_id": "cust_123",
"application_id": "app_123",
"status": "completed",
"direction": "inbound",
"from": "+15551230001",
"to": "+15551230002"
},
"variables": {},
"data": {}
}

Common Use Case

Create or verify a BYOC trunk before placing outbound calls through your carrier.

Common Failure Case

{
"error": {
"code": "no_active_trunk",
"message": "no active outbound trunk available"
}
}

Use the error code for branching and log the full response body while testing.