Tutorial

Prerequisites

Before working with routes, you need:

  • An authentication token. Obtain one via POST /auth/login or use an access key from GET /accesskeys.

  • A provider ID (UUID). Obtain from GET /providers or create one via POST /providers.

  • A customer ID (UUID). Obtain from GET /customers. Use 00000000-0000-0000-0000-000000000001 for system-wide default routes.

Note

AI Implementation Hint

Routes are evaluated by priority (lower number = higher priority). To set up failover, create multiple routes for the same customer_id and target with different provider_id values and incrementing priority values (e.g., 1, 2, 3). If the first provider fails, VoIPBIN automatically tries the next route.

Get list of routes

Example

$ curl --location --request GET 'https://api.voipbin.net/v1.0/routes?customer_id=00000000-0000-0000-0000-000000000001&token=<YOUR_AUTH_TOKEN>'

{
    "result": [
        {
            "id": "491b6858-5357-11ed-b753-8fd49cd36340",
            "customer_id": "00000000-0000-0000-0000-000000000001",
            "name": "",
            "detail": "",
            "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
            "priority": 1,
            "target": "all",
            "tm_create": "2022-10-22 16:16:16.874761",
            "tm_update": "2022-10-22 16:16:16.874761",
            "tm_delete": "9999-01-01 00:00:00.000000"
        }
    ],
    "next_page_token": "2022-10-22 16:16:16.874761"
}

Get detail of route

Example

$ curl --location --request GET 'https://api.voipbin.net/v1.0/routes/dccfd81b-5f11-4c49-8e3f-70730ef1a4d3?token=<YOUR_AUTH_TOKEN>'

{
    "id": "dccfd81b-5f11-4c49-8e3f-70730ef1a4d3",
    "customer_id": "00000000-0000-0000-0000-000000000001",
    "name": "",
    "detail": "",
    "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
    "priority": 1,
    "target": "+82",
    "tm_create": "2022-10-26 11:41:18.124909",
    "tm_update": "2022-10-29 14:50:33.477405",
    "tm_delete": "2022-10-29 14:50:33.477405"
}

Create a new route

Example

$ curl --location --request POST 'https://api.voipbin.net/v1.0/routes?token=<YOUR_AUTH_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "customer_id": "00000000-0000-0000-0000-000000000001",
    "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
    "priority": 1,
    "target": "+82"
}'

{
    "id": "b972b61c-59d2-4217-8fbb-a32304be5c3b",
    "customer_id": "00000000-0000-0000-0000-000000000001",
    "name": "",
    "detail": "",
    "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
    "priority": 1,
    "target": "+82",
    "tm_create": "2022-11-02 15:36:32.174346",
    "tm_update": "9999-01-01 00:00:00.000000",
    "tm_delete": "9999-01-01 00:00:00.000000"
}

Update route

Example

$ curl --location --request PUT 'https://api.voipbin.net/v1.0/routes/b972b61c-59d2-4217-8fbb-a32304be5c3b?token=<YOUR_AUTH_TOKEN>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "customer_id": "00000000-0000-0000-0000-000000000001",
        "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
        "priority": 2,
        "target": "+82"
    }'

{
    "id": "b972b61c-59d2-4217-8fbb-a32304be5c3b",
    "customer_id": "00000000-0000-0000-0000-000000000001",
    "name": "",
    "detail": "",
    "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
    "priority": 2,
    "target": "+82",
    "tm_create": "2022-11-02 15:36:32.174346",
    "tm_update": "2022-11-02 15:43:09.190169",
    "tm_delete": "9999-01-01 00:00:00.000000"
}

Delete route

Example

$ curl --location --request DELETE 'https://api.voipbin.net/v1.0/routes/b972b61c-59d2-4217-8fbb-a32304be5c3b?token=<YOUR_AUTH_TOKEN>'

{
    "id": "b972b61c-59d2-4217-8fbb-a32304be5c3b",
    "customer_id": "00000000-0000-0000-0000-000000000001",
    "name": "",
    "detail": "",
    "provider_id": "4dbeabd6-f397-4375-95d2-a38411e07ed1",
    "priority": 1,
    "target": "+82",
    "tm_create": "2022-11-02 15:36:32.174346",
    "tm_update": "2022-11-02 15:44:09.686612",
    "tm_delete": "2022-11-02 15:44:09.686612"
}