NAV
cURL

Carrier API

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

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

Authentication

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

Webhooks

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

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

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

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

Accounts

Create an account

Request

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

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": "f798b956-39af-4c6e-aecd-1a9382eab392",
    "type": "account",
    "attributes": {
      "created_at": "2025-10-25T10:15:14Z",
      "updated_at": "2025-10-25T10:15:14Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "HSwGSuBO7CXgzNEcjr3H8p7EBiXkUZW9I-drS7Rt2xM",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/3017e28c-624b-4467-bf5b-10161130d760" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer WokrCLVfmC7lL0Ea3lf6GQ7ps8y1YeERodxWsUa0ZSM"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/accounts/3017e28c-624b-4467-bf5b-10161130d760

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 UCzACn8caX1_8xFYIilzTgxehNkSqcHHAWyNTZFfBvM"

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": "2e0baf18-5832-4037-afae-9f66da445d52",
      "type": "account",
      "attributes": {
        "created_at": "2025-10-25T10:15:14Z",
        "updated_at": "2025-10-25T10:15:14Z",
        "name": "Telco Net",
        "metadata": {},
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "0ABQOeThpGe5PAd7hh92H8shmDBeQnLG4pwHfdEvl34",
        "default_tts_voice": "Basic.Kal"
      }
    },
    {
      "id": "ae8cc2d6-697d-4e66-9ad1-06d7dcf26dcc",
      "type": "account",
      "attributes": {
        "created_at": "2025-10-25T10:15:14Z",
        "updated_at": "2025-10-25T10:15:14Z",
        "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=2e0baf18-5832-4037-afae-9f66da445d52",
    "next": null
  }
}

Retrieve an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/4563a50a-19de-4713-b649-f4ff98ec7829" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 8yjuWs6MpC46txA-5RPfXL8qzU8hjpkfvOklvXKL47g"

Endpoint

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

GET https://api.somleng.org/carrier/v1/accounts/4563a50a-19de-4713-b649-f4ff98ec7829

Parameters

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

Response


200 OK
{
  "data": {
    "id": "4563a50a-19de-4713-b649-f4ff98ec7829",
    "type": "account",
    "attributes": {
      "created_at": "2025-10-25T10:15:14Z",
      "updated_at": "2025-10-25T10:15:14Z",
      "name": "Rocket Rides",
      "metadata": {},
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "6avdPt4eYSQC8y4J5zg-vo7fMoiDueKewwMzhAOOzQg",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/4273ae88-a8ee-41b8-a6ed-f81ffba6dfb2" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "4273ae88-a8ee-41b8-a6ed-f81ffba6dfb2"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer -GrBJrhp1p2efySYQcabk8_uoM_nrxiJw1JSXXtGi6k"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/accounts/4273ae88-a8ee-41b8-a6ed-f81ffba6dfb2

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "4273ae88-a8ee-41b8-a6ed-f81ffba6dfb2"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "4273ae88-a8ee-41b8-a6ed-f81ffba6dfb2",
    "type": "account",
    "attributes": {
      "created_at": "2025-10-25T10:15:14Z",
      "updated_at": "2025-10-25T10:15:14Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "WV25ifEMaa28_dw2Jcz1mWfa7BV4tumWB6XaH6ZnHC8",
      "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 IQ0uYY_lLWgVytI3AXryn4jVYLGruvuBcXPMPj9AuGo"

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": "d78db412-b545-4370-aea9-63f5869c599d",
      "type": "event",
      "attributes": {
        "created_at": "2025-10-25T10:15:30Z",
        "updated_at": "2025-10-25T10:15:30Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "2c5d39ad-3432-432f-9572-b89fa7f3ff28",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2025-10-25T10:15:30Z",
              "price_unit": null,
              "updated_at": "2025-10-25T10:15:30Z"
            },
            "relationships": {
              "account": {
                "data": {
                  "id": "666781fb-2ec4-45d5-bba7-9c9d8c1d7fa4",
                  "type": "account"
                }
              }
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=d78db412-b545-4370-aea9-63f5869c599d",
    "next": null
  }
}

Retrieve an Event

Request

curl "https://api.somleng.org/carrier/v1/events/f5f960cf-2ee1-45e9-8b87-deb6b7465311" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer pWwWk0uPny2jYqL6U2Odu-fCtoh2xe2_xnaZx0exzM4"

Endpoint

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

GET https://api.somleng.org/carrier/v1/events/f5f960cf-2ee1-45e9-8b87-deb6b7465311

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "f5f960cf-2ee1-45e9-8b87-deb6b7465311",
    "type": "event",
    "attributes": {
      "created_at": "2025-10-25T10:15:30Z",
      "updated_at": "2025-10-25T10:15:30Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "2282bb96-e968-4c54-a99a-6d9bdda98284",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2025-10-25T10:15:30Z",
            "price_unit": null,
            "updated_at": "2025-10-25T10:15:30Z"
          },
          "relationships": {
            "account": {
              "data": {
                "id": "b16ecdb9-5ceb-426d-bfb6-4dbbc244ef59",
                "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]=43a7b1dc-dce3-4f82-bb62-4a13d6275415&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer KdsbKM5gx_Y_UT26pdDhbTyqTw7JpXj3EIrWJDyeKy8"

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]=43a7b1dc-dce3-4f82-bb62-4a13d6275415&filter[direction]=outbound-api

Parameters

{
  "filter": {
    "status": "sent",
    "from_date": "2021-11-01T00:00:00Z",
    "to_date": "2021-11-01T00:00:00Z",
    "account": "43a7b1dc-dce3-4f82-bb62-4a13d6275415",
    "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": "78032698-25a2-4756-96ae-cf64d991022c",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2025-10-25T10:15:08Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "43a7b1dc-dce3-4f82-bb62-4a13d6275415",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=43a7b1dc-dce3-4f82-bb62-4a13d6275415&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=78032698-25a2-4756-96ae-cf64d991022c",
    "next": null
  }
}

Retrieve a message

Request

curl "https://api.somleng.org/carrier/v1/messages/ff374cb8-ae7a-4775-b902-9636fa607303" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer fAbkYGkhYgIHpEnWo91B8vtmj6kvmSue9ets89M962Y"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages/ff374cb8-ae7a-4775-b902-9636fa607303

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "ff374cb8-ae7a-4775-b902-9636fa607303",
    "type": "message",
    "attributes": {
      "created_at": "2025-10-25T10:15:08Z",
      "updated_at": "2025-10-25T10:15:08Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "ff96fb33-50e6-419d-ad79-626877a46537",
          "type": "account"
        }
      }
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/fbabe60a-a862-4811-823e-1a302a4e38b9" -d '{
  "data": {
    "id": "fbabe60a-a862-4811-823e-1a302a4e38b9",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer n51xWcTi5iQUwyDI7AOEAHNDTfGuujpMJOXeIxMdrus"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/messages/fbabe60a-a862-4811-823e-1a302a4e38b9

Parameters

{
  "data": {
    "id": "fbabe60a-a862-4811-823e-1a302a4e38b9",
    "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": "fbabe60a-a862-4811-823e-1a302a4e38b9",
    "type": "message",
    "attributes": {
      "created_at": "2025-10-25T10:15:08Z",
      "updated_at": "2025-10-25T10:15:08Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "696dae5e-0897-449c-a5ad-2d40ca5cb4bc",
          "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]=67db7466-28bd-4259-9988-8f6084818f20&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer WHWWqXlRnsjH3tpREkyro8Qi8Om449B6yOzWrEUnVIY"

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]=67db7466-28bd-4259-9988-8f6084818f20&filter[direction]=outbound-api

Parameters

{
  "filter": {
    "status": "queued",
    "from_date": "2021-11-01T00:00:00Z",
    "to_date": "2021-11-01T00:00:00Z",
    "account": "67db7466-28bd-4259-9988-8f6084818f20",
    "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": "ef59b673-3197-427d-a1e3-ff7e0a7bf5b9",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2025-10-25T10:15:24Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "67db7466-28bd-4259-9988-8f6084818f20",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=67db7466-28bd-4259-9988-8f6084818f20&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=ef59b673-3197-427d-a1e3-ff7e0a7bf5b9",
    "next": null
  }
}

Retrieve a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/89831f26-1e5a-4c32-9ab2-ec89df475367" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer aZzeGP6cTqUvrStuCEYFCx3kt3Jk-InTL6GdixCu0pM"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls/89831f26-1e5a-4c32-9ab2-ec89df475367

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "89831f26-1e5a-4c32-9ab2-ec89df475367",
    "type": "phone_call",
    "attributes": {
      "created_at": "2025-10-25T10:15:24Z",
      "updated_at": "2025-10-25T10:15:24Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "fc043121-e378-4acb-9de8-055c7dc576e3",
          "type": "account"
        }
      }
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/6edf96bc-e8b3-4894-92b0-dcd1bcabbf4a" -d '{
  "data": {
    "id": "6edf96bc-e8b3-4894-92b0-dcd1bcabbf4a",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer V8V4NbvnHhcl_kcpbWW3lId24PYrZgO7tsXItcxDI6s"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_calls/6edf96bc-e8b3-4894-92b0-dcd1bcabbf4a

Parameters

{
  "data": {
    "id": "6edf96bc-e8b3-4894-92b0-dcd1bcabbf4a",
    "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": "6edf96bc-e8b3-4894-92b0-dcd1bcabbf4a",
    "type": "phone_call",
    "attributes": {
      "created_at": "2025-10-25T10:15:24Z",
      "updated_at": "2025-10-25T10:15:24Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "66923f75-dc33-4fd1-8b90-20116d00bed7",
          "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 gojNb-dONXMrxPVh0U60K54y5cTEy6ymhU_6eKJWpX8"

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": "d5d95a6f-0ea2-45d4-94b7-6e97727527b9",
    "type": "phone_number",
    "attributes": {
      "created_at": "2025-10-25T10:14:46Z",
      "updated_at": "2025-10-25T10:14:46Z",
      "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/1ed752f9-d882-4ba4-a744-720d23f47e11" -d '{
  "data": {
    "type": "phone_number",
    "id": "1ed752f9-d882-4ba4-a744-720d23f47e11",
    "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 YJJ00VRoFxpM7jRpnJHkFzqJWxL-m2OF-rw6ElAcBF8"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/1ed752f9-d882-4ba4-a744-720d23f47e11

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "1ed752f9-d882-4ba4-a744-720d23f47e11",
    "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": "1ed752f9-d882-4ba4-a744-720d23f47e11",
    "type": "phone_number",
    "attributes": {
      "created_at": "2025-10-25T10:14:46Z",
      "updated_at": "2025-10-25T10:14:46Z",
      "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/087ce791-c6a2-47ae-bc4d-55829a44bdd6" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer n5bmqCA2CmZ9J5e2G8J09oi07KyeCaGlH8EnRMNZwx0"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_numbers/087ce791-c6a2-47ae-bc4d-55829a44bdd6

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "087ce791-c6a2-47ae-bc4d-55829a44bdd6",
    "type": "phone_number",
    "attributes": {
      "created_at": "2025-10-25T10:14:46Z",
      "updated_at": "2025-10-25T10:14:46Z",
      "number": "+855972345692",
      "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 T0GGImO4uuiBO5Z7_RAhV9kuP48WYY1myAiHd11YZYI"

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": "536ff6dd-fd65-4783-85a0-2a8183fc4e6d",
      "type": "phone_number",
      "attributes": {
        "created_at": "2025-10-25T10:14:46Z",
        "updated_at": "2025-10-25T10:14:46Z",
        "number": "+855972345694",
        "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": "7505e987-f813-4d9f-813d-1203f685f550",
      "type": "phone_number",
      "attributes": {
        "created_at": "2025-10-25T10:14:46Z",
        "updated_at": "2025-10-25T10:14:46Z",
        "number": "+855972345693",
        "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=536ff6dd-fd65-4783-85a0-2a8183fc4e6d",
    "next": null
  }
}

05. Delete a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/507d8e5f-727e-4c39-ac89-6eae2785aacf" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer k-da21ZexNNSTdvDNhQKdhNZP7B0h-PIhVmhIsnqlno"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/phone_numbers/507d8e5f-727e-4c39-ac89-6eae2785aacf

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 WtLNVGKwLBERFRz4H9Vu88Ijky0DWzlcEbetwWvz52I"

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-10-24&filter[account]=00d5661c-3678-43ce-99c4-83f37658d869&filter[phone_call]=d0889c1f-40b1-47af-b908-984f1fda867c" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer vSN4r533MRn6eLhWcqOKtF9QHLwkA7CWU9kwcsI-miI"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2025-10-24&filter[account]=00d5661c-3678-43ce-99c4-83f37658d869&filter[phone_call]=d0889c1f-40b1-47af-b908-984f1fda867c

Parameters

{
  "filter": {
    "from_date": "2025-10-24",
    "account": "00d5661c-3678-43ce-99c4-83f37658d869",
    "phone_call": "d0889c1f-40b1-47af-b908-984f1fda867c"
  }
}
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": "5545471c-5a77-4741-80c7-8ea058b257ff",
      "type": "tts_event",
      "attributes": {
        "created_at": "2025-10-25T10:14:55Z",
        "updated_at": "2025-10-25T10:14:55Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 200
      },
      "relationships": {
        "account": {
          "data": {
            "id": "00d5661c-3678-43ce-99c4-83f37658d869",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "d0889c1f-40b1-47af-b908-984f1fda867c",
            "type": "phone_call"
          }
        }
      }
    },
    {
      "id": "12681032-ac98-4026-abd2-cee55ff6524f",
      "type": "tts_event",
      "attributes": {
        "created_at": "2025-10-25T10:14:55Z",
        "updated_at": "2025-10-25T10:14:55Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 100
      },
      "relationships": {
        "account": {
          "data": {
            "id": "00d5661c-3678-43ce-99c4-83f37658d869",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "d0889c1f-40b1-47af-b908-984f1fda867c",
            "type": "phone_call"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=00d5661c-3678-43ce-99c4-83f37658d869&filter%5Bfrom_date%5D=2025-10-24&filter%5Bphone_call%5D=d0889c1f-40b1-47af-b908-984f1fda867c&page%5Bbefore%5D=5545471c-5a77-4741-80c7-8ea058b257ff",
    "next": null
  }
}

Retrieve a TTS Event

Request

curl "https://api.somleng.org/carrier/v1/tts_events/dc75c3ec-ed6d-4d42-9db0-5dce84f9e447" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Hm13vq5xexkWaRlofdMAxUErCes4QBMEJ6Rq5de2AE4"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events/dc75c3ec-ed6d-4d42-9db0-5dce84f9e447

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "dc75c3ec-ed6d-4d42-9db0-5dce84f9e447",
    "type": "tts_event",
    "attributes": {
      "created_at": "2025-10-25T10:14:55Z",
      "updated_at": "2025-10-25T10:14:55Z",
      "voice": "Basic.Kal (Male, en-US)",
      "characters": 100
    },
    "relationships": {
      "account": {
        "data": {
          "id": "f58be4b9-e79b-4679-b20a-e0fbe241953c",
          "type": "account"
        }
      },
      "phone_call": {
        "data": {
          "id": "799bd137-dcb9-400c-9e99-46e43ed1ae94",
          "type": "phone_call"
        }
      }
    }
  }
}