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 xDIFsfjTqkgGmnFShsPck7DGducICjIhtQmVB2BhEi0"
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": "9aaee422-0dc9-4783-b82f-f930f8ea516e",
"type": "account",
"attributes": {
"created_at": "2025-09-10T11:05:50Z",
"updated_at": "2025-09-10T11:05:50Z",
"name": "Rocket Rides",
"metadata": {
"foo": "bar"
},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "cKY_ueS7P13CTT6Xe-SNiXgKCp1mZWTVxMRKRxlDkhc",
"default_tts_voice": "Basic.Kal"
}
}
}
Delete an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/1128caa9-aaf5-4161-86a2-00a78b3620cf" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer QIemyEdyf5PpBdm-q6kzroFc8cUGB-nHeiXbrpuq4gE"
Endpoint
DELETE https://api.somleng.org/carrier/v1/accounts/:id
DELETE https://api.somleng.org/carrier/v1/accounts/1128caa9-aaf5-4161-86a2-00a78b3620cf
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 X_Xm1XzSTBxV_F3xe5bZEEjS3jtbuHl-tr09y7A5yRE"
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": "c360bad3-4f39-435d-a69b-45a9d1ec9586",
"type": "account",
"attributes": {
"created_at": "2025-09-10T11:05:50Z",
"updated_at": "2025-09-10T11:05:50Z",
"name": "Telco Net",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "TOGlDPea_StmDwIZ-scBK-y_yTXsR4tYlqI-6yRVbII",
"default_tts_voice": "Basic.Kal"
}
},
{
"id": "229eac17-018f-45b9-a759-a0ef557bf13c",
"type": "account",
"attributes": {
"created_at": "2025-09-10T11:05:50Z",
"updated_at": "2025-09-10T11:05:50Z",
"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=c360bad3-4f39-435d-a69b-45a9d1ec9586",
"next": null
}
}
Retrieve an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/a2df7751-61e1-4c25-97bf-df70f67f8efd" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 7uGmuss2mfdLYRWuHNTZTWcLqJhVTHkKwjdkch7E5l8"
Endpoint
GET https://api.somleng.org/carrier/v1/accounts/:id
GET https://api.somleng.org/carrier/v1/accounts/a2df7751-61e1-4c25-97bf-df70f67f8efd
Parameters
Name | Description |
---|---|
id required | The id of the account to be retrieved. |
Response
200 OK
{
"data": {
"id": "a2df7751-61e1-4c25-97bf-df70f67f8efd",
"type": "account",
"attributes": {
"created_at": "2025-09-10T11:05:50Z",
"updated_at": "2025-09-10T11:05:50Z",
"name": "Rocket Rides",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "enV1Syq4Il9h_QU4S63Xgk92PMDpb_Gld1S-NJ3Bxss",
"default_tts_voice": "Basic.Kal"
}
}
}
Update an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/751505e8-df8c-4463-90bd-e7c7b0dc652b" -d '{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "751505e8-df8c-4463-90bd-e7c7b0dc652b"
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer kLUG7qsC26Nqf0uvQzniBV-1rrpiJFguJ_y764rdMI0"
Endpoint
PATCH https://api.somleng.org/carrier/v1/accounts/:id
PATCH https://api.somleng.org/carrier/v1/accounts/751505e8-df8c-4463-90bd-e7c7b0dc652b
Parameters
{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "751505e8-df8c-4463-90bd-e7c7b0dc652b"
}
}
Name | Description |
---|---|
data[attributes][status] | Update the status of the account. One of either enabled or disabled . |
Response
200 OK
{
"data": {
"id": "751505e8-df8c-4463-90bd-e7c7b0dc652b",
"type": "account",
"attributes": {
"created_at": "2025-09-10T11:05:50Z",
"updated_at": "2025-09-10T11:05:50Z",
"name": "Bob Cats",
"metadata": {
"foo": "bar",
"bar": "foo"
},
"status": "disabled",
"type": "carrier_managed",
"auth_token": "Zzkfp5nnv3Jn4-64f_GW1Z6kyHkCUeXjF-9PaH9g90Q",
"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 BphQJR-VfeTW4p5nfx0S8oAQgFMS8B9lAJ0Bu3LVrW8"
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": "13e81113-26ab-4e5a-a731-06da0555d8b7",
"type": "event",
"attributes": {
"created_at": "2025-09-10T11:06:16Z",
"updated_at": "2025-09-10T11:06:16Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "07299df0-a6fb-47bf-963f-ea2848f1f8b7",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2025-09-10T11:06:16Z",
"price_unit": null,
"updated_at": "2025-09-10T11:06:16Z"
},
"relationships": {
"account": {
"data": {
"id": "84b62d49-9a83-4b5d-a13b-a87c867c8dd1",
"type": "account"
}
}
}
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=13e81113-26ab-4e5a-a731-06da0555d8b7",
"next": null
}
}
Retrieve an Event
Request
curl "https://api.somleng.org/carrier/v1/events/48f97c36-f237-477d-89cb-1ec62bccffa3" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer rXRCjX1iLr_aNSs9z6GrfPFCbiYNkqOr_RqDzpwEk6o"
Endpoint
GET https://api.somleng.org/carrier/v1/events/:id
GET https://api.somleng.org/carrier/v1/events/48f97c36-f237-477d-89cb-1ec62bccffa3
Parameters
None known.
Response
200 OK
{
"data": {
"id": "48f97c36-f237-477d-89cb-1ec62bccffa3",
"type": "event",
"attributes": {
"created_at": "2025-09-10T11:06:16Z",
"updated_at": "2025-09-10T11:06:16Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "f2e6e3e6-f682-4166-a820-210f986a074e",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2025-09-10T11:06:16Z",
"price_unit": null,
"updated_at": "2025-09-10T11:06:16Z"
},
"relationships": {
"account": {
"data": {
"id": "1b0bc49c-ecf8-4eed-8586-9769e9a32e60",
"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]=4943241c-21ca-4ebb-b4fd-b9295fc0e554&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer ezabMlsLTr1I67ctsti8-g0HdlT-7-NZo0okUO2bWN0"
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]=4943241c-21ca-4ebb-b4fd-b9295fc0e554&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "sent",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "4943241c-21ca-4ebb-b4fd-b9295fc0e554",
"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": "4ee7cef6-18f4-487b-adb0-bd2d52fadd68",
"type": "message",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2025-09-10T11:05:45Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "4943241c-21ca-4ebb-b4fd-b9295fc0e554",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=4943241c-21ca-4ebb-b4fd-b9295fc0e554&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=4ee7cef6-18f4-487b-adb0-bd2d52fadd68",
"next": null
}
}
Retrieve a message
Request
curl "https://api.somleng.org/carrier/v1/messages/879b20c6-b053-4ca3-ae95-66291b12d982" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer cUyguelXLZxC5zDfZBUOpHAhaBJsfjDORJUkmr3Dphc"
Endpoint
GET https://api.somleng.org/carrier/v1/messages/:id
GET https://api.somleng.org/carrier/v1/messages/879b20c6-b053-4ca3-ae95-66291b12d982
Parameters
None known.
Response
200 OK
{
"data": {
"id": "879b20c6-b053-4ca3-ae95-66291b12d982",
"type": "message",
"attributes": {
"created_at": "2025-09-10T11:05:45Z",
"updated_at": "2025-09-10T11:05:45Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "accepted",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "625cd5d3-c547-45bf-ac16-af23a9ed44da",
"type": "account"
}
}
}
}
}
Update a message
Request
curl "https://api.somleng.org/carrier/v1/messages/ea888782-299b-4b48-ad15-110a0f794da1" -d '{
"data": {
"id": "ea888782-299b-4b48-ad15-110a0f794da1",
"type": "message",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer QdWlmivAzYk-iuB5JDKjoUVh-RgC0nKIx-5cLgjwjKU"
Endpoint
PATCH https://api.somleng.org/carrier/v1/messages/:id
PATCH https://api.somleng.org/carrier/v1/messages/ea888782-299b-4b48-ad15-110a0f794da1
Parameters
{
"data": {
"id": "ea888782-299b-4b48-ad15-110a0f794da1",
"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": "ea888782-299b-4b48-ad15-110a0f794da1",
"type": "message",
"attributes": {
"created_at": "2025-09-10T11:05:45Z",
"updated_at": "2025-09-10T11:05:45Z",
"to": "+85512334667",
"from": "2442",
"price": "-0.05",
"price_unit": "USD",
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "b1a66daf-b99a-4034-bdae-87d8cabfdc22",
"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]=bdfe2779-679c-417b-8908-0f2e0e1eb95a&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer qW3tlkjivwglAEoyhbYJn3moSZVtQmI0TCG2EvkNA9A"
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]=bdfe2779-679c-417b-8908-0f2e0e1eb95a&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "queued",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "bdfe2779-679c-417b-8908-0f2e0e1eb95a",
"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": "231fe518-680d-4a93-90b5-4092af0a9cab",
"type": "phone_call",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2025-09-10T11:05:10Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
},
"relationships": {
"account": {
"data": {
"id": "bdfe2779-679c-417b-8908-0f2e0e1eb95a",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=bdfe2779-679c-417b-8908-0f2e0e1eb95a&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=231fe518-680d-4a93-90b5-4092af0a9cab",
"next": null
}
}
Retrieve a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/ef538bac-3466-40a5-af64-d57bb948a4d3" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer QkEz4glPkt1X9TdGR4F-gg9vy5ZRg8qSamD8L3ZoNhc"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_calls/:id
GET https://api.somleng.org/carrier/v1/phone_calls/ef538bac-3466-40a5-af64-d57bb948a4d3
Parameters
None known.
Response
200 OK
{
"data": {
"id": "ef538bac-3466-40a5-af64-d57bb948a4d3",
"type": "phone_call",
"attributes": {
"created_at": "2025-09-10T11:05:10Z",
"updated_at": "2025-09-10T11:05:10Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
},
"relationships": {
"account": {
"data": {
"id": "e792be63-10ed-4437-8de5-011efb6d3ee7",
"type": "account"
}
}
}
}
}
Update a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/2e409ee0-aa91-4a74-8c77-ffb8d6ee4166" -d '{
"data": {
"id": "2e409ee0-aa91-4a74-8c77-ffb8d6ee4166",
"type": "phone_call",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer iJbubdkwxtp1pdrwcYcCXfNJ9GJgpq-vJXTglrAdVlc"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_calls/:id
PATCH https://api.somleng.org/carrier/v1/phone_calls/2e409ee0-aa91-4a74-8c77-ffb8d6ee4166
Parameters
{
"data": {
"id": "2e409ee0-aa91-4a74-8c77-ffb8d6ee4166",
"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": "2e409ee0-aa91-4a74-8c77-ffb8d6ee4166",
"type": "phone_call",
"attributes": {
"created_at": "2025-09-10T11:05:10Z",
"updated_at": "2025-09-10T11:05:10Z",
"to": "+85512334667",
"from": "2442",
"price": "-0.05",
"price_unit": "USD",
"duration": "5",
"direction": "outbound-api",
"status": "completed"
},
"relationships": {
"account": {
"data": {
"id": "4d03c684-aed6-4652-a7cc-f8b6a66ddccc",
"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 xLnwPIOrFkT1B3j8Kp24m358_Bz3-iDbP_WQNZ5jSYY"
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": "7b743367-6845-46e1-ad0e-ebf0943a6512",
"type": "phone_number",
"attributes": {
"created_at": "2025-09-10T11:05:10Z",
"updated_at": "2025-09-10T11:05:10Z",
"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/71a3d5cf-f350-4eb1-b58a-a9970bb59edd" -d '{
"data": {
"type": "phone_number",
"id": "71a3d5cf-f350-4eb1-b58a-a9970bb59edd",
"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 fG1A9H8W2ChBNKAEEYncxj72gtAivUvo9cn6rqKp84g"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id
PATCH https://api.somleng.org/carrier/v1/phone_numbers/71a3d5cf-f350-4eb1-b58a-a9970bb59edd
Parameters
{
"data": {
"type": "phone_number",
"id": "71a3d5cf-f350-4eb1-b58a-a9970bb59edd",
"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": "71a3d5cf-f350-4eb1-b58a-a9970bb59edd",
"type": "phone_number",
"attributes": {
"created_at": "2025-09-10T11:05:09Z",
"updated_at": "2025-09-10T11:05: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/d9bf76a4-46bd-47dc-b416-84ee417363e1" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer K79Lbai6L6rTsQjy8NC7W1YquKcfFxG1aZz54cCnpd4"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_numbers/:id
GET https://api.somleng.org/carrier/v1/phone_numbers/d9bf76a4-46bd-47dc-b416-84ee417363e1
Parameters
None known.
Response
200 OK
{
"data": {
"id": "d9bf76a4-46bd-47dc-b416-84ee417363e1",
"type": "phone_number",
"attributes": {
"created_at": "2025-09-10T11:05:09Z",
"updated_at": "2025-09-10T11:05:09Z",
"number": "+855972345712",
"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 MvsgAhTxwrtwdEycur8QMZi-PdHGgSGn9m6e70zWiuk"
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": "a23b3f45-be3c-4703-8db8-1427d564f408",
"type": "phone_number",
"attributes": {
"created_at": "2025-09-10T11:05:10Z",
"updated_at": "2025-09-10T11:05:10Z",
"number": "+855972345715",
"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": "7219b4e3-3a10-4807-ab4f-fa2ededac2a8",
"type": "phone_number",
"attributes": {
"created_at": "2025-09-10T11:05:10Z",
"updated_at": "2025-09-10T11:05:10Z",
"number": "+855972345714",
"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=a23b3f45-be3c-4703-8db8-1427d564f408",
"next": null
}
}
05. Delete a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/ec109441-af12-4162-a513-acdb731a4fef" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer PnHSXkZV5mAmjno-JHwMKLP2b5pF722W7mARW55bY-k"
Endpoint
DELETE https://api.somleng.org/carrier/v1/phone_numbers/:id
DELETE https://api.somleng.org/carrier/v1/phone_numbers/ec109441-af12-4162-a513-acdb731a4fef
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 O2QohgBjry2v3i00oZUiXIxZEuvKXItCjaT1HrMxg8s"
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-09-09&filter[account]=8aca0e4c-28c1-40b7-a3e4-2b82ccc3821a&filter[phone_call]=059dba41-2588-4305-aa91-bd47f8f899a3" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 3WO0WK8vYdxbmZUTiJpqXSF1FQWRAZDJfhgH0qZXXZI"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events
GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2025-09-09&filter[account]=8aca0e4c-28c1-40b7-a3e4-2b82ccc3821a&filter[phone_call]=059dba41-2588-4305-aa91-bd47f8f899a3
Parameters
{
"filter": {
"from_date": "2025-09-09",
"account": "8aca0e4c-28c1-40b7-a3e4-2b82ccc3821a",
"phone_call": "059dba41-2588-4305-aa91-bd47f8f899a3"
}
}
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": "808a8eb4-d8bf-4a19-805f-842454a13feb",
"type": "tts_event",
"attributes": {
"created_at": "2025-09-10T11:06:07Z",
"updated_at": "2025-09-10T11:06:07Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 200
},
"relationships": {
"account": {
"data": {
"id": "8aca0e4c-28c1-40b7-a3e4-2b82ccc3821a",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "059dba41-2588-4305-aa91-bd47f8f899a3",
"type": "phone_call"
}
}
}
},
{
"id": "35bb1814-52f4-497d-bcc9-138ebd99cf9a",
"type": "tts_event",
"attributes": {
"created_at": "2025-09-10T11:06:07Z",
"updated_at": "2025-09-10T11:06:07Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "8aca0e4c-28c1-40b7-a3e4-2b82ccc3821a",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "059dba41-2588-4305-aa91-bd47f8f899a3",
"type": "phone_call"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=8aca0e4c-28c1-40b7-a3e4-2b82ccc3821a&filter%5Bfrom_date%5D=2025-09-09&filter%5Bphone_call%5D=059dba41-2588-4305-aa91-bd47f8f899a3&page%5Bbefore%5D=808a8eb4-d8bf-4a19-805f-842454a13feb",
"next": null
}
}
Retrieve a TTS Event
Request
curl "https://api.somleng.org/carrier/v1/tts_events/9823bf92-be64-4954-878e-eff6b8fd4da9" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer -SgZ-pD09s6tiPUqHxD02f83ad-JySryHFBr7PNMs_Y"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events/:id
GET https://api.somleng.org/carrier/v1/tts_events/9823bf92-be64-4954-878e-eff6b8fd4da9
Parameters
None known.
Response
200 OK
{
"data": {
"id": "9823bf92-be64-4954-878e-eff6b8fd4da9",
"type": "tts_event",
"attributes": {
"created_at": "2025-09-10T11:06:07Z",
"updated_at": "2025-09-10T11:06:07Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "373881b9-11d9-4175-901c-bb5d9dc7eeea",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "48630527-45b4-41f3-8ae5-784394251958",
"type": "phone_call"
}
}
}
}
}