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 -X POST "https://api.somleng.org/carrier/v1/accounts" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer nFKV2Y7WDVRZA-_2pl-t01QHWDS3jGvEFlRXs_1m8iA" \
    --data-urlencode "{
  "data": {
    "type": "account",
    "attributes": {
      "name": "Rocket Rides",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "foo": "bar"
      }
    }
  }
}="

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": "52600c0e-5ba4-4584-b9f8-ede581aeba71",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-30T07:53:28Z",
      "updated_at": "2024-05-30T07:53:28Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "Furg2f-6zAUHea8ud3BqfjffwdxGrfucqbvEsRup6ik",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/f8637ad8-21c8-4efa-8e00-076bed48bb44" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer O4MfftSQc88DCJtd0SVFn1VsltZPQyKc4OFNC5Ys35w"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/accounts/f8637ad8-21c8-4efa-8e00-076bed48bb44

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 FnPKOnhAu-je9bBlD85Mj_lUH__ijMTk5k0aCMVSmKU"

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": "638ec822-fc60-4dd9-821a-44fdf27c0836",
      "type": "account",
      "attributes": {
        "created_at": "2024-05-30T07:53:28Z",
        "updated_at": "2024-05-30T07:53:28Z",
        "name": "Telco Net",
        "metadata": {
        },
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "H2xbHSYB95z6za5ldieZ7lS9S6WOSsYdoemqGnkJ6Io",
        "default_tts_voice": "Basic.Kal"
      }
    },
    {
      "id": "edd99e06-1e39-44a0-aee9-411e5747e18f",
      "type": "account",
      "attributes": {
        "created_at": "2024-05-30T07:53:28Z",
        "updated_at": "2024-05-30T07:53:28Z",
        "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=638ec822-fc60-4dd9-821a-44fdf27c0836",
    "next": null
  }
}

Retrieve an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/d3ed8c38-fa2b-48a3-aa0d-e81e34315e31" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer jkTrd6j1Vz2UtC2R8CD3ps7JjtL9CGrTfG0eYBLb79s"

Endpoint

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

GET https://api.somleng.org/carrier/v1/accounts/d3ed8c38-fa2b-48a3-aa0d-e81e34315e31

Parameters

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

Response


200 OK
{
  "data": {
    "id": "d3ed8c38-fa2b-48a3-aa0d-e81e34315e31",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-30T07:53:28Z",
      "updated_at": "2024-05-30T07:53:28Z",
      "name": "Rocket Rides",
      "metadata": {
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "wb2wKXKGVdMUK9HSbz9e-BFp82xYFcxhf-r-4R9-ttY",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/4e4bf73a-221b-4b05-aa17-431328ae1fab" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "4e4bf73a-221b-4b05-aa17-431328ae1fab"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer mfbPOyPg8yG0HC1387wjQxiy_1g-wVxg69AhWz5bzBY"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/accounts/4e4bf73a-221b-4b05-aa17-431328ae1fab

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "4e4bf73a-221b-4b05-aa17-431328ae1fab"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "4e4bf73a-221b-4b05-aa17-431328ae1fab",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-30T07:53:29Z",
      "updated_at": "2024-05-30T07:53:29Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "tepSc9kkYAm6wEFzjDB4640KDd4wtsr6HAncLk_fm2U",
      "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 Lnklb6t_w4o6ZJTl5ed4PQkuw8DHbL3r4DmlluC_eU4"

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": "f7de1579-9809-495f-9c6d-c222aa123d64",
      "type": "event",
      "attributes": {
        "created_at": "2024-05-30T07:52:23Z",
        "updated_at": "2024-05-30T07:52:23Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "ff427ab3-9058-4571-8908-01aac9d80749",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2024-05-30T07:52:23Z",
              "price_unit": null,
              "updated_at": "2024-05-30T07:52:23Z"
            },
            "relationships": {
              "account": {
                "data": {
                  "id": "7957b641-a8e8-47bb-b41e-71ddd47bc6c6",
                  "type": "account"
                }
              }
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=f7de1579-9809-495f-9c6d-c222aa123d64",
    "next": null
  }
}

Retrieve an Event

Request

curl "https://api.somleng.org/carrier/v1/events/4305e35e-4888-42c7-9b9d-caf4514bafac" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer s3y5vuWsR1iPYR8uxGJyqrz1quM8Z0r8PlL54X8orZA"

Endpoint

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

GET https://api.somleng.org/carrier/v1/events/4305e35e-4888-42c7-9b9d-caf4514bafac

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "4305e35e-4888-42c7-9b9d-caf4514bafac",
    "type": "event",
    "attributes": {
      "created_at": "2024-05-30T07:52:23Z",
      "updated_at": "2024-05-30T07:52:23Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "c2852e9a-b519-43d3-a142-bdb425f6ab8f",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2024-05-30T07:52:23Z",
            "price_unit": null,
            "updated_at": "2024-05-30T07:52:23Z"
          },
          "relationships": {
            "account": {
              "data": {
                "id": "1bedd89d-431b-418f-8976-bc816148d847",
                "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]=82b10412-869e-4999-ad76-bbf5bf62ddb6&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 3UFVLVpqV78os5HorCs0_lYLTjrAoFKZmnTe4lfXN5s"

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]=82b10412-869e-4999-ad76-bbf5bf62ddb6&filter[direction]=outbound-api

Parameters

filter: {"status"=>"sent", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T00:00:00Z", "account"=>"82b10412-869e-4999-ad76-bbf5bf62ddb6", "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": "b5e2c8cc-f9ab-4aa8-9ea3-c8e9afeccb11",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-05-30T07:53:05Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "82b10412-869e-4999-ad76-bbf5bf62ddb6",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=82b10412-869e-4999-ad76-bbf5bf62ddb6&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=b5e2c8cc-f9ab-4aa8-9ea3-c8e9afeccb11",
    "next": null
  }
}

Retrieve a message

Request

curl "https://api.somleng.org/carrier/v1/messages/8a4eb775-959e-4da6-8a32-b76da5b9888a" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer LOMvNDp4SWm26tSiYRxTjszyEFPrY0QpvDOqgUwhdVw"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages/8a4eb775-959e-4da6-8a32-b76da5b9888a

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "8a4eb775-959e-4da6-8a32-b76da5b9888a",
    "type": "message",
    "attributes": {
      "created_at": "2024-05-30T07:53:05Z",
      "updated_at": "2024-05-30T07:53:05Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "5ccac25a-2a3b-4834-a249-29a41069109e",
          "type": "account"
        }
      }
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/aa931396-92ce-4366-a7f5-2c5c30d32517" -d '{
  "data": {
    "id": "aa931396-92ce-4366-a7f5-2c5c30d32517",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer PyGzXfamP_FcbGLr66_XWmBxvNFwusIFOxWW21VLPmE"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/messages/aa931396-92ce-4366-a7f5-2c5c30d32517

Parameters

{
  "data": {
    "id": "aa931396-92ce-4366-a7f5-2c5c30d32517",
    "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": "aa931396-92ce-4366-a7f5-2c5c30d32517",
    "type": "message",
    "attributes": {
      "created_at": "2024-05-30T07:53:05Z",
      "updated_at": "2024-05-30T07:53:05Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "5d6ded19-60a3-4b1b-8d36-7c540141f113",
          "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]=61bddb83-e255-4c17-b036-c7cd114224e2&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer c2K19-yUrogtfiT06JuB9aSDGhxfKMdNCXe0V6tHfE4"

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]=61bddb83-e255-4c17-b036-c7cd114224e2&filter[direction]=outbound-api

Parameters

filter: {"status"=>"queued", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T00:00:00Z", "account"=>"61bddb83-e255-4c17-b036-c7cd114224e2", "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": "a2de1bdd-af42-4a00-ad72-fa55bae0cc7d",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-05-30T07:53:18Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "61bddb83-e255-4c17-b036-c7cd114224e2",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=61bddb83-e255-4c17-b036-c7cd114224e2&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=a2de1bdd-af42-4a00-ad72-fa55bae0cc7d",
    "next": null
  }
}

Retrieve a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/579b68c1-e112-4f1a-8a20-cb90511c37de" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer hQq9AJ9gI2Ah2pHtjEuyZEPQ-ioX64iijoPA1Yjplpk"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls/579b68c1-e112-4f1a-8a20-cb90511c37de

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "579b68c1-e112-4f1a-8a20-cb90511c37de",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-05-30T07:53:18Z",
      "updated_at": "2024-05-30T07:53:18Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "8d68abc9-a3ee-4ff0-b0ec-cd679882f3dd",
          "type": "account"
        }
      }
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/bf66b64d-5c52-4174-8c46-515fc7dcfed7" -d '{
  "data": {
    "id": "bf66b64d-5c52-4174-8c46-515fc7dcfed7",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 1HIpH758rpNtfCc5Eqktiraw5M_AHEsw98YiZ90MB5Y"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_calls/bf66b64d-5c52-4174-8c46-515fc7dcfed7

Parameters

{
  "data": {
    "id": "bf66b64d-5c52-4174-8c46-515fc7dcfed7",
    "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": "bf66b64d-5c52-4174-8c46-515fc7dcfed7",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-05-30T07:53:18Z",
      "updated_at": "2024-05-30T07:53:18Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "96e58138-2509-4cd3-a1f5-dfeeec977e5e",
          "type": "account"
        }
      }
    }
  }
}

Phone Numbers

Create a phone number

Request

curl -X POST "https://api.somleng.org/carrier/v1/phone_numbers" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer epDDVwC9wyjjyxfczefMPdlEJldUGJlTzkRCdKVaiPY" \
    --data-urlencode "{
  "data": {
    "type": "phone_number",
    "attributes": {
      "number": "1294",
      "type": "short_code"
    }
  }
}="

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"
    }
  }
}
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.

Response


201 Created
{
  "data": {
    "id": "baf84462-081b-473e-878b-24a5a15a76b6",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-30T07:53:19Z",
      "updated_at": "2024-05-30T07:53:19Z",
      "number": "1294",
      "country": "KH",
      "visibility": "private",
      "type": "short_code",
      "locality": null,
      "currency": "KHR",
      "price": "0.00",
      "region": null
    }
  }
}

Delete a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/54dc83fd-5832-40e1-a983-d6fd4a515925" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer hlyvRxyOIDAj7oVMyjmPU1bmPJlOPXAyU1Gdn5ZCbxs"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/phone_numbers/54dc83fd-5832-40e1-a983-d6fd4a515925

Parameters

None known.

Response


204 No Content

List all phone numbers

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer WY2EuOcom5Shd00vP2SgqVyHBISFdd1e_68J1r3oF2o"

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": "ccf58ffb-121b-4bc3-b37e-f52c1a7ef9f0",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-05-30T07:53:19Z",
        "updated_at": "2024-05-30T07:53:19Z",
        "number": "+855972345805",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "locality": null,
        "currency": "KHR",
        "price": "0.00",
        "region": null
      }
    },
    {
      "id": "e28257ea-8c21-4276-8142-4148d23171d6",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-05-30T07:53:19Z",
        "updated_at": "2024-05-30T07:53:19Z",
        "number": "+855972345804",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "locality": null,
        "currency": "KHR",
        "price": "0.00",
        "region": null
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_numbers?page%5Bbefore%5D=ccf58ffb-121b-4bc3-b37e-f52c1a7ef9f0",
    "next": null
  }
}

Retrieve a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/d0fc22c1-eee4-4895-ab32-3082a0ada497" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer w8cQg4hvQA-sANJ7zHMuS3KQyKTZsKcawM7PX82O95w"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_numbers/d0fc22c1-eee4-4895-ab32-3082a0ada497

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "d0fc22c1-eee4-4895-ab32-3082a0ada497",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-30T07:53:19Z",
      "updated_at": "2024-05-30T07:53:19Z",
      "number": "+855972345808",
      "country": "KH",
      "visibility": "private",
      "type": "mobile",
      "locality": null,
      "currency": "KHR",
      "price": "0.00",
      "region": null
    }
  }
}

Update a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/2bc6f17a-4a9a-48f2-bb10-f76a4095b034" -d '{
  "data": {
    "type": "phone_number",
    "id": "2bc6f17a-4a9a-48f2-bb10-f76a4095b034",
    "attributes": {
      "type": "mobile",
      "visibility": "public",
      "country": "US",
      "price": "1.15",
      "region": "AK",
      "locality": "Little Rock"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Yh4kqkZkydQKcaJmHshGmv00Udl1W2S_onfgUrpn-u8"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/2bc6f17a-4a9a-48f2-bb10-f76a4095b034

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "2bc6f17a-4a9a-48f2-bb10-f76a4095b034",
    "attributes": {
      "type": "mobile",
      "visibility": "public",
      "country": "US",
      "price": "1.15",
      "region": "AK",
      "locality": "Little Rock"
    }
  }
}
Name Description
data[attributes][type] 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.
data[attributes][price] The price for the phone number in the billing currency of the carrier.

Response


200 OK
{
  "data": {
    "id": "2bc6f17a-4a9a-48f2-bb10-f76a4095b034",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-30T07:53:19Z",
      "updated_at": "2024-05-30T07:53:19Z",
      "number": "+15067020972",
      "country": "US",
      "visibility": "public",
      "type": "mobile",
      "locality": "Little Rock",
      "currency": "CAD",
      "price": "1.15",
      "region": "AK"
    }
  }
}

TTS Events

List all TTS events

Request

curl "https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2024-05-29&filter[account]=36a3450a-71a7-4308-80cc-407bf64a5055&filter[phone_call]=08848baf-6b31-4c10-aea6-8e931ed5dc60" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer nkvr4xzAgiwhivYV73znehoKkIG_4_uxsdfLP_KcP2s"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2024-05-29&filter[account]=36a3450a-71a7-4308-80cc-407bf64a5055&filter[phone_call]=08848baf-6b31-4c10-aea6-8e931ed5dc60

Parameters

filter: {"from_date"=>"2024-05-29", "account"=>"36a3450a-71a7-4308-80cc-407bf64a5055", "phone_call"=>"08848baf-6b31-4c10-aea6-8e931ed5dc60"}
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": "835ef5b6-8d00-4d06-8e61-cb69ad7d9486",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-05-30T07:53:00Z",
        "updated_at": "2024-05-30T07:53:00Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 200
      },
      "relationships": {
        "account": {
          "data": {
            "id": "36a3450a-71a7-4308-80cc-407bf64a5055",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "08848baf-6b31-4c10-aea6-8e931ed5dc60",
            "type": "phone_call"
          }
        }
      }
    },
    {
      "id": "eef1e073-9045-41c3-85c2-f231ae301ea3",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-05-30T07:53:00Z",
        "updated_at": "2024-05-30T07:53:00Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 100
      },
      "relationships": {
        "account": {
          "data": {
            "id": "36a3450a-71a7-4308-80cc-407bf64a5055",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "08848baf-6b31-4c10-aea6-8e931ed5dc60",
            "type": "phone_call"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=36a3450a-71a7-4308-80cc-407bf64a5055&filter%5Bfrom_date%5D=2024-05-29&filter%5Bphone_call%5D=08848baf-6b31-4c10-aea6-8e931ed5dc60&page%5Bbefore%5D=835ef5b6-8d00-4d06-8e61-cb69ad7d9486",
    "next": null
  }
}

Retrieve a TTS Event

Request

curl "https://api.somleng.org/carrier/v1/tts_events/3ea5dbb0-08f6-4a71-a0da-196a2e8d0357" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Pn2Z8SLpskPbaXfVYlHJrXmQ0AfPnsqTOQbNYzL89yI"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events/3ea5dbb0-08f6-4a71-a0da-196a2e8d0357

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "3ea5dbb0-08f6-4a71-a0da-196a2e8d0357",
    "type": "tts_event",
    "attributes": {
      "created_at": "2024-05-30T07:53:00Z",
      "updated_at": "2024-05-30T07:53:00Z",
      "voice": "Basic.Kal (Male, en-US)",
      "characters": 100
    },
    "relationships": {
      "account": {
        "data": {
          "id": "f7cfcd54-f667-4182-96af-9ac87bf7a913",
          "type": "account"
        }
      },
      "phone_call": {
        "data": {
          "id": "2795ca19-defa-488a-8892-c825304aff44",
          "type": "phone_call"
        }
      }
    }
  }
}