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",
"billing_enabled": true,
"billing_mode": "prepaid",
"metadata": {
"foo": "bar"
}
}
}
}' -X POST \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer uKI2v9XVs7VUuUyhebkcVkc2-cqe75Nn9yErZD8T1ro"
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",
"billing_enabled": true,
"billing_mode": "prepaid",
"metadata": {
"foo": "bar"
}
}
}
}
| Name | Description |
|---|---|
| data[attributes][name] required | A friendly name which identifies the account |
| data[attributes][billing_enabled] | Enable billing for the account. Defaults to false. |
| data[attributes][billing_mode] | The billing mode for the account. Only prepaid is supported at this time. |
| 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": "4bbbffd9-5963-4294-a72d-d6fe88118fee",
"type": "account",
"attributes": {
"created_at": "2026-09-13T08:45:13Z",
"updated_at": "2026-09-13T08:45:13Z",
"name": "Rocket Rides",
"metadata": {
"foo": "bar"
},
"status": "enabled",
"type": "carrier_managed",
"billing_enabled": true,
"billing_mode": "prepaid",
"auth_token": "QwhGul5t3vCbUQ_uXjTUMWJ_x4uoyQfUdgo8b20bHNs",
"default_tts_voice": "Basic.Kal"
}
}
}
Delete an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/e1c9ed4c-6249-48e8-a8de-317964e192fd" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer tLIhK9tAo9p30FXyKqZjfsd88WHbPcMMXPSfFUKG1Jw"
Endpoint
DELETE https://api.somleng.org/carrier/v1/accounts/:id
DELETE https://api.somleng.org/carrier/v1/accounts/e1c9ed4c-6249-48e8-a8de-317964e192fd
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 rf17msqxsc3pnWsXEFoER41eyd6DEfBxQGOuXz8aGLY"
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": "664172a7-7291-4219-8198-d2b21e3bf591",
"type": "account",
"attributes": {
"created_at": "2026-09-13T08:45:13Z",
"updated_at": "2026-09-13T08:45:13Z",
"name": "Telco Net",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"auth_token": "mda8kf4df6oNFFFCohvftcCi28zvSVpOYt9CTz7k4Vw",
"default_tts_voice": "Basic.Kal"
}
},
{
"id": "44ad395b-8591-4824-a58c-25d76426db18",
"type": "account",
"attributes": {
"created_at": "2026-09-13T08:45:13Z",
"updated_at": "2026-09-13T08:45:13Z",
"name": "Rocket Rides",
"metadata": {},
"status": "enabled",
"type": "customer_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"default_tts_voice": "Basic.Kal"
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/accounts?page%5Bbefore%5D=664172a7-7291-4219-8198-d2b21e3bf591",
"next": null
}
}
Retrieve an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/b1abaf96-7c1f-4765-a387-d6409b73074a" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 4uIJ1CKzCyXlJaqBZiPFIJjiTPWnMKSKC_mKh2lPDfY"
Endpoint
GET https://api.somleng.org/carrier/v1/accounts/:id
GET https://api.somleng.org/carrier/v1/accounts/b1abaf96-7c1f-4765-a387-d6409b73074a
Parameters
| Name | Description |
|---|---|
| id required | The id of the account to be retrieved. |
Response
200 OK
{
"data": {
"id": "b1abaf96-7c1f-4765-a387-d6409b73074a",
"type": "account",
"attributes": {
"created_at": "2026-09-13T08:45:13Z",
"updated_at": "2026-09-13T08:45:13Z",
"name": "Rocket Rides",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"auth_token": "wFRIveMWy8DkNa1LqvZMOUleO9tDxt7X3NnYQpV4zwk",
"default_tts_voice": "Basic.Kal"
}
}
}
Update an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/485f81ae-f5ae-4131-94e0-974d9f34526c" -d '{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"billing_enabled": false,
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "485f81ae-f5ae-4131-94e0-974d9f34526c"
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer jb0RxOPtD--MScW3MIC03p3Ci4AkYzCI7ARhqPi2p6A"
Endpoint
PATCH https://api.somleng.org/carrier/v1/accounts/:id
PATCH https://api.somleng.org/carrier/v1/accounts/485f81ae-f5ae-4131-94e0-974d9f34526c
Parameters
{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"billing_enabled": false,
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "485f81ae-f5ae-4131-94e0-974d9f34526c"
}
}
| Name | Description |
|---|---|
| data[attributes][status] | Update the status of the account. One of either enabled or disabled. |
Response
200 OK
{
"data": {
"id": "485f81ae-f5ae-4131-94e0-974d9f34526c",
"type": "account",
"attributes": {
"created_at": "2026-09-13T08:45:13Z",
"updated_at": "2026-09-13T08:45:13Z",
"name": "Bob Cats",
"metadata": {
"foo": "bar",
"bar": "foo"
},
"status": "disabled",
"type": "carrier_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"auth_token": "lrNLDY83j1AOAo-8YBoCquJC-VS3FJvOhPd2F3wV5wE",
"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 3PcxA2CqtkQh6d-2MW77tbqUt4rSN4HJQ46qwCpesTo"
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": "a4d52c0c-c7b5-4814-8c73-73d8cc658966",
"type": "event",
"attributes": {
"created_at": "2026-09-13T08:45:24Z",
"updated_at": "2026-09-13T08:45:24Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "1ef4d927-0c8b-48a0-bea2-7b78352b4461",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2026-09-13T08:45:24Z",
"price_unit": null,
"updated_at": "2026-09-13T08:45:24Z"
},
"relationships": {
"account": {
"data": {
"id": "5d07e221-4863-42bf-8a89-7c51fe2373c6",
"type": "account"
}
}
}
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=a4d52c0c-c7b5-4814-8c73-73d8cc658966",
"next": null
}
}
Retrieve an Event
Request
curl "https://api.somleng.org/carrier/v1/events/fcdf9673-57f5-44ba-a141-1a170cd2ee95" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer EYSZ-Z-6vYO2nZKoJYZA8ue52ncZvZkhUfkc9T00-Ic"
Endpoint
GET https://api.somleng.org/carrier/v1/events/:id
GET https://api.somleng.org/carrier/v1/events/fcdf9673-57f5-44ba-a141-1a170cd2ee95
Parameters
None known.
Response
200 OK
{
"data": {
"id": "fcdf9673-57f5-44ba-a141-1a170cd2ee95",
"type": "event",
"attributes": {
"created_at": "2026-09-13T08:45:24Z",
"updated_at": "2026-09-13T08:45:24Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "a8a06237-5dcf-4697-b3ef-4137b9b9d1f8",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2026-09-13T08:45:24Z",
"price_unit": null,
"updated_at": "2026-09-13T08:45:24Z"
},
"relationships": {
"account": {
"data": {
"id": "9f967353-b07b-4cad-bbec-96caf9fd660d",
"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]=42351424-3a3f-49ca-84da-5b1df821acf2&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer hoMQw3Hu_xbfQzqnjRc97Mpx8A3F3BMoXaWoBEY7aa4"
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]=42351424-3a3f-49ca-84da-5b1df821acf2&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "sent",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "42351424-3a3f-49ca-84da-5b1df821acf2",
"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": "75334fc8-8716-450f-8cf8-b5bb199e2d3c",
"type": "message",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2026-09-13T08:45:24Z",
"to": "+85512334667",
"from": "2442",
"price_unit": null,
"direction": "outbound-api",
"status": "sent",
"body": "Hello World",
"price": null
},
"relationships": {
"account": {
"data": {
"id": "42351424-3a3f-49ca-84da-5b1df821acf2",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=42351424-3a3f-49ca-84da-5b1df821acf2&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=75334fc8-8716-450f-8cf8-b5bb199e2d3c",
"next": null
}
}
Retrieve a message
Request
curl "https://api.somleng.org/carrier/v1/messages/2bce6333-bf5a-4eeb-96e9-4feda49d2d4d" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer TtUTpJlgwaYV6UBpW00Yl2vObeWeeiPeuz1a1vbYUQI"
Endpoint
GET https://api.somleng.org/carrier/v1/messages/:id
GET https://api.somleng.org/carrier/v1/messages/2bce6333-bf5a-4eeb-96e9-4feda49d2d4d
Parameters
None known.
Response
200 OK
{
"data": {
"id": "2bce6333-bf5a-4eeb-96e9-4feda49d2d4d",
"type": "message",
"attributes": {
"created_at": "2026-09-13T08:45:24Z",
"updated_at": "2026-09-13T08:45:24Z",
"to": "+85512334667",
"from": "2442",
"price_unit": null,
"direction": "outbound-api",
"status": "accepted",
"body": "Hello World",
"price": null
},
"relationships": {
"account": {
"data": {
"id": "d7dbde3a-bbe1-4163-9835-d30355d47e9b",
"type": "account"
}
}
}
}
}
Update a message
Request
curl "https://api.somleng.org/carrier/v1/messages/11a0b39a-6d1b-4937-9af0-0994033efd7e" -d '{
"data": {
"id": "11a0b39a-6d1b-4937-9af0-0994033efd7e",
"type": "message",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer vsCH5G-iXTiircayqcVRwy1dTK44kj1mtHOr8628RUM"
Endpoint
PATCH https://api.somleng.org/carrier/v1/messages/:id
PATCH https://api.somleng.org/carrier/v1/messages/11a0b39a-6d1b-4937-9af0-0994033efd7e
Parameters
{
"data": {
"id": "11a0b39a-6d1b-4937-9af0-0994033efd7e",
"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": "11a0b39a-6d1b-4937-9af0-0994033efd7e",
"type": "message",
"attributes": {
"created_at": "2026-09-13T08:45:24Z",
"updated_at": "2026-09-13T08:45:24Z",
"to": "+85512334667",
"from": "2442",
"price_unit": "USD",
"direction": "outbound-api",
"status": "sent",
"body": "Hello World",
"price": "-0.05000"
},
"relationships": {
"account": {
"data": {
"id": "eb99da57-44b3-4099-a0c0-619600d8f250",
"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]=b098c53b-5f4d-47b4-86c1-cc6a0c394352&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Rz5oTjjl9Zo5LTnsza9X-yTBsL45Mn9ZoECA5MSGQ34"
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]=b098c53b-5f4d-47b4-86c1-cc6a0c394352&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "queued",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "b098c53b-5f4d-47b4-86c1-cc6a0c394352",
"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": "535c020f-f917-4ddf-abbe-57aba51c9072",
"type": "phone_call",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2026-09-13T08:45:18Z",
"to": "+85512334667",
"from": "2442",
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued",
"price": null
},
"relationships": {
"account": {
"data": {
"id": "b098c53b-5f4d-47b4-86c1-cc6a0c394352",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=b098c53b-5f4d-47b4-86c1-cc6a0c394352&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=535c020f-f917-4ddf-abbe-57aba51c9072",
"next": null
}
}
Retrieve a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/a3589d9b-18f8-4895-84bd-fbe487b24798" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer jWgquAioWX5T8JRWaqClt5HRG8zw6MHcKO4ExS7y0wY"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_calls/:id
GET https://api.somleng.org/carrier/v1/phone_calls/a3589d9b-18f8-4895-84bd-fbe487b24798
Parameters
None known.
Response
200 OK
{
"data": {
"id": "a3589d9b-18f8-4895-84bd-fbe487b24798",
"type": "phone_call",
"attributes": {
"created_at": "2026-09-13T08:45:18Z",
"updated_at": "2026-09-13T08:45:18Z",
"to": "+85512334667",
"from": "2442",
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued",
"price": null
},
"relationships": {
"account": {
"data": {
"id": "9698ea80-01d9-4b45-8407-0644bedeebf2",
"type": "account"
}
}
}
}
}
Update a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/a00169ab-8162-4a1d-9aa3-b7e330ad4caf" -d '{
"data": {
"id": "a00169ab-8162-4a1d-9aa3-b7e330ad4caf",
"type": "phone_call",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer GlsqVLLVumRXwEpUDZm7O2FTArw5tVVZIhZqnNWILYE"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_calls/:id
PATCH https://api.somleng.org/carrier/v1/phone_calls/a00169ab-8162-4a1d-9aa3-b7e330ad4caf
Parameters
{
"data": {
"id": "a00169ab-8162-4a1d-9aa3-b7e330ad4caf",
"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": "a00169ab-8162-4a1d-9aa3-b7e330ad4caf",
"type": "phone_call",
"attributes": {
"created_at": "2026-09-13T08:45:18Z",
"updated_at": "2026-09-13T08:45:18Z",
"to": "+85512334667",
"from": "2442",
"price_unit": "USD",
"duration": "5",
"direction": "outbound-api",
"status": "completed",
"price": "-0.05000"
},
"relationships": {
"account": {
"data": {
"id": "913496b4-aef9-435e-a846-4142c7d75395",
"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 7OtK3IL64382349RfjAWBjLwaT5PVlesOlXBDVm8l1I"
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": "94b9352b-4819-41a1-a7ab-364d22c23895",
"type": "phone_number",
"attributes": {
"created_at": "2026-09-13T08:45:11Z",
"updated_at": "2026-09-13T08:45:11Z",
"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/8b155a12-65b7-4072-bee2-2bf94ced9472" -d '{
"data": {
"type": "phone_number",
"id": "8b155a12-65b7-4072-bee2-2bf94ced9472",
"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 Qkdp_4GqzndH8rn83Mu99hqPvYIICmRQPhU1yxP26Wk"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id
PATCH https://api.somleng.org/carrier/v1/phone_numbers/8b155a12-65b7-4072-bee2-2bf94ced9472
Parameters
{
"data": {
"type": "phone_number",
"id": "8b155a12-65b7-4072-bee2-2bf94ced9472",
"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": "8b155a12-65b7-4072-bee2-2bf94ced9472",
"type": "phone_number",
"attributes": {
"created_at": "2026-09-13T08:45:10Z",
"updated_at": "2026-09-13T08:45:10Z",
"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/56986b79-2a3e-456a-abd9-eed9431accb0" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer ScDMp9zgY8HnYnygdLnNyVRLK0aBn8rK6nWxsm6jyko"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_numbers/:id
GET https://api.somleng.org/carrier/v1/phone_numbers/56986b79-2a3e-456a-abd9-eed9431accb0
Parameters
None known.
Response
200 OK
{
"data": {
"id": "56986b79-2a3e-456a-abd9-eed9431accb0",
"type": "phone_number",
"attributes": {
"created_at": "2026-09-13T08:45:11Z",
"updated_at": "2026-09-13T08:45:11Z",
"number": "+855972345810",
"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 CacTTx9XMbpU4amo4yPcbTkMimtM5cgVoESnaqCXmQ0"
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": "1f4372a8-033c-466c-84bf-9dcdee91d1f8",
"type": "phone_number",
"attributes": {
"created_at": "2026-09-13T08:45:10Z",
"updated_at": "2026-09-13T08:45:10Z",
"number": "+855972345808",
"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": "8744f46d-734a-4d63-bd7c-b77bc646f7a0",
"type": "phone_number",
"attributes": {
"created_at": "2026-09-13T08:45:10Z",
"updated_at": "2026-09-13T08:45:10Z",
"number": "+855972345807",
"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=1f4372a8-033c-466c-84bf-9dcdee91d1f8",
"next": null
}
}
05. Delete a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/c7fb0580-b5c8-46ab-be03-8b0f140ceac1" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer tw2C_W5y3Bg5H1tjW-sp3dHtJkfOqO-aY21utuSYrhE"
Endpoint
DELETE https://api.somleng.org/carrier/v1/phone_numbers/:id
DELETE https://api.somleng.org/carrier/v1/phone_numbers/c7fb0580-b5c8-46ab-be03-8b0f140ceac1
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 Pt47hZA1AKy9HwyEb64IIrw-AWFFPjbZj8xqCH5tA_8"
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]=2026-09-12&filter[account]=a2079fee-dc01-4554-9504-b0e11e79b0b7&filter[phone_call]=d4ef66a1-0f11-4a13-a58d-f6f70923ff8b" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer aseNJN3cRdBHEt48QYkrB2YixoInuRfQkXOg6zv2PIg"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events
GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2026-09-12&filter[account]=a2079fee-dc01-4554-9504-b0e11e79b0b7&filter[phone_call]=d4ef66a1-0f11-4a13-a58d-f6f70923ff8b
Parameters
{
"filter": {
"from_date": "2026-09-12",
"account": "a2079fee-dc01-4554-9504-b0e11e79b0b7",
"phone_call": "d4ef66a1-0f11-4a13-a58d-f6f70923ff8b"
}
}
| 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": "31ca3414-aeb0-4797-bcff-06cf3f7f900b",
"type": "tts_event",
"attributes": {
"created_at": "2026-09-13T08:44:25Z",
"updated_at": "2026-09-13T08:44:25Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 200
},
"relationships": {
"account": {
"data": {
"id": "a2079fee-dc01-4554-9504-b0e11e79b0b7",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "d4ef66a1-0f11-4a13-a58d-f6f70923ff8b",
"type": "phone_call"
}
}
}
},
{
"id": "b671516d-b4ad-49f5-865e-12f3b80bf2a9",
"type": "tts_event",
"attributes": {
"created_at": "2026-09-13T08:44:25Z",
"updated_at": "2026-09-13T08:44:25Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "a2079fee-dc01-4554-9504-b0e11e79b0b7",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "d4ef66a1-0f11-4a13-a58d-f6f70923ff8b",
"type": "phone_call"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=a2079fee-dc01-4554-9504-b0e11e79b0b7&filter%5Bfrom_date%5D=2026-09-12&filter%5Bphone_call%5D=d4ef66a1-0f11-4a13-a58d-f6f70923ff8b&page%5Bbefore%5D=31ca3414-aeb0-4797-bcff-06cf3f7f900b",
"next": null
}
}
Retrieve a TTS Event
Request
curl "https://api.somleng.org/carrier/v1/tts_events/56bbc8c0-bac3-43a8-bad0-05b6a41f098f" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer EukBWep2r3TH9GUMQOvgvPfJzU11ZT3f19Cmz_L-hNo"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events/:id
GET https://api.somleng.org/carrier/v1/tts_events/56bbc8c0-bac3-43a8-bad0-05b6a41f098f
Parameters
None known.
Response
200 OK
{
"data": {
"id": "56bbc8c0-bac3-43a8-bad0-05b6a41f098f",
"type": "tts_event",
"attributes": {
"created_at": "2026-09-13T08:44:25Z",
"updated_at": "2026-09-13T08:44:25Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "be324ef9-1ccc-4d3f-8029-ecb998d8cf4d",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "e27dd06e-a334-4a95-8a01-f556a53819cc",
"type": "phone_call"
}
}
}
}
}