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 x1SkR2CWFH5jLZd0wsQQyIMihKLMiNScTBr4ReGZY64"
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": "fc540e90-41f3-4d50-97b2-17a3f92c9524",
"type": "account",
"attributes": {
"created_at": "2025-01-16T05:34:23Z",
"updated_at": "2025-01-16T05:34:23Z",
"name": "Rocket Rides",
"metadata": {
"foo": "bar"
},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "Pv-VkzYJ7r9WSADmTnGtEEoecWo84YSEARW6afGF4-E",
"default_tts_voice": "Basic.Kal"
}
}
}
Delete an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/f1b0eef7-3136-48c5-88e5-e26a3938e813" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer IMcLFk9ZfpzKybPa3mEcbyAuEwNI_mbUlv4WoYMYQUA"
Endpoint
DELETE https://api.somleng.org/carrier/v1/accounts/:id
DELETE https://api.somleng.org/carrier/v1/accounts/f1b0eef7-3136-48c5-88e5-e26a3938e813
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 pouSIR3sY_aSS1jsnt9l8NpBmesSZE9YkQau3MUxJAg"
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": "a3cddf23-f636-4940-89fd-c6eb2ad6b3f4",
"type": "account",
"attributes": {
"created_at": "2025-01-16T05:34:22Z",
"updated_at": "2025-01-16T05:34:22Z",
"name": "Telco Net",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "cBmlP_V4CAkpOPkLrIxywK8Ikpg34TtTdhgWie4Zahg",
"default_tts_voice": "Basic.Kal"
}
},
{
"id": "9b0bf1aa-a037-41fb-96a5-fdecc74dd45b",
"type": "account",
"attributes": {
"created_at": "2025-01-16T05:34:22Z",
"updated_at": "2025-01-16T05:34:22Z",
"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=a3cddf23-f636-4940-89fd-c6eb2ad6b3f4",
"next": null
}
}
Retrieve an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/301a1124-f993-49ce-b3d4-fdddf1b0b5d3" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer JOUp_lXiIgw21Qd_tvJntDuJqFM81fY-u1RQ9aVnNEI"
Endpoint
GET https://api.somleng.org/carrier/v1/accounts/:id
GET https://api.somleng.org/carrier/v1/accounts/301a1124-f993-49ce-b3d4-fdddf1b0b5d3
Parameters
Name | Description |
---|---|
id required | The id of the account to be retrieved. |
Response
200 OK
{
"data": {
"id": "301a1124-f993-49ce-b3d4-fdddf1b0b5d3",
"type": "account",
"attributes": {
"created_at": "2025-01-16T05:34:23Z",
"updated_at": "2025-01-16T05:34:23Z",
"name": "Rocket Rides",
"metadata": {},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "OnV-8eAp6ywDLqEcoBO9isgz_7m2oT9x_UBSud6YwJE",
"default_tts_voice": "Basic.Kal"
}
}
}
Update an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/9ae3a6d7-76c3-4720-9651-53c83b4ef7bd" -d '{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "9ae3a6d7-76c3-4720-9651-53c83b4ef7bd"
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 0iFmWuif7hHioHbCvDR72wFVa9E5hcdI92bDW2NqQV8"
Endpoint
PATCH https://api.somleng.org/carrier/v1/accounts/:id
PATCH https://api.somleng.org/carrier/v1/accounts/9ae3a6d7-76c3-4720-9651-53c83b4ef7bd
Parameters
{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"default_tts_voice": "Basic.Kal",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "9ae3a6d7-76c3-4720-9651-53c83b4ef7bd"
}
}
Name | Description |
---|---|
data[attributes][status] | Update the status of the account. One of either enabled or disabled . |
Response
200 OK
{
"data": {
"id": "9ae3a6d7-76c3-4720-9651-53c83b4ef7bd",
"type": "account",
"attributes": {
"created_at": "2025-01-16T05:34:23Z",
"updated_at": "2025-01-16T05:34:23Z",
"name": "Bob Cats",
"metadata": {
"foo": "bar",
"bar": "foo"
},
"status": "disabled",
"type": "carrier_managed",
"auth_token": "Zduw_27B3Ogdt3hqfV2vaTnx49WJvMK2vdf6fLR3ZWY",
"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 xshF6U2xRfJi0rDZgvLx16wBDQVRxiYL75lF7_T7QDs"
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": "90775961-9203-4f9f-99be-c2a72f100221",
"type": "event",
"attributes": {
"created_at": "2025-01-16T05:34:38Z",
"updated_at": "2025-01-16T05:34:38Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "ad080d94-8a9a-40a8-892e-574086908541",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2025-01-16T05:34:38Z",
"price_unit": null,
"updated_at": "2025-01-16T05:34:38Z"
},
"relationships": {
"account": {
"data": {
"id": "639cc70b-0c12-4222-95e0-d358e90ef208",
"type": "account"
}
}
}
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=90775961-9203-4f9f-99be-c2a72f100221",
"next": null
}
}
Retrieve an Event
Request
curl "https://api.somleng.org/carrier/v1/events/349e59de-b46e-4109-ae8c-0218c621ebb7" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer FvbINF7mQErjCRJ44eykJdPZWdfU_PODaaryd9bVEoI"
Endpoint
GET https://api.somleng.org/carrier/v1/events/:id
GET https://api.somleng.org/carrier/v1/events/349e59de-b46e-4109-ae8c-0218c621ebb7
Parameters
None known.
Response
200 OK
{
"data": {
"id": "349e59de-b46e-4109-ae8c-0218c621ebb7",
"type": "event",
"attributes": {
"created_at": "2025-01-16T05:34:37Z",
"updated_at": "2025-01-16T05:34:37Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "6b7d5a00-ae0a-4844-9411-3bc274b6814c",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2025-01-16T05:34:37Z",
"price_unit": null,
"updated_at": "2025-01-16T05:34:37Z"
},
"relationships": {
"account": {
"data": {
"id": "e6aa3696-8577-4509-87e8-e7814ff280cf",
"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]=d9026fce-8bbd-46ae-8522-8d764aa3ea38&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer _kRl86Yh4Q2_YyiDDUJx2gIqjEoCu-SedPZ7GltbId0"
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]=d9026fce-8bbd-46ae-8522-8d764aa3ea38&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "sent",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "d9026fce-8bbd-46ae-8522-8d764aa3ea38",
"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": "15cd84c6-86f0-4d3f-9be4-795a6db2d827",
"type": "message",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2025-01-16T05:34:26Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "d9026fce-8bbd-46ae-8522-8d764aa3ea38",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=d9026fce-8bbd-46ae-8522-8d764aa3ea38&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=15cd84c6-86f0-4d3f-9be4-795a6db2d827",
"next": null
}
}
Retrieve a message
Request
curl "https://api.somleng.org/carrier/v1/messages/5bfd0026-e7fc-4939-9ecb-3680754b86cc" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer gjXnI546Isu9o8hBEKzlAWUtjAN_g5ZIyrEXiwIcZXc"
Endpoint
GET https://api.somleng.org/carrier/v1/messages/:id
GET https://api.somleng.org/carrier/v1/messages/5bfd0026-e7fc-4939-9ecb-3680754b86cc
Parameters
None known.
Response
200 OK
{
"data": {
"id": "5bfd0026-e7fc-4939-9ecb-3680754b86cc",
"type": "message",
"attributes": {
"created_at": "2025-01-16T05:34:26Z",
"updated_at": "2025-01-16T05:34:26Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "accepted",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "4637f34f-69bb-4f64-9c5d-d3dfaee8e367",
"type": "account"
}
}
}
}
}
Update a message
Request
curl "https://api.somleng.org/carrier/v1/messages/b6e4643a-4420-4091-87b3-9e9597ee4f97" -d '{
"data": {
"id": "b6e4643a-4420-4091-87b3-9e9597ee4f97",
"type": "message",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer eB-982sAFGl-s0MYwJXZCZepjN56uXE83rIVmwWkU2s"
Endpoint
PATCH https://api.somleng.org/carrier/v1/messages/:id
PATCH https://api.somleng.org/carrier/v1/messages/b6e4643a-4420-4091-87b3-9e9597ee4f97
Parameters
{
"data": {
"id": "b6e4643a-4420-4091-87b3-9e9597ee4f97",
"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": "b6e4643a-4420-4091-87b3-9e9597ee4f97",
"type": "message",
"attributes": {
"created_at": "2025-01-16T05:34:26Z",
"updated_at": "2025-01-16T05:34:26Z",
"to": "+85512334667",
"from": "2442",
"price": "-0.05",
"price_unit": "USD",
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
},
"relationships": {
"account": {
"data": {
"id": "0d91cf3f-c081-4cd7-8e63-c4374d36b6c7",
"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]=2333595b-0584-440e-9025-8009f921fe41&filter[direction]=outbound-api" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer i9iIEYVte6WSh68QZMI1j-YLOI8REYhpPI_ltRy2tCQ"
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]=2333595b-0584-440e-9025-8009f921fe41&filter[direction]=outbound-api
Parameters
{
"filter": {
"status": "queued",
"from_date": "2021-11-01T00:00:00Z",
"to_date": "2021-11-01T00:00:00Z",
"account": "2333595b-0584-440e-9025-8009f921fe41",
"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": "376c953d-cd55-48d1-b78a-cdb340d32ff8",
"type": "phone_call",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2025-01-16T05:34:27Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
},
"relationships": {
"account": {
"data": {
"id": "2333595b-0584-440e-9025-8009f921fe41",
"type": "account"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=2333595b-0584-440e-9025-8009f921fe41&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=376c953d-cd55-48d1-b78a-cdb340d32ff8",
"next": null
}
}
Retrieve a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/69644f9b-e346-44aa-9559-381c23548701" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer jbSKOLxldxg9pIYvD1iqHDnt7f_F4ZqujA_sLSoq_aE"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_calls/:id
GET https://api.somleng.org/carrier/v1/phone_calls/69644f9b-e346-44aa-9559-381c23548701
Parameters
None known.
Response
200 OK
{
"data": {
"id": "69644f9b-e346-44aa-9559-381c23548701",
"type": "phone_call",
"attributes": {
"created_at": "2025-01-16T05:34:27Z",
"updated_at": "2025-01-16T05:34:27Z",
"to": "+85512334667",
"from": "2442",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
},
"relationships": {
"account": {
"data": {
"id": "f094877c-a7a9-472d-9b19-f52df1e653e5",
"type": "account"
}
}
}
}
}
Update a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/29b25877-084e-4a78-8fb3-494383b24650" -d '{
"data": {
"id": "29b25877-084e-4a78-8fb3-494383b24650",
"type": "phone_call",
"attributes": {
"price": "-0.05"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 0T8RAViGNK20RzJZ0l3fq2p_mmxGSeZJC1qm4_DcG1E"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_calls/:id
PATCH https://api.somleng.org/carrier/v1/phone_calls/29b25877-084e-4a78-8fb3-494383b24650
Parameters
{
"data": {
"id": "29b25877-084e-4a78-8fb3-494383b24650",
"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": "29b25877-084e-4a78-8fb3-494383b24650",
"type": "phone_call",
"attributes": {
"created_at": "2025-01-16T05:34:27Z",
"updated_at": "2025-01-16T05:34:27Z",
"to": "+85512334667",
"from": "2442",
"price": "-0.05",
"price_unit": "USD",
"duration": "5",
"direction": "outbound-api",
"status": "completed"
},
"relationships": {
"account": {
"data": {
"id": "4cc64ef2-a6e3-47ec-af19-189822592232",
"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 AsQlNbbOruBeT05g94QsQrfpNr3Hl4YGcVbmpYpK6tA"
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": "7b6bbb1d-ebf3-4c89-8e67-ed56c05303d0",
"type": "phone_number",
"attributes": {
"created_at": "2025-01-16T05:34:42Z",
"updated_at": "2025-01-16T05:34:42Z",
"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/fda7c080-ef1b-4e2e-85c0-e91157307a32" -d '{
"data": {
"type": "phone_number",
"id": "fda7c080-ef1b-4e2e-85c0-e91157307a32",
"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 tnnhQLjDHDWPjsl0516Y7DDa83aVs1AS7AQFE1AEMPc"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id
PATCH https://api.somleng.org/carrier/v1/phone_numbers/fda7c080-ef1b-4e2e-85c0-e91157307a32
Parameters
{
"data": {
"type": "phone_number",
"id": "fda7c080-ef1b-4e2e-85c0-e91157307a32",
"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": "fda7c080-ef1b-4e2e-85c0-e91157307a32",
"type": "phone_number",
"attributes": {
"created_at": "2025-01-16T05:34:42Z",
"updated_at": "2025-01-16T05:34:42Z",
"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/98aea05b-04f9-465a-b94b-35d152361ef7" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer AIefK2YOV4b93wQnHgtxITDPrXnYi1ord2UUvNmqC_g"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_numbers/:id
GET https://api.somleng.org/carrier/v1/phone_numbers/98aea05b-04f9-465a-b94b-35d152361ef7
Parameters
None known.
Response
200 OK
{
"data": {
"id": "98aea05b-04f9-465a-b94b-35d152361ef7",
"type": "phone_number",
"attributes": {
"created_at": "2025-01-16T05:34:42Z",
"updated_at": "2025-01-16T05:34:42Z",
"number": "+855972345784",
"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 4NOhxG1BP4x7H1nfufIrRvZSqkpdFWFszYJ0Liotmbc"
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": "82d5e979-8e68-4ed2-bd43-5d1bc3f3d956",
"type": "phone_number",
"attributes": {
"created_at": "2025-01-16T05:34:42Z",
"updated_at": "2025-01-16T05:34:42Z",
"number": "+855972345786",
"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": "7e536b96-ca1b-40b3-bcbc-73ec86562460",
"type": "phone_number",
"attributes": {
"created_at": "2025-01-16T05:34:42Z",
"updated_at": "2025-01-16T05:34:42Z",
"number": "+855972345785",
"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=82d5e979-8e68-4ed2-bd43-5d1bc3f3d956",
"next": null
}
}
05. Delete a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/7d9eb72c-01e7-4092-9404-c521dab8de19" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer lZ7cBzXDGC-Idc11DK7zQ5UT_jBGo9_yr20ekRQT1a8"
Endpoint
DELETE https://api.somleng.org/carrier/v1/phone_numbers/:id
DELETE https://api.somleng.org/carrier/v1/phone_numbers/7d9eb72c-01e7-4092-9404-c521dab8de19
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 czyATSGsy-8u-u711CIlignzLUfEly_051gGa_BTnfo"
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-01-15&filter[account]=fa045460-0e86-45f5-a7e7-a6c33650d71e&filter[phone_call]=f39e9716-9fd6-4fad-86d5-633e273ae812" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer HeFtI3JM3i-DbxUMrRx8cqUUs_BFohNmS3v88THb2S0"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events
GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2025-01-15&filter[account]=fa045460-0e86-45f5-a7e7-a6c33650d71e&filter[phone_call]=f39e9716-9fd6-4fad-86d5-633e273ae812
Parameters
{
"filter": {
"from_date": "2025-01-15",
"account": "fa045460-0e86-45f5-a7e7-a6c33650d71e",
"phone_call": "f39e9716-9fd6-4fad-86d5-633e273ae812"
}
}
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": "877223b6-27ee-4410-bbfd-dda7861249fa",
"type": "tts_event",
"attributes": {
"created_at": "2025-01-16T05:34:41Z",
"updated_at": "2025-01-16T05:34:41Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 200
},
"relationships": {
"account": {
"data": {
"id": "fa045460-0e86-45f5-a7e7-a6c33650d71e",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "f39e9716-9fd6-4fad-86d5-633e273ae812",
"type": "phone_call"
}
}
}
},
{
"id": "943ad1e5-27c6-42bf-9f6d-245608d41fa2",
"type": "tts_event",
"attributes": {
"created_at": "2025-01-16T05:34:41Z",
"updated_at": "2025-01-16T05:34:41Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "fa045460-0e86-45f5-a7e7-a6c33650d71e",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "f39e9716-9fd6-4fad-86d5-633e273ae812",
"type": "phone_call"
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=fa045460-0e86-45f5-a7e7-a6c33650d71e&filter%5Bfrom_date%5D=2025-01-15&filter%5Bphone_call%5D=f39e9716-9fd6-4fad-86d5-633e273ae812&page%5Bbefore%5D=877223b6-27ee-4410-bbfd-dda7861249fa",
"next": null
}
}
Retrieve a TTS Event
Request
curl "https://api.somleng.org/carrier/v1/tts_events/b1c76134-0533-40b6-aa14-b8536dde5f56" \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 7pjjUXjKfCsRqd6Fql41PBGSeVCz7l37GfThwRnuuWQ"
Endpoint
GET https://api.somleng.org/carrier/v1/tts_events/:id
GET https://api.somleng.org/carrier/v1/tts_events/b1c76134-0533-40b6-aa14-b8536dde5f56
Parameters
None known.
Response
200 OK
{
"data": {
"id": "b1c76134-0533-40b6-aa14-b8536dde5f56",
"type": "tts_event",
"attributes": {
"created_at": "2025-01-16T05:34:41Z",
"updated_at": "2025-01-16T05:34:41Z",
"voice": "Basic.Kal (Male, en-US)",
"characters": 100
},
"relationships": {
"account": {
"data": {
"id": "09edc0e8-f3d3-4cc8-a14d-756984708fc3",
"type": "account"
}
},
"phone_call": {
"data": {
"id": "82c9b2fc-585d-46ae-b886-3635ac6daa9b",
"type": "phone_call"
}
}
}
}
}