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 oTVOWwZz9VZGDjc2Uz91vzZGn5l3wzNJlTubJCNo0x0"
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": "be4f914c-3825-49aa-8c60-5a19b4c188e0",
"type": "account",
"attributes": {
"created_at": "2026-01-13T07:36:30Z",
"updated_at": "2026-01-13T07:36:30Z",
"name": "Rocket Rides",
"metadata": {
"foo": "bar"
},
"status": "enabled",
"type": "carrier_managed",
"billing_enabled": true,
"billing_mode": "prepaid",
"auth_token": "gIlHX8nFcDspzk5xPWJUuNnKLmBRH4CCuIIYC2gCo5I",
"default_tts_voice": "Basic.Kal"
}
}
}
Delete an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/d9f3f973-2063-4da0-b475-3bfed71a31ce" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer v5BoCwEseR1cmNInL94dZbLrLuuki7pjungzatsjvH0"
Endpoint
DELETE https://api.somleng.org/carrier/v1/accounts/:id
DELETE https://api.somleng.org/carrier/v1/accounts/d9f3f973-2063-4da0-b475-3bfed71a31ce
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 SYjRbszbTZKS-UhNIH4LuF_hIuw4xCnmqWvuRw9ZdBY"
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": "623808c8-fef4-434b-9047-cb5851c36d02",
"type": "account",
"attributes": {
"created_at": "2026-01-13T07:36:30Z",
"updated_at": "2026-01-13T07:36:30Z",
"name": "Telco Net",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"auth_token": "M8DmdUJEp04_46CGWSzEsoTJJgu01FyY6RIVzngW-W8",
"default_tts_voice": "Basic.Kal"
}
},
{
"id": "dad00f2c-1a4a-48d9-a037-86caf54f7051",
"type": "account",
"attributes": {
"created_at": "2026-01-13T07:36:30Z",
"updated_at": "2026-01-13T07:36:30Z",
"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=623808c8-fef4-434b-9047-cb5851c36d02",
"next": null
}
}
Retrieve an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/dc2b9350-11b7-41c8-9e50-b61f0703bd37" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer eomwuG5x_VOFaEi2SjkGd-WDxBfNAQAnMISTZ9AdhHo"
Endpoint
GET https://api.somleng.org/carrier/v1/accounts/:id
GET https://api.somleng.org/carrier/v1/accounts/dc2b9350-11b7-41c8-9e50-b61f0703bd37
Parameters
| Name | Description |
|---|---|
| id required | The id of the account to be retrieved. |
Response
200 OK
{
"data": {
"id": "dc2b9350-11b7-41c8-9e50-b61f0703bd37",
"type": "account",
"attributes": {
"created_at": "2026-01-13T07:36:30Z",
"updated_at": "2026-01-13T07:36:30Z",
"name": "Rocket Rides",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"auth_token": "NTq9Avw7ZdOGIcAk-uGZQqP9yb8jV1Q8e1yYT4v9w6w",
"default_tts_voice": "Basic.Kal"
}
}
}
Update an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/be578c95-6e1c-404c-b392-2b1f7ea4e95d" -d '{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"billing_enabled": false,
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "be578c95-6e1c-404c-b392-2b1f7ea4e95d"
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer nJkZhJm-Ur-S7C559x98LnSmrM6IkGS1yb4DCOud2Wo"
Endpoint
PATCH https://api.somleng.org/carrier/v1/accounts/:id
PATCH https://api.somleng.org/carrier/v1/accounts/be578c95-6e1c-404c-b392-2b1f7ea4e95d
Parameters
{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"billing_enabled": false,
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "be578c95-6e1c-404c-b392-2b1f7ea4e95d"
}
}
| Name | Description |
|---|---|
| data[attributes][status] | Update the status of the account. One of either enabled or disabled. |
Response
200 OK
{
"data": {
"id": "be578c95-6e1c-404c-b392-2b1f7ea4e95d",
"type": "account",
"attributes": {
"created_at": "2026-01-13T07:36:29Z",
"updated_at": "2026-01-13T07:36:29Z",
"name": "Bob Cats",
"metadata": {
"foo": "bar",
"bar": "foo"
},
"status": "disabled",
"type": "carrier_managed",
"billing_enabled": false,
"billing_mode": "prepaid",
"auth_token": "jT5OTTpmwXK2VoSjKaGO4QK6V0k4jxOlZNwzapmeReY",
"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 SJknQpa4n8GQCbgTboCR2lb53z0hJnxTv1aRH1oMyac"
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": "75aae61f-3373-4a55-9638-8d682354792d",
"type": "event",
"attributes": {
"created_at": "2026-01-13T07:35:16Z",
"updated_at": "2026-01-13T07:35:16Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "25aab78d-c7e9-4193-8a38-586f7cd1eb25",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2026-01-13T07:35:16Z",
"price_unit": null,
"updated_at": "2026-01-13T07:35:16Z"
},
"relationships": {
"account": {
"data": {
"id": "ca6991ff-afb5-418b-b759-bab27039d8a1",
"type": "account"
}
}
}
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=75aae61f-3373-4a55-9638-8d682354792d",
"next": null
}
}
Retrieve an Event
Request
curl "https://api.somleng.org/carrier/v1/events/87fda2e7-4160-407f-abce-8bab4ecda73e" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer _KD_L8mOZsK0En3AnEJZBOf5Yn2qtEGZIhw8nazuDBw"
Endpoint
GET https://api.somleng.org/carrier/v1/events/:id
GET https://api.somleng.org/carrier/v1/events/87fda2e7-4160-407f-abce-8bab4ecda73e
Parameters
None known.
Response
200 OK
{
"data": {
"id": "87fda2e7-4160-407f-abce-8bab4ecda73e",
"type": "event",
"attributes": {
"created_at": "2026-01-13T07:35:16Z",
"updated_at": "2026-01-13T07:35:16Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "2d80af03-1ad0-4e67-a27f-1e56e0ec2366",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2026-01-13T07:35:16Z",
"price_unit": null,
"updated_at": "2026-01-13T07:35:16Z"
},
"relationships": {
"account": {
"data": {
"id": "6017400c-a78a-4ba0-b353-169de4f40d2c",
"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]=2c7b20ce-fdf0-4fa3-ac2a-120eec9ff90b&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer e6-mwLOmHQt0XdQfLBTzBkfDbp45_yuSnDVTQziIii8"
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]=2c7b20ce-fdf0-4fa3-ac2a-120eec9ff90b&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "sent",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "2c7b20ce-fdf0-4fa3-ac2a-120eec9ff90b",
"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": "ec22c962-f9dc-46e4-980a-7d50373758f3",
"type": "message",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2026-01-13T07:35:40Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "2c7b20ce-fdf0-4fa3-ac2a-120eec9ff90b",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=2c7b20ce-fdf0-4fa3-ac2a-120eec9ff90b&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=ec22c962-f9dc-46e4-980a-7d50373758f3",
"next": null
}
}
Retrieve a message
Request
curl "https://api.somleng.org/carrier/v1/messages/62cd0c5c-dd6b-4cc8-b897-d5f98b4a14e2" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer BbxNeuJWV06WplaG4ULsEtzA8psPCGA1OwGFRJ4HlYY"
Endpoint
GET https://api.somleng.org/carrier/v1/messages/:id
GET https://api.somleng.org/carrier/v1/messages/62cd0c5c-dd6b-4cc8-b897-d5f98b4a14e2
Parameters
None known.
Response
200 OK
{
"data": {
"id": "62cd0c5c-dd6b-4cc8-b897-d5f98b4a14e2",
"type": "message",
"attributes": {
"created_at": "2026-01-13T07:35:39Z",
"updated_at": "2026-01-13T07:35:39Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "accepted",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "a6e33c9f-675a-4611-9914-1e3e56604441",
"type": "account"
}
}
}
}
}
Update a message
Request
curl "https://api.somleng.org/carrier/v1/messages/f8cc99bb-0d70-4fce-9479-b45cbacab20d" -d '{
"data": {
"id": "f8cc99bb-0d70-4fce-9479-b45cbacab20d",
"type": "message",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer MsrFZyZ4Tx1hcs3d9GDuQ37vOqCvaSJhRdNnGYu4UfI"
Endpoint
PATCH https://api.somleng.org/carrier/v1/messages/:id
PATCH https://api.somleng.org/carrier/v1/messages/f8cc99bb-0d70-4fce-9479-b45cbacab20d
Parameters
{
"data": {
"id": "f8cc99bb-0d70-4fce-9479-b45cbacab20d",
"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": "f8cc99bb-0d70-4fce-9479-b45cbacab20d",
"type": "message",
"attributes": {
"created_at": "2026-01-13T07:35:39Z",
"updated_at": "2026-01-13T07:35:39Z",
"to": "+85512334667",
"from": "2442",
"price": "-0.05",
"price_unit": "USD",
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "1fee3184-33a5-4c36-b43c-5b91161740c6",
"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]=0f9ab087-6c19-41be-8a8d-45e6c99b2088&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Qjf9ehdROvHCsbRfQpoLyldtQ1x_UPcCZ4XfbWxx7YA"
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]=0f9ab087-6c19-41be-8a8d-45e6c99b2088&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "queued",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "0f9ab087-6c19-41be-8a8d-45e6c99b2088",
"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": "7ecaca6b-2b46-4649-af75-1266082df8aa",
"type": "phone_call",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2026-01-13T07:36:16Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
},
"relationships": {
"account": {
"data": {
"id": "0f9ab087-6c19-41be-8a8d-45e6c99b2088",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=0f9ab087-6c19-41be-8a8d-45e6c99b2088&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=7ecaca6b-2b46-4649-af75-1266082df8aa",
"next": null
}
}
Retrieve a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/1ee79c80-a5ff-4112-bfd8-a8fd3f9d85dc" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer PUV1vB2zFBgaWt1c8-olSjSuXFcDJTdvxAULi_kBnUQ"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_calls/:id
GET https://api.somleng.org/carrier/v1/phone_calls/1ee79c80-a5ff-4112-bfd8-a8fd3f9d85dc
Parameters
None known.
Response
200 OK
{
"data": {
"id": "1ee79c80-a5ff-4112-bfd8-a8fd3f9d85dc",
"type": "phone_call",
"attributes": {
"created_at": "2026-01-13T07:36:16Z",
"updated_at": "2026-01-13T07:36:16Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
},
"relationships": {
"account": {
"data": {
"id": "98ef9c44-d830-4933-a7dc-14681df769b5",
"type": "account"
}
}
}
}
}
Update a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/9da83e89-022e-405c-aa2c-a6fd14718978" -d '{
"data": {
"id": "9da83e89-022e-405c-aa2c-a6fd14718978",
"type": "phone_call",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer aOMuRhrezKcJse3J789PyEaO0vGwW6H9do_OMwQ667M"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_calls/:id
PATCH https://api.somleng.org/carrier/v1/phone_calls/9da83e89-022e-405c-aa2c-a6fd14718978
Parameters
{
"data": {
"id": "9da83e89-022e-405c-aa2c-a6fd14718978",
"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": "9da83e89-022e-405c-aa2c-a6fd14718978",
"type": "phone_call",
"attributes": {
"created_at": "2026-01-13T07:36:16Z",
"updated_at": "2026-01-13T07:36:16Z",
"to": "+85512334667",
"from": "2442",
"price": "-0.05",
"price_unit": "USD",
"duration": "5",
"direction": "outbound-api",
"status": "completed"
},
"relationships": {
"account": {
"data": {
"id": "0237c6a1-e3dc-4886-aff8-439369335176",
"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 O75q5qVDceJyoyb66Kd_w8Aupsby7zSn1MX3kEVzIls"
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": "285adb57-db7d-4dc7-b14e-8922acea881e",
"type": "phone_number",
"attributes": {
"created_at": "2026-01-13T07:36:13Z",
"updated_at": "2026-01-13T07:36:13Z",
"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/ea037859-1eeb-4da2-b1b6-ab840eceab61" -d '{
"data": {
"type": "phone_number",
"id": "ea037859-1eeb-4da2-b1b6-ab840eceab61",
"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 ALo6tJNbCt3IWz0ziPz0lSqK-0NIqztJ6ar96JyAayo"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id
PATCH https://api.somleng.org/carrier/v1/phone_numbers/ea037859-1eeb-4da2-b1b6-ab840eceab61
Parameters
{
"data": {
"type": "phone_number",
"id": "ea037859-1eeb-4da2-b1b6-ab840eceab61",
"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": "ea037859-1eeb-4da2-b1b6-ab840eceab61",
"type": "phone_number",
"attributes": {
"created_at": "2026-01-13T07:36:13Z",
"updated_at": "2026-01-13T07:36:13Z",
"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/015c91d6-645f-43d4-9c18-16af508c0ea2" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer EHrZWFG21CHX-8XN1UNDsVPNcDtR4rWCoNr3u55hsUY"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_numbers/:id
GET https://api.somleng.org/carrier/v1/phone_numbers/015c91d6-645f-43d4-9c18-16af508c0ea2
Parameters
None known.
Response
200 OK
{
"data": {
"id": "015c91d6-645f-43d4-9c18-16af508c0ea2",
"type": "phone_number",
"attributes": {
"created_at": "2026-01-13T07:36:13Z",
"updated_at": "2026-01-13T07:36:13Z",
"number": "+855972345806",
"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 jvisul9wxxiadR4qrt3TiD6Zgs7kLFylPWJ1uUerbeo"
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": "4947f735-61ff-480e-a499-cfbce06b30a7",
"type": "phone_number",
"attributes": {
"created_at": "2026-01-13T07:36:13Z",
"updated_at": "2026-01-13T07:36:13Z",
"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": "454b62cd-f441-4aed-855f-249ed10f07b9",
"type": "phone_number",
"attributes": {
"created_at": "2026-01-13T07:36:13Z",
"updated_at": "2026-01-13T07:36:13Z",
"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=4947f735-61ff-480e-a499-cfbce06b30a7",
"next": null
}
}
05. Delete a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/e069d984-901f-4d8a-a305-cf6e082bab42" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer ckYuEsJJL4fN1CxaniiybazUoWR1rwgxHg0K-K54GG8"
Endpoint
DELETE https://api.somleng.org/carrier/v1/phone_numbers/:id
DELETE https://api.somleng.org/carrier/v1/phone_numbers/e069d984-901f-4d8a-a305-cf6e082bab42
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 rSTcbM76ivjMH6lhkz1tZ-i39cU0W0mbHyovg8-5W48"
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-01-12&filter[account]=1dab7c89-0ff7-490a-9c67-48dfcd93aac8&filter[phone_call]=68fe37d9-d6b0-48d8-aebc-fb7df585dedd" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer laxdV2qVxyM6wHTbFUV6KWoPi8U600qQWrAwj7Vw9RA"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events
GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2026-01-12&filter[account]=1dab7c89-0ff7-490a-9c67-48dfcd93aac8&filter[phone_call]=68fe37d9-d6b0-48d8-aebc-fb7df585dedd
Parameters
{
"filter": {
"from_date": "2026-01-12",
"account": "1dab7c89-0ff7-490a-9c67-48dfcd93aac8",
"phone_call": "68fe37d9-d6b0-48d8-aebc-fb7df585dedd"
}
}
| 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": "31f595ad-c491-4e81-9c01-18ebe807186a",
"type": "tts_event",
"attributes": {
"created_at": "2026-01-13T07:36:07Z",
"updated_at": "2026-01-13T07:36:07Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 200
},
"relationships": {
"account": {
"data": {
"id": "1dab7c89-0ff7-490a-9c67-48dfcd93aac8",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "68fe37d9-d6b0-48d8-aebc-fb7df585dedd",
"type": "phone_call"
}
}
}
},
{
"id": "7884ba69-abf2-44fb-bd36-150875c3b629",
"type": "tts_event",
"attributes": {
"created_at": "2026-01-13T07:36:07Z",
"updated_at": "2026-01-13T07:36:07Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "1dab7c89-0ff7-490a-9c67-48dfcd93aac8",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "68fe37d9-d6b0-48d8-aebc-fb7df585dedd",
"type": "phone_call"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=1dab7c89-0ff7-490a-9c67-48dfcd93aac8&filter%5Bfrom_date%5D=2026-01-12&filter%5Bphone_call%5D=68fe37d9-d6b0-48d8-aebc-fb7df585dedd&page%5Bbefore%5D=31f595ad-c491-4e81-9c01-18ebe807186a",
"next": null
}
}
Retrieve a TTS Event
Request
curl "https://api.somleng.org/carrier/v1/tts_events/380605f1-7ef4-4f40-8ee2-bdda678b5ec4" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer cDP00a40GNic9O_lWv5nUTbB1t4Qjgp5oE0wJsFfGmw"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events/:id
GET https://api.somleng.org/carrier/v1/tts_events/380605f1-7ef4-4f40-8ee2-bdda678b5ec4
Parameters
None known.
Response
200 OK
{
"data": {
"id": "380605f1-7ef4-4f40-8ee2-bdda678b5ec4",
"type": "tts_event",
"attributes": {
"created_at": "2026-01-13T07:36:07Z",
"updated_at": "2026-01-13T07:36:07Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "85711c6b-4a4e-4a04-ba59-2bcb1be2e14f",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "0ab34f07-9ca1-464d-b094-7c5bd620d3e2",
"type": "phone_call"
}
}
}
}
}