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. Here's 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",
"metadata": {
"foo": "bar"
}
}
}
}' -X POST \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer JS63jqi7GDYySbrjLB5y5zWjOMzw3DPKNA4fVks11NY"
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",
"metadata": {
"foo": "bar"
}
}
}
}
Name | Description |
---|---|
data[attributes][name] required | A friendly name which identifies the account |
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": "f3f45891-cfd5-4525-aa7a-6e2e0762ea6d",
"type": "account",
"attributes": {
"created_at": "2023-03-14T02:21:49Z",
"updated_at": "2023-03-14T02:21:49Z",
"name": "Rocket Rides",
"metadata": {
"foo": "bar"
},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "La78N_EaTTPMbebdVMYQnvSKA4zT4Gy0n2j0X7iyzMo"
}
}
}
Delete an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/39c18049-961e-46a5-b3b5-043a39e58b0c" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Tu7IzmPX2R5QfT8MpenskSdOaZKhg6W62KLjLfQt0B4"
Endpoint
DELETE https://api.somleng.org/carrier/v1/accounts/:id
DELETE https://api.somleng.org/carrier/v1/accounts/39c18049-961e-46a5-b3b5-043a39e58b0c
Parameters
None known.
Response
204 No Content
List all accounts
Request
curl -g "https://api.somleng.org/carrier/v1/accounts" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer SxieItuaflim9ewucljiIkTFwDvHDFaY4zNY1reheuM"
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": "436ca948-b7d7-49be-8881-4a7149fb9d57",
"type": "account",
"attributes": {
"created_at": "2023-03-14T02:21:49Z",
"updated_at": "2023-03-14T02:21:49Z",
"name": "Telco Net",
"metadata": {
},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "3x3wVk_Zo-QcXuJCKdGsT-le3IEl2JdWluvg6F6RYC4"
}
},
{
"id": "ec5ec52e-671f-42bf-bbbf-34531e0075be",
"type": "account",
"attributes": {
"created_at": "2023-03-14T02:21:49Z",
"updated_at": "2023-03-14T02:21:49Z",
"name": "Rocket Rides",
"metadata": {
},
"status": "enabled",
"type": "customer_managed"
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/accounts?page%5Bbefore%5D=436ca948-b7d7-49be-8881-4a7149fb9d57",
"next": null
}
}
Retrieve an account
Request
curl -g "https://api.somleng.org/carrier/v1/accounts/02d1e9e2-ed5e-4db5-9aae-dc016ca6c069" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer jiii9sUAZbuU5YpS-M3cuLlvNOM9B7utA0MX15W-npw"
Endpoint
GET https://api.somleng.org/carrier/v1/accounts/:id
GET https://api.somleng.org/carrier/v1/accounts/02d1e9e2-ed5e-4db5-9aae-dc016ca6c069
Parameters
Name | Description |
---|---|
id required | The id of the account to be retrieved. |
Response
200 OK
{
"data": {
"id": "02d1e9e2-ed5e-4db5-9aae-dc016ca6c069",
"type": "account",
"attributes": {
"created_at": "2023-03-14T02:21:49Z",
"updated_at": "2023-03-14T02:21:49Z",
"name": "Rocket Rides",
"metadata": {
},
"status": "enabled",
"type": "carrier_managed",
"auth_token": "0UdMRxcCBsfRuOSxf7CCOyn0aiCY_SR6lOP9B8zWsgU"
}
}
}
Update an account
Request
curl "https://api.somleng.org/carrier/v1/accounts/1dd0b483-e88d-40f4-a118-ad203edd831d" -d '{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "1dd0b483-e88d-40f4-a118-ad203edd831d"
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Cz86aOtnzJmSI6udH5SZTdvNDepEXoC6wvGRqc0inKo"
Endpoint
PATCH https://api.somleng.org/carrier/v1/accounts/:id
PATCH https://api.somleng.org/carrier/v1/accounts/1dd0b483-e88d-40f4-a118-ad203edd831d
Parameters
{
"data": {
"attributes": {
"status": null,
"name": "Bob Cats",
"status": "disabled",
"metadata": {
"bar": "foo"
}
},
"type": "account",
"id": "1dd0b483-e88d-40f4-a118-ad203edd831d"
}
}
Name | Description |
---|---|
data[attributes][status] | Update the status of the account. One of either enabled or disabled . |
Response
200 OK
{
"data": {
"id": "1dd0b483-e88d-40f4-a118-ad203edd831d",
"type": "account",
"attributes": {
"created_at": "2023-03-14T02:21:49Z",
"updated_at": "2023-03-14T02:21:49Z",
"name": "Bob Cats",
"metadata": {
"foo": "bar",
"bar": "foo"
},
"status": "disabled",
"type": "carrier_managed",
"auth_token": "A_QIs_Nov2_FREbyuYCkVhZNn1gVEiv7_2Ls3lv12UQ"
}
}
}
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 -g "https://api.somleng.org/carrier/v1/events" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 4Cph7TzR6wA87qMjcuMF5FWJbceGu-n3lBfJ7imMCSA"
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": "de5b0d25-c402-44ec-ae5f-a7ad7063b8c3",
"type": "event",
"attributes": {
"created_at": "2023-03-14T02:22:05Z",
"updated_at": "2023-03-14T02:22:05Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "55292e8d-402f-4aeb-9b5b-319a1e8a9dd9",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"sid": "55292e8d-402f-4aeb-9b5b-319a1e8a9dd9",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2023-03-14T02:22:05Z",
"price_unit": null,
"updated_at": "2023-03-14T02:22:05Z",
"account_sid": "b176cccf-8106-4ac3-b7e6-ff0d5a998f7e"
}
}
}
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=de5b0d25-c402-44ec-ae5f-a7ad7063b8c3",
"next": null
}
}
Retrieve an Event
Request
curl -g "https://api.somleng.org/carrier/v1/events/11d2128b-bb63-442f-8067-d12fe8791944" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer mGuwzlWtOxNev4AMfDW1lKQ-XMq3Js8q-eZEj-8_p54"
Endpoint
GET https://api.somleng.org/carrier/v1/events/:id
GET https://api.somleng.org/carrier/v1/events/11d2128b-bb63-442f-8067-d12fe8791944
Parameters
None known.
Response
200 OK
{
"data": {
"id": "11d2128b-bb63-442f-8067-d12fe8791944",
"type": "event",
"attributes": {
"created_at": "2023-03-14T02:22:05Z",
"updated_at": "2023-03-14T02:22:05Z",
"type": "phone_call.completed",
"details": {
"data": {
"id": "fa28c1e6-a5f4-4474-b7f2-2ad3c412a2d4",
"type": "phone_call",
"attributes": {
"to": "+85512334667",
"sid": "fa28c1e6-a5f4-4474-b7f2-2ad3c412a2d4",
"from": "2442",
"price": null,
"status": "queued",
"duration": null,
"direction": "outbound-api",
"created_at": "2023-03-14T02:22:05Z",
"price_unit": null,
"updated_at": "2023-03-14T02:22:05Z",
"account_sid": "2b838561-29ed-4e2a-be53-3fd3caefa83b"
}
}
}
}
}
}
Messages
List messages
Request
curl -g "https://api.somleng.org/carrier/v1/messages?filter[status]=sent&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T11%3A00%3A00Z&filter[account]=8f87279c-871e-4a3f-bdbe-7f4ccd89f33e&filter[direction]=outbound-api" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Jpnn6HafTxKSi6IQFMg2S3Wg5oBVXwzI17rwQ_dYUTQ"
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-01T11%3A00%3A00Z&filter[account]=8f87279c-871e-4a3f-bdbe-7f4ccd89f33e&filter[direction]=outbound-api
Parameters
filter: {"status"=>"sent", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T11:00:00Z", "account"=>"8f87279c-871e-4a3f-bdbe-7f4ccd89f33e", "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 , and outbound-reply |
filter[status] | One of accepted , scheduled , queued , sending , sent , failed , received , canceled , and delivered |
Response
200 OK
{
"data": [
{
"id": "c1775384-9039-45fc-873a-9329500c3888",
"type": "message",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2023-03-14T02:22:00Z",
"to": "+85512334667",
"from": "2442",
"sid": "c1775384-9039-45fc-873a-9329500c3888",
"account_sid": "8f87279c-871e-4a3f-bdbe-7f4ccd89f33e",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=8f87279c-871e-4a3f-bdbe-7f4ccd89f33e&filter%5Bdirection%5D=outbound-api&filter%5Bfrom_date%5D=2021-11-01T00%3A00%3A00Z&filter%5Bstatus%5D=sent&filter%5Bto_date%5D=2021-11-01T11%3A00%3A00Z&page%5Bbefore%5D=c1775384-9039-45fc-873a-9329500c3888",
"next": null
}
}
Retrieve a message
Request
curl -g "https://api.somleng.org/carrier/v1/messages/2c8d8107-fbaf-43a9-a663-9bdc672a3996" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer cjtxRYCJdPsyiOxZadyS5sfgj_WjqhwvHXP6k_-IajY"
Endpoint
GET https://api.somleng.org/carrier/v1/messages/:id
GET https://api.somleng.org/carrier/v1/messages/2c8d8107-fbaf-43a9-a663-9bdc672a3996
Parameters
None known.
Response
200 OK
{
"data": {
"id": "2c8d8107-fbaf-43a9-a663-9bdc672a3996",
"type": "message",
"attributes": {
"created_at": "2023-03-14T02:22:00Z",
"updated_at": "2023-03-14T02:22:00Z",
"to": "+85512334667",
"from": "2442",
"sid": "2c8d8107-fbaf-43a9-a663-9bdc672a3996",
"account_sid": "65e282eb-8403-49a0-ba1e-6f11f2a3fb72",
"price": null,
"price_unit": null,
"direction": "outbound-api",
"status": "accepted",
"body": "Hello World"
}
}
}
Update a message
Request
curl "https://api.somleng.org/carrier/v1/messages/cc76e5bc-63b1-47f1-bfef-b956bbc902da" -d '{
"data": {
"id": "cc76e5bc-63b1-47f1-bfef-b956bbc902da",
"type": "message",
"attributes": {
"price": "-0.05",
"price_unit": "USD"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer t7A3OOmdEgOpjx3hPaF5_Vi1I5KUP2nbd0dQ6YuBam4"
Endpoint
PATCH https://api.somleng.org/carrier/v1/messages/:id
PATCH https://api.somleng.org/carrier/v1/messages/cc76e5bc-63b1-47f1-bfef-b956bbc902da
Parameters
{
"data": {
"id": "cc76e5bc-63b1-47f1-bfef-b956bbc902da",
"type": "message",
"attributes": {
"price": "-0.05",
"price_unit": "USD"
}
}
}
Name | Description |
---|---|
data[attributes][price] | The charge for this message. |
data[attributes][price_unit] | The currency in which price is measured, in ISO 4127 format. (e.g., USD , EUR , JPY ). Always capitalized for messages. |
Response
200 OK
{
"data": {
"id": "cc76e5bc-63b1-47f1-bfef-b956bbc902da",
"type": "message",
"attributes": {
"created_at": "2023-03-14T02:22:00Z",
"updated_at": "2023-03-14T02:22:00Z",
"to": "+85512334667",
"from": "2442",
"sid": "cc76e5bc-63b1-47f1-bfef-b956bbc902da",
"account_sid": "e84926d4-8844-46f1-9cdc-cd2b186c365a",
"price": "-0.05",
"price_unit": "USD",
"direction": "outbound-api",
"status": "sent",
"body": "Hello World"
}
}
}
Phone Calls
List phone calls
Request
curl -g "https://api.somleng.org/carrier/v1/phone_calls?filter[status]=queued&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T11%3A00%3A00Z&filter[account]=8328cf70-f5c8-4d8c-a7b7-e2c00a62fe63&filter[direction]=outbound-api" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer GlaEi4y0j4WLxZ5Uph8kjaZusbN0MaT57LsweyluEuk"
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-01T11%3A00%3A00Z&filter[account]=8328cf70-f5c8-4d8c-a7b7-e2c00a62fe63&filter[direction]=outbound-api
Parameters
filter: {"status"=>"queued", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T11:00:00Z", "account"=>"8328cf70-f5c8-4d8c-a7b7-e2c00a62fe63", "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 and outbound-api |
filter[status] | One of queued , ringing , in-progress , busy , failed , no-answer , completed , and canceled |
Response
200 OK
{
"data": [
{
"id": "c3ce613b-0d96-49a4-b568-fd0dd1c627f7",
"type": "phone_call",
"attributes": {
"created_at": "2021-11-01T01:00:00Z",
"updated_at": "2023-03-14T02:21:55Z",
"to": "+85512334667",
"from": "2442",
"sid": "c3ce613b-0d96-49a4-b568-fd0dd1c627f7",
"account_sid": "8328cf70-f5c8-4d8c-a7b7-e2c00a62fe63",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=8328cf70-f5c8-4d8c-a7b7-e2c00a62fe63&filter%5Bdirection%5D=outbound-api&filter%5Bfrom_date%5D=2021-11-01T00%3A00%3A00Z&filter%5Bstatus%5D=queued&filter%5Bto_date%5D=2021-11-01T11%3A00%3A00Z&page%5Bbefore%5D=c3ce613b-0d96-49a4-b568-fd0dd1c627f7",
"next": null
}
}
Retrieve a phone call
Request
curl -g "https://api.somleng.org/carrier/v1/phone_calls/63ba08af-c2e6-49f4-b8dc-bbddd1d58be3" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer p3rwCO1XiMi9UbapaK0qWQ2ss7wyspvYcdlgbTHdPhg"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_calls/:id
GET https://api.somleng.org/carrier/v1/phone_calls/63ba08af-c2e6-49f4-b8dc-bbddd1d58be3
Parameters
None known.
Response
200 OK
{
"data": {
"id": "63ba08af-c2e6-49f4-b8dc-bbddd1d58be3",
"type": "phone_call",
"attributes": {
"created_at": "2023-03-14T02:21:55Z",
"updated_at": "2023-03-14T02:21:55Z",
"to": "+85512334667",
"from": "2442",
"sid": "63ba08af-c2e6-49f4-b8dc-bbddd1d58be3",
"account_sid": "25e597ca-2b1f-4593-83b1-ab16593aa199",
"price": null,
"price_unit": null,
"duration": null,
"direction": "outbound-api",
"status": "queued"
}
}
}
Update a phone call
Request
curl "https://api.somleng.org/carrier/v1/phone_calls/da3e5a28-1944-467a-8e53-52ebc285febd" -d '{
"data": {
"id": "da3e5a28-1944-467a-8e53-52ebc285febd",
"type": "phone_call",
"attributes": {
"price": "-0.05",
"price_unit": "USD"
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Pi4VRHHRA158HJMoNpuH1Ya2kesstyOpuw7HMda_hBQ"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_calls/:id
PATCH https://api.somleng.org/carrier/v1/phone_calls/da3e5a28-1944-467a-8e53-52ebc285febd
Parameters
{
"data": {
"id": "da3e5a28-1944-467a-8e53-52ebc285febd",
"type": "phone_call",
"attributes": {
"price": "-0.05",
"price_unit": "USD"
}
}
}
Name | Description |
---|---|
data[attributes][price] | The charge for this call. |
data[attributes][price_unit] | The currency in which price is measured, in ISO 4127 format. (e.g., USD , EUR , JPY ). Always capitalized for calls. |
Response
200 OK
{
"data": {
"id": "da3e5a28-1944-467a-8e53-52ebc285febd",
"type": "phone_call",
"attributes": {
"created_at": "2023-03-14T02:21:55Z",
"updated_at": "2023-03-14T02:21:55Z",
"to": "+85512334667",
"from": "2442",
"sid": "da3e5a28-1944-467a-8e53-52ebc285febd",
"account_sid": "48716d0c-06b4-4ed4-b0aa-a212e867101c",
"price": "-0.05",
"price_unit": "USD",
"duration": "5",
"direction": "outbound-api",
"status": "completed"
}
}
}
Phone Numbers
Assign an account to a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/3321219b-9054-418d-99db-1816d7506fec" -d '{
"data": {
"type": "phone_number",
"id": "3321219b-9054-418d-99db-1816d7506fec",
"relationships": {
"account": {
"data": {
"type": "account",
"id": "10346513-e34a-4927-b1df-0f7a3dccbaff"
}
}
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer ePA3IZ61Sbfn4DwYL-ZFI9j2_GCUm22LjUDilC4e-HU"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id
PATCH https://api.somleng.org/carrier/v1/phone_numbers/3321219b-9054-418d-99db-1816d7506fec
Parameters
{
"data": {
"type": "phone_number",
"id": "3321219b-9054-418d-99db-1816d7506fec",
"relationships": {
"account": {
"data": {
"type": "account",
"id": "10346513-e34a-4927-b1df-0f7a3dccbaff"
}
}
}
}
}
Name | Description |
---|---|
data[relationships][account] | The id of the account to associate the phone number with. |
Response
200 OK
{
"data": {
"id": "3321219b-9054-418d-99db-1816d7506fec",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:57Z",
"updated_at": "2023-03-14T02:21:57Z",
"number": "855972345697",
"enabled": true
},
"relationships": {
"account": {
"data": {
"id": "10346513-e34a-4927-b1df-0f7a3dccbaff",
"type": "account"
}
}
}
}
}
Create a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers" -d '{
"data": {
"type": "phone_number",
"attributes": {
"number": "1294"
},
"relationships": {
"account": {
"data": {
"type": "account",
"id": "356d38f5-64d9-4d00-9abe-75106c3580b2"
}
}
}
}
}' -X POST \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer _kl2rQyNhfXzHzTHVcIc7TqoC7PQ9FSBWi5IBZP4Ibw"
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"
},
"relationships": {
"account": {
"data": {
"type": "account",
"id": "356d38f5-64d9-4d00-9abe-75106c3580b2"
}
}
}
}
}
Name | Description |
---|---|
data[attributes][number] required | Phone number or shortcode. |
data[attributes][enabled] | Set to false to disable this number. Disabled phone numbers cannot be used by accounts. Enabled by default. |
data[relationships][account] | The id of the account to associate the phone number with. |
Response
201 Created
{
"data": {
"id": "2b7d39d6-8edc-48c9-86c2-42016ec979ce",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:57Z",
"updated_at": "2023-03-14T02:21:57Z",
"number": "1294",
"enabled": true
},
"relationships": {
"account": {
"data": {
"id": "356d38f5-64d9-4d00-9abe-75106c3580b2",
"type": "account"
}
}
}
}
}
Delete a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/92141a62-2f7a-4880-8023-627d37393400" -d '' -X DELETE \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer du38ovZyyOc8tiQI1cmmuud9o0W66hLOaW61HCUOThA"
Endpoint
DELETE https://api.somleng.org/carrier/v1/phone_numbers/:id
DELETE https://api.somleng.org/carrier/v1/phone_numbers/92141a62-2f7a-4880-8023-627d37393400
Parameters
None known.
Response
204 No Content
List all phone numbers
Request
curl -g "https://api.somleng.org/carrier/v1/phone_numbers" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 4s0xzxC1tnakPFVpFTw4l66qrcq7sZCs18KyeV_PoNE"
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": "48b6280d-f53a-4ab4-a5a5-621ee001f32d",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:57Z",
"updated_at": "2023-03-14T02:21:57Z",
"number": "855972345699",
"enabled": true
},
"relationships": {
}
},
{
"id": "5786b519-0d2b-4cac-b2e6-7515ee7b437b",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:57Z",
"updated_at": "2023-03-14T02:21:57Z",
"number": "855972345698",
"enabled": true
},
"relationships": {
}
}
],
"links": {
"prev": "https://api.somleng.org/carrier/v1/phone_numbers?page%5Bbefore%5D=48b6280d-f53a-4ab4-a5a5-621ee001f32d",
"next": null
}
}
Release a phone number
Releases a phone number by unassigning the account and removing any configuration.
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/5471366f-5af5-4ff3-8f99-90e82d23546a/release" -d '' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer 0l9EUp1t73L4NO9t6PJFvn-rReeq7TnMncbY5E3kLpU"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id/release
PATCH https://api.somleng.org/carrier/v1/phone_numbers/5471366f-5af5-4ff3-8f99-90e82d23546a/release
Parameters
None known.
Response
200 OK
{
"data": {
"id": "5471366f-5af5-4ff3-8f99-90e82d23546a",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:57Z",
"updated_at": "2023-03-14T02:21:57Z",
"number": "855972345701",
"enabled": true
},
"relationships": {
}
}
}
Retrieve a phone number
Request
curl -g "https://api.somleng.org/carrier/v1/phone_numbers/f96a0a2c-9dee-439f-a427-a9500168dcca" -X GET \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer j32LNnDHffAvHHQ2GigUUMYXlzt8ltzQ0UILya1UM_s"
Endpoint
GET https://api.somleng.org/carrier/v1/phone_numbers/:id
GET https://api.somleng.org/carrier/v1/phone_numbers/f96a0a2c-9dee-439f-a427-a9500168dcca
Parameters
None known.
Response
200 OK
{
"data": {
"id": "f96a0a2c-9dee-439f-a427-a9500168dcca",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:57Z",
"updated_at": "2023-03-14T02:21:57Z",
"number": "855972345696",
"enabled": true
},
"relationships": {
}
}
}
Update a phone number
Request
curl "https://api.somleng.org/carrier/v1/phone_numbers/4c395eae-1274-46c0-bec6-0494f9f874df" -d '{
"data": {
"type": "phone_number",
"id": "4c395eae-1274-46c0-bec6-0494f9f874df",
"attributes": {
"enabled": false
}
}
}' -X PATCH \
-H "Content-Type: application/vnd.api+json" \
-H "Authorization: Bearer Za3X0EqFb-ToZep7d-nly4wXX9h-TSlIO7mYIidEYhQ"
Endpoint
PATCH https://api.somleng.org/carrier/v1/phone_numbers/:id
PATCH https://api.somleng.org/carrier/v1/phone_numbers/4c395eae-1274-46c0-bec6-0494f9f874df
Parameters
{
"data": {
"type": "phone_number",
"id": "4c395eae-1274-46c0-bec6-0494f9f874df",
"attributes": {
"enabled": false
}
}
}
Name | Description |
---|---|
data[attributes][enabled] | Set to false to disable the phone number or true to enable it. Disabled phone numbers cannot be used by accounts. |
Response
200 OK
{
"data": {
"id": "4c395eae-1274-46c0-bec6-0494f9f874df",
"type": "phone_number",
"attributes": {
"created_at": "2023-03-14T02:21:56Z",
"updated_at": "2023-03-14T02:21:56Z",
"number": "855972345695",
"enabled": false
},
"relationships": {
}
}
}