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

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": "0a08f07f-d501-42ae-89b9-81a3c57c8577",
    "type": "account",
    "attributes": {
      "created_at": "2024-12-16T00:58:40Z",
      "updated_at": "2024-12-16T00:58:40Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "GK-O2ThtvoAhtPlPR12AVTbXoXohYjbnUGduEE2EDbo",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/76afc54b-f563-4df1-a9be-b1a23c62be97" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer qpSV-nDn9pS3IenE9o9ymQk3dMcRVlMR3vgIa17qhv4"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/accounts/76afc54b-f563-4df1-a9be-b1a23c62be97

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

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": "04bd826a-5964-4862-aa8c-68cd52381ec2",
      "type": "account",
      "attributes": {
        "created_at": "2024-12-16T00:58:40Z",
        "updated_at": "2024-12-16T00:58:40Z",
        "name": "Telco Net",
        "metadata": {},
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "SQfA8UgV-_XKQdqvXeolnPRa_IyAf8mw2kdTjiVK33Q",
        "default_tts_voice": "Basic.Kal"
      }
    },
    {
      "id": "28714e31-012f-4b1b-83f1-43145a40cfcd",
      "type": "account",
      "attributes": {
        "created_at": "2024-12-16T00:58:40Z",
        "updated_at": "2024-12-16T00:58:40Z",
        "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=04bd826a-5964-4862-aa8c-68cd52381ec2",
    "next": null
  }
}

Retrieve an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/10ea7365-8f59-470c-b546-6d83c01e3332" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer tza8b7jfSuH61DF0aaYf4D0NbHbJbnUlxfr-rQ1kJ1c"

Endpoint

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

GET https://api.somleng.org/carrier/v1/accounts/10ea7365-8f59-470c-b546-6d83c01e3332

Parameters

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

Response


200 OK
{
  "data": {
    "id": "10ea7365-8f59-470c-b546-6d83c01e3332",
    "type": "account",
    "attributes": {
      "created_at": "2024-12-16T00:58:40Z",
      "updated_at": "2024-12-16T00:58:40Z",
      "name": "Rocket Rides",
      "metadata": {},
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "M1Bfm4z6iZgmn6tCULw5DBQuF-BsxC-uKy4HTnn1woY",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/6a03deb1-32a5-4acd-aa60-e684bed1d86b" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "6a03deb1-32a5-4acd-aa60-e684bed1d86b"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer gUkRPPQqZ4B6bGrqjMfSTsAVb8n3AVR7quESxrIBX6E"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/accounts/6a03deb1-32a5-4acd-aa60-e684bed1d86b

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "6a03deb1-32a5-4acd-aa60-e684bed1d86b"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "6a03deb1-32a5-4acd-aa60-e684bed1d86b",
    "type": "account",
    "attributes": {
      "created_at": "2024-12-16T00:58:40Z",
      "updated_at": "2024-12-16T00:58:40Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "WHhtSs8_9lTZpj4GkNmL5-6F3-enEK3gw8roYr_gLwg",
      "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 pogKbzWX0clEfuvQEbZ7wKI8LZ5l09Stov8W3E4_4v4"

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": "67ea81e8-a5a0-4c83-ac3e-afa716036b17",
      "type": "event",
      "attributes": {
        "created_at": "2024-12-16T00:57:53Z",
        "updated_at": "2024-12-16T00:57:53Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "2b0490cd-c20b-426d-baa2-402dc739145d",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2024-12-16T00:57:53Z",
              "price_unit": null,
              "updated_at": "2024-12-16T00:57:53Z"
            },
            "relationships": {
              "account": {
                "data": {
                  "id": "9a51dba9-ab1f-4e1a-83f8-f892a4badbf4",
                  "type": "account"
                }
              }
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=67ea81e8-a5a0-4c83-ac3e-afa716036b17",
    "next": null
  }
}

Retrieve an Event

Request

curl "https://api.somleng.org/carrier/v1/events/810c3f1c-0803-4910-aaf4-945991a3f3f9" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer sAlZ8I8QPfk6bRHUJaAs9Kayo-dPorIyY2ZjyKy7qCc"

Endpoint

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

GET https://api.somleng.org/carrier/v1/events/810c3f1c-0803-4910-aaf4-945991a3f3f9

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "810c3f1c-0803-4910-aaf4-945991a3f3f9",
    "type": "event",
    "attributes": {
      "created_at": "2024-12-16T00:57:54Z",
      "updated_at": "2024-12-16T00:57:54Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "758d42a0-3063-4f58-b5ec-0d6307c524ba",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2024-12-16T00:57:54Z",
            "price_unit": null,
            "updated_at": "2024-12-16T00:57:54Z"
          },
          "relationships": {
            "account": {
              "data": {
                "id": "d092b067-845b-4d4c-8daa-9a384965b317",
                "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]=315c15f4-d83c-4572-9d84-09ac5a880168&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer jMrWFqZTj9ZICRgOS7PSjTbKXmwCsRAXxls1T8ly8Z4"

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]=315c15f4-d83c-4572-9d84-09ac5a880168&filter[direction]=outbound-api

Parameters

{
  "filter": {
    "status": "sent",
    "from_date": "2021-11-01T00:00:00Z",
    "to_date": "2021-11-01T00:00:00Z",
    "account": "315c15f4-d83c-4572-9d84-09ac5a880168",
    "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": "d0fb0603-b755-43ff-b126-1fe5303302e2",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-12-16T00:58:19Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "315c15f4-d83c-4572-9d84-09ac5a880168",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=315c15f4-d83c-4572-9d84-09ac5a880168&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=d0fb0603-b755-43ff-b126-1fe5303302e2",
    "next": null
  }
}

Retrieve a message

Request

curl "https://api.somleng.org/carrier/v1/messages/6b42b407-583c-4475-be61-e73005466506" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ivhvCxwsglHhkpJKYwAOTzeluyP_jCUuWqIB5prtv-I"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages/6b42b407-583c-4475-be61-e73005466506

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "6b42b407-583c-4475-be61-e73005466506",
    "type": "message",
    "attributes": {
      "created_at": "2024-12-16T00:58:19Z",
      "updated_at": "2024-12-16T00:58:19Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "499ac99c-2052-49ae-994e-67ac30386309",
          "type": "account"
        }
      }
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/598de741-dc18-46e8-b6f9-78fde28f9006" -d '{
  "data": {
    "id": "598de741-dc18-46e8-b6f9-78fde28f9006",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ivXd5_Ci8_QVf3w1j_pHGzH0g9RBvlSBUPxMTm43LQw"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/messages/598de741-dc18-46e8-b6f9-78fde28f9006

Parameters

{
  "data": {
    "id": "598de741-dc18-46e8-b6f9-78fde28f9006",
    "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": "598de741-dc18-46e8-b6f9-78fde28f9006",
    "type": "message",
    "attributes": {
      "created_at": "2024-12-16T00:58:19Z",
      "updated_at": "2024-12-16T00:58:19Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "60cd553f-364b-47aa-9c3f-1f37dd407a8e",
          "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]=6cbbe225-a997-4c1e-8be0-956618af99aa&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer xO3SWp-0I9Vb1GAHWlix790ENYBsFP2fxlGu6hj9hS4"

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]=6cbbe225-a997-4c1e-8be0-956618af99aa&filter[direction]=outbound-api

Parameters

{
  "filter": {
    "status": "queued",
    "from_date": "2021-11-01T00:00:00Z",
    "to_date": "2021-11-01T00:00:00Z",
    "account": "6cbbe225-a997-4c1e-8be0-956618af99aa",
    "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": "ae4f7e66-c651-4d5f-8695-3a0629107a4f",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-12-16T00:58:25Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "6cbbe225-a997-4c1e-8be0-956618af99aa",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=6cbbe225-a997-4c1e-8be0-956618af99aa&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=ae4f7e66-c651-4d5f-8695-3a0629107a4f",
    "next": null
  }
}

Retrieve a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/a018e278-952b-45ef-851c-8f8e490e012c" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer hamYs4fV6WWCC-x1hYVvpsRrNMuJYrXS9qaU-nHse5w"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls/a018e278-952b-45ef-851c-8f8e490e012c

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "a018e278-952b-45ef-851c-8f8e490e012c",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-12-16T00:58:25Z",
      "updated_at": "2024-12-16T00:58:25Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "e487d2be-abab-4cb9-81a4-318b9386edb8",
          "type": "account"
        }
      }
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/316fbb9b-f3de-4f5d-a546-c79dcd14dbfe" -d '{
  "data": {
    "id": "316fbb9b-f3de-4f5d-a546-c79dcd14dbfe",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer qBQBQ8xWKOMDVe0kkXRb13CWhPABj8TYM6dzrd-MnPM"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_calls/316fbb9b-f3de-4f5d-a546-c79dcd14dbfe

Parameters

{
  "data": {
    "id": "316fbb9b-f3de-4f5d-a546-c79dcd14dbfe",
    "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": "316fbb9b-f3de-4f5d-a546-c79dcd14dbfe",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-12-16T00:58:25Z",
      "updated_at": "2024-12-16T00:58:25Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "1cf1bc98-53f2-44f6-a838-28924205e17e",
          "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 W3yRXDoe86ieLE8xIxBOm-jcGBSzDNPbZltT1Os23iY"

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": "c30b3b3c-bc23-4bf9-a624-4a4af24af027",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-12-16T00:57:35Z",
      "updated_at": "2024-12-16T00:57:35Z",
      "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/8ed15373-da70-4c94-ad52-112ff27e0ed8" -d '{
  "data": {
    "type": "phone_number",
    "id": "8ed15373-da70-4c94-ad52-112ff27e0ed8",
    "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 Y8bLq6Y_TgsXgma1X9kJV_PAZoE1-pRgBU6DYHHzrJQ"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/8ed15373-da70-4c94-ad52-112ff27e0ed8

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "8ed15373-da70-4c94-ad52-112ff27e0ed8",
    "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": "8ed15373-da70-4c94-ad52-112ff27e0ed8",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-12-16T00:57:35Z",
      "updated_at": "2024-12-16T00:57:35Z",
      "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/8e277b2c-e25b-4207-b20a-4c76b9958097" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer QIB7m6kdq_OUs_D40Qop8r3aFrVRnC43PM34t19KTLs"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_numbers/8e277b2c-e25b-4207-b20a-4c76b9958097

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "8e277b2c-e25b-4207-b20a-4c76b9958097",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-12-16T00:57:35Z",
      "updated_at": "2024-12-16T00:57:35Z",
      "number": "+855972345703",
      "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 ruiZQG9w0PqdVKmW4-JyexdYv5MpfRXn59u1DW4r2Gc"

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": "cf3fccfb-acbd-4c1c-ad64-a3c7b6d46b0e",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-12-16T00:57:35Z",
        "updated_at": "2024-12-16T00:57:35Z",
        "number": "+855972345700",
        "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": "22742d3c-746a-4ff8-9316-1ed7eaef38e0",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-12-16T00:57:35Z",
        "updated_at": "2024-12-16T00:57:35Z",
        "number": "+855972345699",
        "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=cf3fccfb-acbd-4c1c-ad64-a3c7b6d46b0e",
    "next": null
  }
}

05. Delete a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/48de9c15-3c75-4721-90d6-a38fde80ee5d" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer _VdwG46YWSjORlYFJwsNyIQUVSxAu5mWYW44zJs3_Jw"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/phone_numbers/48de9c15-3c75-4721-90d6-a38fde80ee5d

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 c9-Mq_y7210aCx5EwPNlJCepW2V40p3_61rNvwqD7Go"

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]=2024-12-15&filter[account]=95ec0046-4fff-4212-a107-544a4ec41cab&filter[phone_call]=8d011a04-06f3-4c93-8fe6-6743bc749722" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer upy9FHFqOq8GsumXfk3eWk5U1PFY2py8Y9qXZinQgaY"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2024-12-15&filter[account]=95ec0046-4fff-4212-a107-544a4ec41cab&filter[phone_call]=8d011a04-06f3-4c93-8fe6-6743bc749722

Parameters

{
  "filter": {
    "from_date": "2024-12-15",
    "account": "95ec0046-4fff-4212-a107-544a4ec41cab",
    "phone_call": "8d011a04-06f3-4c93-8fe6-6743bc749722"
  }
}
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": "ccc13450-8c6e-43d0-928c-a8a982df52a3",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-12-16T00:58:16Z",
        "updated_at": "2024-12-16T00:58:16Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 200
      },
      "relationships": {
        "account": {
          "data": {
            "id": "95ec0046-4fff-4212-a107-544a4ec41cab",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "8d011a04-06f3-4c93-8fe6-6743bc749722",
            "type": "phone_call"
          }
        }
      }
    },
    {
      "id": "df60f324-ff39-4673-b4c7-e04f92df6ba2",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-12-16T00:58:16Z",
        "updated_at": "2024-12-16T00:58:16Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 100
      },
      "relationships": {
        "account": {
          "data": {
            "id": "95ec0046-4fff-4212-a107-544a4ec41cab",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "8d011a04-06f3-4c93-8fe6-6743bc749722",
            "type": "phone_call"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=95ec0046-4fff-4212-a107-544a4ec41cab&filter%5Bfrom_date%5D=2024-12-15&filter%5Bphone_call%5D=8d011a04-06f3-4c93-8fe6-6743bc749722&page%5Bbefore%5D=ccc13450-8c6e-43d0-928c-a8a982df52a3",
    "next": null
  }
}

Retrieve a TTS Event

Request

curl "https://api.somleng.org/carrier/v1/tts_events/eecce092-8541-4c3f-8d6a-b793ea16093d" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer y8Khd43MXo8C54yE3XrUpd8-ctAeqgUbjx74k-lDdu0"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events/eecce092-8541-4c3f-8d6a-b793ea16093d

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "eecce092-8541-4c3f-8d6a-b793ea16093d",
    "type": "tts_event",
    "attributes": {
      "created_at": "2024-12-16T00:58:16Z",
      "updated_at": "2024-12-16T00:58:16Z",
      "voice": "Basic.Kal (Male, en-US)",
      "characters": 100
    },
    "relationships": {
      "account": {
        "data": {
          "id": "526f554b-3d18-4837-abe7-f5ebed837531",
          "type": "account"
        }
      },
      "phone_call": {
        "data": {
          "id": "09b261c2-66d2-4e14-ac9c-b74bbb1fdc41",
          "type": "phone_call"
        }
      }
    }
  }
}