NAV
cURL

Carrier API

This documentation is intended for carriers as defined in the carrier documentation. The API documentation for Somleng's Open Source implementation of Twilio's REST API is available here.

The Carrier API is intended for carriers who need to automate provisioning of carrier resources (e.g. Accounts) rather that using the dashboard. This API is written according to the JSON API Specification. We recommend using a JSON API Client for consuming this API.

Authentication

This API uses Bearer authentication. You must include your API key in the Authorization header for all requests. Your API key is available on the Carrier Dashboard.

Webhooks

Somleng uses webhooks to notify your application when an event happens in your account. Somleng signs the webhook events it sends to your endpoint by including a signature in each event's Authorization header. This allows you to verify that the events were sent by Somleng, not by a third party.

All requests are signed using JSON Web Token (JWT) Bearer authentication, according to the HS256 (HMAC-SHA256) algorithm.

You should verify the events that Somleng sends to your Webhook endpoints. On the right is an example in Ruby ---->

JWT.decode(
  request.headers["Authorization"].sub("Bearer ", ""),
  "[your-webhook-signing-secret]",
  true,
  algorithm: "HS256",
  verify_iss: true,
  iss: "Somleng"
)

Accounts

Create an account

Request

curl "https://api.somleng.org/carrier/v1/accounts" -d '{
  "data": {
    "type": "account",
    "attributes": {
      "name": "Rocket Rides",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "foo": "bar"
      }
    }
  }
}' -X POST \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Gq-jadVyin6VhZ8ZVJ7frMAmAKYM-3QJllkcOJ79YHw"

Endpoint

POST https://api.somleng.org/carrier/v1/accounts

POST https://api.somleng.org/carrier/v1/accounts

Parameters

{
  "data": {
    "type": "account",
    "attributes": {
      "name": "Rocket Rides",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "foo": "bar"
      }
    }
  }
}
Name Description
data[attributes][name] required A friendly name which identifies the account
data[attributes][tts_voice] The default TTS voice identifier. Defaults to: Basic.Kal
data[attributes][metadata] Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

Response


201 Created
{
  "data": {
    "id": "a3c126f5-dcab-46b9-8e59-b6b403265d5c",
    "type": "account",
    "attributes": {
      "created_at": "2025-12-05T06:07:20Z",
      "updated_at": "2025-12-05T06:07:20Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "Vo7-JWA_XzlqXnevF-oooO5cGJ4CPAK1bqUkTggXizc",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/1eaf8bb7-8cf9-45c0-8d1a-ef995c2f8fbc" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer YtJ_Y37oEiyAim8vu4TxTrJX_M2holWK-XmjkW-tSKk"

Endpoint

DELETE https://api.somleng.org/carrier/v1/accounts/:id

DELETE https://api.somleng.org/carrier/v1/accounts/1eaf8bb7-8cf9-45c0-8d1a-ef995c2f8fbc

Parameters

None known.

Response


204 No Content

List all accounts

Request

curl "https://api.somleng.org/carrier/v1/accounts" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer d12OlHhoX68SR3_Z9s-jihb6TS7cKCtsHge6WQnR0ck"

Endpoint

GET https://api.somleng.org/carrier/v1/accounts

GET https://api.somleng.org/carrier/v1/accounts

Parameters

None known.

Response


200 OK
{
  "data": [
    {
      "id": "e10c80d9-07f9-4499-a72e-d0300563a7d0",
      "type": "account",
      "attributes": {
        "created_at": "2025-12-05T06:07:20Z",
        "updated_at": "2025-12-05T06:07:20Z",
        "name": "Telco Net",
        "metadata": {},
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "XF4dLidgPuStJLPTZWtnkaoSsh0tUnVH-Rh_QDYPNr4",
        "default_tts_voice": "Basic.Kal"
      }
    },
    {
      "id": "c5385ee7-cb88-4d8d-bef5-e84493e43d83",
      "type": "account",
      "attributes": {
        "created_at": "2025-12-05T06:07:20Z",
        "updated_at": "2025-12-05T06:07:20Z",
        "name": "Rocket Rides",
        "metadata": {},
        "status": "enabled",
        "type": "customer_managed",
        "default_tts_voice": "Basic.Kal"
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/accounts?page%5Bbefore%5D=e10c80d9-07f9-4499-a72e-d0300563a7d0",
    "next": null
  }
}

Retrieve an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/384c2fa4-7537-4166-89ee-b0e4555a9dc7" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer j_PR3vhGv-fE-WxIsKda2A3v7t8b85w45ilQUQfNR2c"

Endpoint

GET https://api.somleng.org/carrier/v1/accounts/:id

GET https://api.somleng.org/carrier/v1/accounts/384c2fa4-7537-4166-89ee-b0e4555a9dc7

Parameters

Name Description
id required The id of the account to be retrieved.

Response


200 OK
{
  "data": {
    "id": "384c2fa4-7537-4166-89ee-b0e4555a9dc7",
    "type": "account",
    "attributes": {
      "created_at": "2025-12-05T06:07:20Z",
      "updated_at": "2025-12-05T06:07:20Z",
      "name": "Rocket Rides",
      "metadata": {},
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "vo47j3CEE679BCB_EUHjYdDc6pxLi562yyP_WrOEPJo",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/ee438b49-b4fa-49ad-b0c2-ec206952a26f" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "ee438b49-b4fa-49ad-b0c2-ec206952a26f"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer uHhi0NQY5a_8_DWJkGJNcqSsDlSEL0uPmwOrghTLqd8"

Endpoint

PATCH https://api.somleng.org/carrier/v1/accounts/:id

PATCH https://api.somleng.org/carrier/v1/accounts/ee438b49-b4fa-49ad-b0c2-ec206952a26f

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "ee438b49-b4fa-49ad-b0c2-ec206952a26f"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "ee438b49-b4fa-49ad-b0c2-ec206952a26f",
    "type": "account",
    "attributes": {
      "created_at": "2025-12-05T06:07:20Z",
      "updated_at": "2025-12-05T06:07:20Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "FnsnPDIk9AYfRQEb5DR_iK4vaKTCo7K6uxKH9YQjY8s",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Events

List all events

Types of events

This is a list of all the types of events we currently send. We may add more at any time, so in developing and maintaining your code, you should not assume that only these types exist.

You'll notice that these events follow a pattern: resource.event. Our goal is to design a consistent system that makes things easier to anticipate and code against.

Event
phone_call.completed
message.sent
message.delivered

Request

curl "https://api.somleng.org/carrier/v1/events" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer aq0wxMrUOpvobKOmQZGxwL1EvEsAkC__3E6Glp27uXM"

Endpoint

GET https://api.somleng.org/carrier/v1/events

GET https://api.somleng.org/carrier/v1/events

Parameters

None known.

Response


200 OK
{
  "data": [
    {
      "id": "258bb092-5c98-423b-b9f6-4543369295bd",
      "type": "event",
      "attributes": {
        "created_at": "2025-12-05T06:07:13Z",
        "updated_at": "2025-12-05T06:07:13Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "a45be71f-d0ac-4ac4-950c-22959a5815d9",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2025-12-05T06:07:13Z",
              "price_unit": null,
              "updated_at": "2025-12-05T06:07:13Z"
            },
            "relationships": {
              "account": {
                "data": {
                  "id": "748db48d-2439-4a6f-8c69-d027755f9ed4",
                  "type": "account"
                }
              }
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=258bb092-5c98-423b-b9f6-4543369295bd",
    "next": null
  }
}

Retrieve an Event

Request

curl "https://api.somleng.org/carrier/v1/events/f8129265-c9c0-4f8f-a34b-55c50ce931c5" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer xnAMmEeLwQYl3y1f1DOG0eCNdLDaqKxIfl4h7XNVVbE"

Endpoint

GET https://api.somleng.org/carrier/v1/events/:id

GET https://api.somleng.org/carrier/v1/events/f8129265-c9c0-4f8f-a34b-55c50ce931c5

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "f8129265-c9c0-4f8f-a34b-55c50ce931c5",
    "type": "event",
    "attributes": {
      "created_at": "2025-12-05T06:07:13Z",
      "updated_at": "2025-12-05T06:07:13Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "68e2b1b0-68b2-4fed-8375-dbc881fc8a2e",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2025-12-05T06:07:13Z",
            "price_unit": null,
            "updated_at": "2025-12-05T06:07:13Z"
          },
          "relationships": {
            "account": {
              "data": {
                "id": "352d3de3-c999-4ada-a101-5fecb7fc08ae",
                "type": "account"
              }
            }
          }
        }
      }
    }
  }
}

Messages

List messages

Request

curl "https://api.somleng.org/carrier/v1/messages?filter[status]=sent&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T00%3A00%3A00Z&filter[account]=dd37814d-1eaf-4aaf-9f6b-bf5e8ed8042e&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 9LLaFNQ1nJpiggc06IhyvfyX6k2XjA1q4MkCjcwvyWM"

Endpoint

GET https://api.somleng.org/carrier/v1/messages

GET https://api.somleng.org/carrier/v1/messages?filter[status]=sent&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T00%3A00%3A00Z&filter[account]=dd37814d-1eaf-4aaf-9f6b-bf5e8ed8042e&filter[direction]=outbound-api

Parameters

{
  "filter": {
    "status": "sent",
    "from_date": "2021-11-01T00:00:00Z",
    "to_date": "2021-11-01T00:00:00Z",
    "account": "dd37814d-1eaf-4aaf-9f6b-bf5e8ed8042e",
    "direction": "outbound-api"
  }
}
Name Description
filter[account] Return messages from the provided account-sid
filter[from_date] Return messages on or after the provided date/time in ISO 8601 format.
filter[to_date] Return messages on or before the provided date/time in ISO 8601 format.
filter[direction] One of inbound, outbound-api, outbound-call, outbound-reply, and outbound
filter[status] One of accepted, scheduled, queued, sending, sent, failed, received, canceled, and delivered

Response


200 OK
{
  "data": [
    {
      "id": "a3253205-e437-473b-8e23-4921d5a4fd83",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2025-12-05T06:07:04Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "dd37814d-1eaf-4aaf-9f6b-bf5e8ed8042e",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=dd37814d-1eaf-4aaf-9f6b-bf5e8ed8042e&filter%5Bdirection%5D=outbound-api&filter%5Bfrom_date%5D=2021-11-01T00%3A00%3A00Z&filter%5Bstatus%5D=sent&filter%5Bto_date%5D=2021-11-01T00%3A00%3A00Z&page%5Bbefore%5D=a3253205-e437-473b-8e23-4921d5a4fd83",
    "next": null
  }
}

Retrieve a message

Request

curl "https://api.somleng.org/carrier/v1/messages/c723010a-8e69-4ff9-b716-1187f71da8af" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer gUajDrxfmNuoE7rmDU_F6pq4yTvK8SK34DyD8PWZ1Kg"

Endpoint

GET https://api.somleng.org/carrier/v1/messages/:id

GET https://api.somleng.org/carrier/v1/messages/c723010a-8e69-4ff9-b716-1187f71da8af

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "c723010a-8e69-4ff9-b716-1187f71da8af",
    "type": "message",
    "attributes": {
      "created_at": "2025-12-05T06:07:04Z",
      "updated_at": "2025-12-05T06:07:04Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "c5cd0f3b-3d78-4799-a9d2-47724c7ae31d",
          "type": "account"
        }
      }
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/b7f8cd35-aedc-4d38-a223-8a323e00906c" -d '{
  "data": {
    "id": "b7f8cd35-aedc-4d38-a223-8a323e00906c",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer pMgE4Qj0L2nCMCLKKmefF8WiQupKROUZi7dkBZRg02U"

Endpoint

PATCH https://api.somleng.org/carrier/v1/messages/:id

PATCH https://api.somleng.org/carrier/v1/messages/b7f8cd35-aedc-4d38-a223-8a323e00906c

Parameters

{
  "data": {
    "id": "b7f8cd35-aedc-4d38-a223-8a323e00906c",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}
Name Description
data[attributes][price] The charge for this call in the account's billing currency

Response


200 OK
{
  "data": {
    "id": "b7f8cd35-aedc-4d38-a223-8a323e00906c",
    "type": "message",
    "attributes": {
      "created_at": "2025-12-05T06:07:04Z",
      "updated_at": "2025-12-05T06:07:04Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "ffd7fc38-cd3a-4283-9d1e-779a1bc0dcb0",
          "type": "account"
        }
      }
    }
  }
}

Phone Calls

List phone calls

Request

curl "https://api.somleng.org/carrier/v1/phone_calls?filter[status]=queued&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T00%3A00%3A00Z&filter[account]=beffafea-31de-4069-827a-f20c9c614e45&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 1Cfk5lxdiV8O6Zlu9BQjKWaGKb6BxEAynyo5gWUn7Pk"

Endpoint

GET https://api.somleng.org/carrier/v1/phone_calls

GET https://api.somleng.org/carrier/v1/phone_calls?filter[status]=queued&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T00%3A00%3A00Z&filter[account]=beffafea-31de-4069-827a-f20c9c614e45&filter[direction]=outbound-api

Parameters

{
  "filter": {
    "status": "queued",
    "from_date": "2021-11-01T00:00:00Z",
    "to_date": "2021-11-01T00:00:00Z",
    "account": "beffafea-31de-4069-827a-f20c9c614e45",
    "direction": "outbound-api"
  }
}
Name Description
filter[account] Return phone calls from the provided account-sid
filter[from_date] Return phone calls on or after the provided date/time in ISO 8601 format.
filter[to_date] Return phone calls on or before the provided date/time in ISO 8601 format.
filter[direction] One of inbound, outbound-api, and outbound-dial
filter[status] One of queued, ringing, in-progress, busy, failed, no-answer, completed, and canceled

Response


200 OK
{
  "data": [
    {
      "id": "b294b2e1-d840-4996-9742-fc209950739d",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2025-12-05T06:06:11Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "beffafea-31de-4069-827a-f20c9c614e45",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=beffafea-31de-4069-827a-f20c9c614e45&filter%5Bdirection%5D=outbound-api&filter%5Bfrom_date%5D=2021-11-01T00%3A00%3A00Z&filter%5Bstatus%5D=queued&filter%5Bto_date%5D=2021-11-01T00%3A00%3A00Z&page%5Bbefore%5D=b294b2e1-d840-4996-9742-fc209950739d",
    "next": null
  }
}

Retrieve a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/e7c84bd4-c1de-40fb-bd9a-60549115d974" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer hM7jsOmzB4N0fu4gUJLlF8RZlXh2k5lETgZqXzCfadI"

Endpoint

GET https://api.somleng.org/carrier/v1/phone_calls/:id

GET https://api.somleng.org/carrier/v1/phone_calls/e7c84bd4-c1de-40fb-bd9a-60549115d974

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "e7c84bd4-c1de-40fb-bd9a-60549115d974",
    "type": "phone_call",
    "attributes": {
      "created_at": "2025-12-05T06:06:11Z",
      "updated_at": "2025-12-05T06:06:11Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "acf128ca-00df-4b6b-8ccf-82e98acee490",
          "type": "account"
        }
      }
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/a8a35045-dafa-4fd1-9922-838c3de9625e" -d '{
  "data": {
    "id": "a8a35045-dafa-4fd1-9922-838c3de9625e",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer RtIdvcdMk1fHis7FQ1G28w2ZoSsPaDkOIBSqYDdckDk"

Endpoint

PATCH https://api.somleng.org/carrier/v1/phone_calls/:id

PATCH https://api.somleng.org/carrier/v1/phone_calls/a8a35045-dafa-4fd1-9922-838c3de9625e

Parameters

{
  "data": {
    "id": "a8a35045-dafa-4fd1-9922-838c3de9625e",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}
Name Description
data[attributes][price] The charge for this call in the account's billing currency

Response


200 OK
{
  "data": {
    "id": "a8a35045-dafa-4fd1-9922-838c3de9625e",
    "type": "phone_call",
    "attributes": {
      "created_at": "2025-12-05T06:06:11Z",
      "updated_at": "2025-12-05T06:06:11Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "52db32db-6326-4e64-b111-6d893b099777",
          "type": "account"
        }
      }
    }
  }
}

Phone Numbers

01. Create a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers" -d '{
  "data": {
    "type": "phone_number",
    "attributes": {
      "number": "1294",
      "type": "short_code",
      "metadata": {
        "my_custom_field": "my_custom_field_value"
      }
    }
  }
}' -X POST \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer XiqldnIr0MTfc-uDcCFIWhIOX2zmk-wb-8k_vJfcTBo"

Endpoint

POST https://api.somleng.org/carrier/v1/phone_numbers

POST https://api.somleng.org/carrier/v1/phone_numbers

Parameters

{
  "data": {
    "type": "phone_number",
    "attributes": {
      "number": "1294",
      "type": "short_code",
      "metadata": {
        "my_custom_field": "my_custom_field_value"
      }
    }
  }
}
Name Description
data[attributes][number] required Phone number in E.164 format or shortcode.
data[attributes][type] required The type of the phone number. Must be one of short_code, local, mobile, toll_free.
data[attributes][visibility] The visibility of the phone number. Must be one of private, public, disabled. Defaults to public for phone numbers with a price and private for phone numbers without one
data[attributes][country] The ISO 3166-1 alpha-2 country code of the phone number. If not specified, it's automatically resolved from the number parameter, or defaults to the carrier's country code if unresolvable.
data[attributes][price] The price for the phone number in the billing currency of the carrier.
data[attributes][region] The state or province abbreviation of this phone number's location.
data[attributes][locality] The locality or city of this phone number's location.
data[attributes][lata] The LATA of this phone number. Applicable only to phone numbers from the US and Canada.
data[attributes][rate_center] The rate center of this phone number. Applicable only to phone numbers from the US and Canada.
data[attributes][latitude] The latitude of this phone number's location. Applicable only for phone numbers from the US and Canada.
data[attributes][longitude] The longitude of this phone number's location. Applicable only for phone numbers from the US and Canada.
data[attributes][metadata] Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

Response


201 Created
{
  "data": {
    "id": "11612be9-fb51-4768-ad35-35197abc3026",
    "type": "phone_number",
    "attributes": {
      "created_at": "2025-12-05T06:07:22Z",
      "updated_at": "2025-12-05T06:07:22Z",
      "number": "1294",
      "country": "KH",
      "visibility": "private",
      "type": "short_code",
      "locality": null,
      "rate_center": null,
      "lata": null,
      "latitude": null,
      "longitude": null,
      "metadata": {
        "my_custom_field": "my_custom_field_value"
      },
      "currency": "KHR",
      "price": "0.00",
      "region": null
    }
  }
}

02. Update a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/a5323259-f1d1-421f-ad37-a2113992bf2b" -d '{
  "data": {
    "type": "phone_number",
    "id": "a5323259-f1d1-421f-ad37-a2113992bf2b",
    "attributes": {
      "type": "mobile",
      "visibility": "public",
      "country": "US",
      "price": "1.15",
      "region": "AR",
      "locality": "Little Rock",
      "rate_center": "LITTLEROCK",
      "lata": "528",
      "latitude": "34.748463",
      "longitude": "-92.284434",
      "metadata": {
        "my_custom_field": "my_custom_field_value"
      }
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer VIatxJPFXAPFihcXb56j0TQ7dSbnd2iycV_M9xQf5wk"

Endpoint

PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id

PATCH https://api.somleng.org/carrier/v1/phone_numbers/a5323259-f1d1-421f-ad37-a2113992bf2b

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "a5323259-f1d1-421f-ad37-a2113992bf2b",
    "attributes": {
      "type": "mobile",
      "visibility": "public",
      "country": "US",
      "price": "1.15",
      "region": "AR",
      "locality": "Little Rock",
      "rate_center": "LITTLEROCK",
      "lata": "528",
      "latitude": "34.748463",
      "longitude": "-92.284434",
      "metadata": {
        "my_custom_field": "my_custom_field_value"
      }
    }
  }
}
Name Description
data[attributes][type] The type of the phone number. Must be one of short_code, local, mobile, toll_free.
data[attributes][visibility] The visibility of the phone number. Must be one of private, public, disabled. Defaults to public for phone numbers with a price and private for phone numbers without one
data[attributes][country] The ISO 3166-1 alpha-2 country code of the phone number. If not specified, it's automatically resolved from the number parameter, or defaults to the carrier's country code if unresolvable.
data[attributes][price] The price for the phone number in the billing currency of the carrier.
data[attributes][region] The state or province abbreviation of this phone number's location.
data[attributes][locality] The locality or city of this phone number's location.
data[attributes][lata] The LATA of this phone number. Applicable only to phone numbers from the US and Canada.
data[attributes][rate_center] The rate center of this phone number. Applicable only to phone numbers from the US and Canada.
data[attributes][latitude] The latitude of this phone number's location. Applicable only for phone numbers from the US and Canada.
data[attributes][longitude] The longitude of this phone number's location. Applicable only for phone numbers from the US and Canada.
data[attributes][metadata] Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

Response


200 OK
{
  "data": {
    "id": "a5323259-f1d1-421f-ad37-a2113992bf2b",
    "type": "phone_number",
    "attributes": {
      "created_at": "2025-12-05T06:07:22Z",
      "updated_at": "2025-12-05T06:07:22Z",
      "number": "+15067020972",
      "country": "US",
      "visibility": "public",
      "type": "mobile",
      "locality": "Little Rock",
      "rate_center": "LITTLEROCK",
      "lata": "528",
      "latitude": "34.748463",
      "longitude": "-92.284434",
      "metadata": {
        "my_custom_field": "my_custom_field_value"
      },
      "currency": "CAD",
      "price": "1.15",
      "region": "AR"
    }
  }
}

03. Retrieve a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/a73b7625-1a6a-4685-b46a-2ec301d3b553" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer t9C7SkEFfIc9hKQJSpzeebNVKR7yWGTIsocU5Q4cdI4"

Endpoint

GET https://api.somleng.org/carrier/v1/phone_numbers/:id

GET https://api.somleng.org/carrier/v1/phone_numbers/a73b7625-1a6a-4685-b46a-2ec301d3b553

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "a73b7625-1a6a-4685-b46a-2ec301d3b553",
    "type": "phone_number",
    "attributes": {
      "created_at": "2025-12-05T06:07:22Z",
      "updated_at": "2025-12-05T06:07:22Z",
      "number": "+855972345823",
      "country": "KH",
      "visibility": "private",
      "type": "mobile",
      "locality": null,
      "rate_center": null,
      "lata": null,
      "latitude": null,
      "longitude": null,
      "metadata": {},
      "currency": "KHR",
      "price": "0.00",
      "region": null
    }
  }
}

04. List all phone numbers

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer seL3pxd1YPlK0_04JpXYIjXcQn7MXP_n4gDhF8fnoOk"

Endpoint

GET https://api.somleng.org/carrier/v1/phone_numbers

GET https://api.somleng.org/carrier/v1/phone_numbers

Parameters

None known.

Response


200 OK
{
  "data": [
    {
      "id": "48ab2365-7be9-4a67-9203-8fa5fc87e666",
      "type": "phone_number",
      "attributes": {
        "created_at": "2025-12-05T06:07:22Z",
        "updated_at": "2025-12-05T06:07:22Z",
        "number": "+855972345820",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "locality": null,
        "rate_center": null,
        "lata": null,
        "latitude": null,
        "longitude": null,
        "metadata": {},
        "currency": "KHR",
        "price": "0.00",
        "region": null
      }
    },
    {
      "id": "11d5187b-880d-48c5-9785-b1437986c439",
      "type": "phone_number",
      "attributes": {
        "created_at": "2025-12-05T06:07:22Z",
        "updated_at": "2025-12-05T06:07:22Z",
        "number": "+855972345819",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "locality": null,
        "rate_center": null,
        "lata": null,
        "latitude": null,
        "longitude": null,
        "metadata": {},
        "currency": "KHR",
        "price": "0.00",
        "region": null
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_numbers?page%5Bbefore%5D=48ab2365-7be9-4a67-9203-8fa5fc87e666",
    "next": null
  }
}

05. Delete a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/114219d0-26af-487e-97fe-d015f1641537" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 7Xpdgp-juut1SKjyhCfX4lfk7gpYTHzF3y3W4welQu4"

Endpoint

DELETE https://api.somleng.org/carrier/v1/phone_numbers/:id

DELETE https://api.somleng.org/carrier/v1/phone_numbers/114219d0-26af-487e-97fe-d015f1641537

Parameters

None known.

Response


204 No Content

06. Get number of available phone numbers per locality having a count less than 2

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/stats?filter[available]=true&filter[type]=local&group_by[]=country&group_by[]=region&group_by[]=locality&having[count][lt]=2" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ixzx1wEVnrfKEANGv38eI0F7vHBXqKIO4PrrTI5A13c"

Endpoint

GET https://api.somleng.org/carrier/v1/phone_numbers/stats

GET https://api.somleng.org/carrier/v1/phone_numbers/stats?filter[available]=true&filter[type]=local&group_by[]=country&group_by[]=region&group_by[]=locality&having[count][lt]=2

Parameters

{
  "filter": {
    "available": "true",
    "type": "local"
  },
  "group_by": [
    "country",
    "region",
    "locality"
  ],
  "having": {
    "count": {
      "lt": "2"
    }
  }
}
Name Description
filter[available] required Return only available phone numbers. Must be true
filter[type] required The phone number type. Must be local
filter[country] The ISO country code. E.g. US
filter[region] The ISO region code. E.g. AR
filter[locality] The locality or city name. e.g. Little Rock
group_by required An array of fields to group by. Must be ['country', 'region', 'locality']
having[count][operator] One of eq, neq, gt, gteq, lt, lteq
having[count][value] The value of the count. Must be an integer greater than or equal to 0

Response


200 OK
{
  "data": [
    {
      "id": "2e02a6de3fa86617dec16e762a756a2fc82f7f474215485effa2577b1a869e64",
      "type": "aggregate_data",
      "attributes": {
        "statistic": {
          "country": "US",
          "region": "AL",
          "locality": "Birmingham",
          "value": 1
        }
      }
    },
    {
      "id": "dbcd7a4b79acfdbeb7bc78dfcded1098b8a5b0ca1cb63619ae65864b89162520",
      "type": "aggregate_data",
      "attributes": {
        "statistic": {
          "country": "US",
          "region": "AL",
          "locality": "Huntsville",
          "value": 1
        }
      }
    },
    {
      "id": "7bb81870f4f3d4a6756f30d8a4ecbf98c0da08ec74cae4af760843e07bee7ec6",
      "type": "aggregate_data",
      "attributes": {
        "statistic": {
          "country": "US",
          "region": "AL",
          "locality": "Tuscaloosa",
          "value": 1
        }
      }
    },
    {
      "id": "f0e41da727a633bc8890195abcfb907391e664682d2da4cbd0a14f5e520bb7f4",
      "type": "aggregate_data",
      "attributes": {
        "statistic": {
          "country": "US",
          "region": "AR",
          "locality": "Hot Springs",
          "value": 1
        }
      }
    },
    {
      "id": "79adb2a2fce5c6ba215fe5f27f532d4e7edbac4b6a5e09e1ef3a08084a904621",
      "type": "aggregate_data",
      "attributes": {
        "statistic": {
          "country": "US",
          "region": null,
          "locality": null,
          "value": 1
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_numbers/stats?filter%5Bavailable%5D=true&filter%5Btype%5D=local&group_by%5B%5D=country&group_by%5B%5D=region&group_by%5B%5D=locality&having%5Bcount%5D%5Blt%5D=2&page%5Bbefore%5D=2e02a6de3fa86617dec16e762a756a2fc82f7f474215485effa2577b1a869e64",
    "next": null
  }
}

TTS Events

List all TTS events

Request

curl "https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2025-12-04&filter[account]=de0c84d9-364b-4c27-be27-e05d219786d8&filter[phone_call]=535be637-abc5-4f56-9a64-62df93a4d0ed" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Hea8WxCk4g9XxSHXerSauojo9YfwNqbpn8pxXqPL0j8"

Endpoint

GET https://api.somleng.org/carrier/v1/tts_events

GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2025-12-04&filter[account]=de0c84d9-364b-4c27-be27-e05d219786d8&filter[phone_call]=535be637-abc5-4f56-9a64-62df93a4d0ed

Parameters

{
  "filter": {
    "from_date": "2025-12-04",
    "account": "de0c84d9-364b-4c27-be27-e05d219786d8",
    "phone_call": "535be637-abc5-4f56-9a64-62df93a4d0ed"
  }
}
Name Description
filter[account] Return TTS Events from the provided account SID
filter[phone_call] Return TTS Events from the provided phone call SID
filter[from_date] Return TTS events on or after the provided date/time in ISO 8601 format.
filter[to_date] Return TTS events on or before the provided date/time in ISO 8601 format.

Response


200 OK
{
  "data": [
    {
      "id": "1a27667c-3c65-4157-843f-33e93236869e",
      "type": "tts_event",
      "attributes": {
        "created_at": "2025-12-05T06:07:32Z",
        "updated_at": "2025-12-05T06:07:32Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 200
      },
      "relationships": {
        "account": {
          "data": {
            "id": "de0c84d9-364b-4c27-be27-e05d219786d8",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "535be637-abc5-4f56-9a64-62df93a4d0ed",
            "type": "phone_call"
          }
        }
      }
    },
    {
      "id": "070efc50-8ee5-4dab-9327-95d91fd20b61",
      "type": "tts_event",
      "attributes": {
        "created_at": "2025-12-05T06:07:32Z",
        "updated_at": "2025-12-05T06:07:32Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 100
      },
      "relationships": {
        "account": {
          "data": {
            "id": "de0c84d9-364b-4c27-be27-e05d219786d8",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "535be637-abc5-4f56-9a64-62df93a4d0ed",
            "type": "phone_call"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=de0c84d9-364b-4c27-be27-e05d219786d8&filter%5Bfrom_date%5D=2025-12-04&filter%5Bphone_call%5D=535be637-abc5-4f56-9a64-62df93a4d0ed&page%5Bbefore%5D=1a27667c-3c65-4157-843f-33e93236869e",
    "next": null
  }
}

Retrieve a TTS Event

Request

curl "https://api.somleng.org/carrier/v1/tts_events/c79a848f-b533-44c6-9f9b-7a68ee5f30e2" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 8wrgtQ8Jp9_wzf8QiiQkxZPU7-U7erLdKT1r40uED5w"

Endpoint

GET https://api.somleng.org/carrier/v1/tts_events/:id

GET https://api.somleng.org/carrier/v1/tts_events/c79a848f-b533-44c6-9f9b-7a68ee5f30e2

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "c79a848f-b533-44c6-9f9b-7a68ee5f30e2",
    "type": "tts_event",
    "attributes": {
      "created_at": "2025-12-05T06:07:32Z",
      "updated_at": "2025-12-05T06:07:32Z",
      "voice": "Basic.Kal (Male, en-US)",
      "characters": 100
    },
    "relationships": {
      "account": {
        "data": {
          "id": "9426256e-c216-478a-b15b-f9025a35f57b",
          "type": "account"
        }
      },
      "phone_call": {
        "data": {
          "id": "1a810bf1-0791-4dea-9269-d51ef3350dca",
          "type": "phone_call"
        }
      }
    }
  }
}