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 Kj0ZWkGbczi6StlCgGdc7X6w0VdQ-Y-hxMbeTvzcyUc" \
    --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": "efcf4e0b-c49c-4298-bd01-8b0b8c5ea15b",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-18T07:58:25Z",
      "updated_at": "2024-05-18T07:58:25Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "dY_sCaMxERPBswwrVRFsmZ4hvu_4quKERlc8pmANntk",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/c9a02746-e485-41dd-bbb0-8dae3ec73a0d" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer b4MUHcb-AeDsDzh7JWjBMBo0uvkuCBENBbBuiw8KVhU"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/accounts/c9a02746-e485-41dd-bbb0-8dae3ec73a0d

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 5cf-jsepsfgjy82m6RyaVGiWD_45DGAUpZbqFN9pIgk"

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": "563b8d00-48a8-4fe6-bd48-e37e731292cb",
      "type": "account",
      "attributes": {
        "created_at": "2024-05-18T07:58:25Z",
        "updated_at": "2024-05-18T07:58:25Z",
        "name": "Telco Net",
        "metadata": {
        },
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "_IgPlJg0RSjR8MH_I-QHewXHy3D5L4Mjnm4y_3Q7re0",
        "default_tts_voice": "Basic.Kal"
      }
    },
    {
      "id": "a1a5ac9f-bc6b-47e5-ad6f-df8a28ee5d0d",
      "type": "account",
      "attributes": {
        "created_at": "2024-05-18T07:58:25Z",
        "updated_at": "2024-05-18T07:58:25Z",
        "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=563b8d00-48a8-4fe6-bd48-e37e731292cb",
    "next": null
  }
}

Retrieve an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/3bdcad53-193a-4c97-9c2b-2a220ecb3b4f" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer HQi6hNZGYWieaJKgEpyQJgw1z533DdTej5nY4nMr5b0"

Endpoint

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

GET https://api.somleng.org/carrier/v1/accounts/3bdcad53-193a-4c97-9c2b-2a220ecb3b4f

Parameters

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

Response


200 OK
{
  "data": {
    "id": "3bdcad53-193a-4c97-9c2b-2a220ecb3b4f",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-18T07:58:25Z",
      "updated_at": "2024-05-18T07:58:25Z",
      "name": "Rocket Rides",
      "metadata": {
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "3u2zF0WTyayfb7SYvV82dwDILXucQGg_TO_Yq5dSKuw",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/9382497d-cb70-4f52-a358-cfd20ac61ff9" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "9382497d-cb70-4f52-a358-cfd20ac61ff9"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Usl5sB1giHWWCIRnh2yHcDVm0Gt7hau5RKv9Mb7JB3Q"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/accounts/9382497d-cb70-4f52-a358-cfd20ac61ff9

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "9382497d-cb70-4f52-a358-cfd20ac61ff9"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "9382497d-cb70-4f52-a358-cfd20ac61ff9",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-18T07:58:25Z",
      "updated_at": "2024-05-18T07:58:25Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "3RMFM5EhaoUdstrTXJTCX2qSvbwvtoirdLNx9MlxH_Q",
      "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 xP_dkugrbflmZ37Y23GcOo_lllte_QzZwVjY-2FuGIc"

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": "5c9e24c6-faff-44a1-a850-2e8c0b9159bf",
      "type": "event",
      "attributes": {
        "created_at": "2024-05-18T07:58:05Z",
        "updated_at": "2024-05-18T07:58:05Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "8781b460-b7b6-48fb-964c-8c22e018ed5d",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2024-05-18T07:58:05Z",
              "price_unit": null,
              "updated_at": "2024-05-18T07:58:05Z"
            },
            "relationships": {
              "account": {
                "data": {
                  "id": "098f23c9-c435-4a84-a03e-d7e1f3f38335",
                  "type": "account"
                }
              }
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=5c9e24c6-faff-44a1-a850-2e8c0b9159bf",
    "next": null
  }
}

Retrieve an Event

Request

curl "https://api.somleng.org/carrier/v1/events/32dc9a10-69f6-4322-b8b1-444755a9c575" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer zJnizlk16FlJGKzBkQ7b2WV2hFyxE6PlIefLxnWjy0w"

Endpoint

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

GET https://api.somleng.org/carrier/v1/events/32dc9a10-69f6-4322-b8b1-444755a9c575

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "32dc9a10-69f6-4322-b8b1-444755a9c575",
    "type": "event",
    "attributes": {
      "created_at": "2024-05-18T07:58:05Z",
      "updated_at": "2024-05-18T07:58:05Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "a76271bf-182b-45b9-b774-1979c1a0d12b",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2024-05-18T07:58:05Z",
            "price_unit": null,
            "updated_at": "2024-05-18T07:58:05Z"
          },
          "relationships": {
            "account": {
              "data": {
                "id": "b713e84c-265e-4534-a6aa-001b093c9903",
                "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]=b5bc037d-c50c-4578-9d8a-30fe0111eeb1&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer wjoRYbVNRBbo57n26A8rv4bgpM2QF1imN5cG40SVFTg"

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]=b5bc037d-c50c-4578-9d8a-30fe0111eeb1&filter[direction]=outbound-api

Parameters

filter: {"status"=>"sent", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T00:00:00Z", "account"=>"b5bc037d-c50c-4578-9d8a-30fe0111eeb1", "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": "efddf7f3-9752-434e-a792-5d7974b5b6a6",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-05-18T07:58:20Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "b5bc037d-c50c-4578-9d8a-30fe0111eeb1",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=b5bc037d-c50c-4578-9d8a-30fe0111eeb1&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=efddf7f3-9752-434e-a792-5d7974b5b6a6",
    "next": null
  }
}

Retrieve a message

Request

curl "https://api.somleng.org/carrier/v1/messages/dfebd379-a25a-43f7-aff2-9957f148ce0e" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ctCImq4r056wi6Wz79bzyNE9ShJ1fK9yZo5aN516JsU"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages/dfebd379-a25a-43f7-aff2-9957f148ce0e

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "dfebd379-a25a-43f7-aff2-9957f148ce0e",
    "type": "message",
    "attributes": {
      "created_at": "2024-05-18T07:58:20Z",
      "updated_at": "2024-05-18T07:58:20Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "d2611db9-9b08-43a2-9821-d812faed1b1a",
          "type": "account"
        }
      }
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/bb0a43cb-3bbf-4c05-aca4-8884575e55b0" -d '{
  "data": {
    "id": "bb0a43cb-3bbf-4c05-aca4-8884575e55b0",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer huNZWcCbol9MbhHJH6eEeVUUtb-5Cpji-9synG9IWj4"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/messages/bb0a43cb-3bbf-4c05-aca4-8884575e55b0

Parameters

{
  "data": {
    "id": "bb0a43cb-3bbf-4c05-aca4-8884575e55b0",
    "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": "bb0a43cb-3bbf-4c05-aca4-8884575e55b0",
    "type": "message",
    "attributes": {
      "created_at": "2024-05-18T07:58:20Z",
      "updated_at": "2024-05-18T07:58:20Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "28473007-8dda-4592-b36e-cbf5da1b868a",
          "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]=22c1aa9e-f972-4449-956d-6197dad1b446&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer c-YNwGXdBWf9eT2cUPItmXb8eHMwkRgVvMwhnP5wVPk"

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]=22c1aa9e-f972-4449-956d-6197dad1b446&filter[direction]=outbound-api

Parameters

filter: {"status"=>"queued", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T00:00:00Z", "account"=>"22c1aa9e-f972-4449-956d-6197dad1b446", "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": "f93b30de-b04d-4a36-a34d-1f55ef3bf7bb",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-05-18T07:58:10Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "22c1aa9e-f972-4449-956d-6197dad1b446",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=22c1aa9e-f972-4449-956d-6197dad1b446&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=f93b30de-b04d-4a36-a34d-1f55ef3bf7bb",
    "next": null
  }
}

Retrieve a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/f7381116-63b8-4273-a6b8-16c9866e4d09" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer J104XF21WWd-LtP0u9XehYTySOuFFioNV_zkwFFBCAU"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls/f7381116-63b8-4273-a6b8-16c9866e4d09

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "f7381116-63b8-4273-a6b8-16c9866e4d09",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-05-18T07:58:10Z",
      "updated_at": "2024-05-18T07:58:10Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "f9867413-d307-41d2-b5c0-967cd64d0859",
          "type": "account"
        }
      }
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/6f1de98f-543c-469c-845d-d0e1c0211531" -d '{
  "data": {
    "id": "6f1de98f-543c-469c-845d-d0e1c0211531",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer BsSWIPZLlro8UcKBV9fdf-nCuYsr6qYLZnKzwi-65vI"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_calls/6f1de98f-543c-469c-845d-d0e1c0211531

Parameters

{
  "data": {
    "id": "6f1de98f-543c-469c-845d-d0e1c0211531",
    "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": "6f1de98f-543c-469c-845d-d0e1c0211531",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-05-18T07:58:10Z",
      "updated_at": "2024-05-18T07:58:10Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "a58aae79-d40a-4f73-8930-dc9c2fd32e29",
          "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 MInRebRNSAHbqmRUPWf8qj_seYiwySNWkVApQ9XR0NE" \
    --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": "2a09f773-b3c9-4f45-a093-38b814847e62",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-18T07:58:13Z",
      "updated_at": "2024-05-18T07:58:13Z",
      "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/47a8e6eb-7f96-4238-8ac8-806dda042e46" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer fCZDRq1WYUvl54uB1MXkYz5IpMMR00t4-AwK04UlAlw"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/phone_numbers/47a8e6eb-7f96-4238-8ac8-806dda042e46

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 VM-FRKDklY_e4a99Ud8gF54xEebbv03SrXcI4uc6sX4"

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": "2f540938-7956-45b7-a8b1-ca0a838e708c",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-05-18T07:58:13Z",
        "updated_at": "2024-05-18T07:58:13Z",
        "number": "+855972345785",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "locality": null,
        "currency": "KHR",
        "price": "0.00",
        "region": null
      }
    },
    {
      "id": "9f5527cc-0f8b-446c-8ef7-95e3a4c30603",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-05-18T07:58:13Z",
        "updated_at": "2024-05-18T07:58:13Z",
        "number": "+855972345784",
        "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=2f540938-7956-45b7-a8b1-ca0a838e708c",
    "next": null
  }
}

Retrieve a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/fb6931ab-0ca2-4a2f-8ba6-4ef5fafd7cc7" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer _16ZZGl_wqx3K-E8wVIUdFaogo0pd2P7Hl6r6F4Fet0"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_numbers/fb6931ab-0ca2-4a2f-8ba6-4ef5fafd7cc7

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "fb6931ab-0ca2-4a2f-8ba6-4ef5fafd7cc7",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-18T07:58:13Z",
      "updated_at": "2024-05-18T07:58:13Z",
      "number": "+855972345788",
      "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/345f1073-7cb0-4d17-9c81-7b04ef9ef358" -d '{
  "data": {
    "type": "phone_number",
    "id": "345f1073-7cb0-4d17-9c81-7b04ef9ef358",
    "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 4aGa0qZA426CFaPwuWsjiYfjXzcIWkvLCJWZRfdHpS4"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/345f1073-7cb0-4d17-9c81-7b04ef9ef358

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "345f1073-7cb0-4d17-9c81-7b04ef9ef358",
    "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": "345f1073-7cb0-4d17-9c81-7b04ef9ef358",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-18T07:58:13Z",
      "updated_at": "2024-05-18T07:58:13Z",
      "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-17&filter[account]=602e3884-7264-49a3-9ef4-0453d511c993&filter[phone_call]=aadf55f1-7369-430f-937e-3fa1b20e5735" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer bXlmjOrPBcqI8qM4o3Eg2NGrJY8hRfgzCY88FfpUNpA"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2024-05-17&filter[account]=602e3884-7264-49a3-9ef4-0453d511c993&filter[phone_call]=aadf55f1-7369-430f-937e-3fa1b20e5735

Parameters

filter: {"from_date"=>"2024-05-17", "account"=>"602e3884-7264-49a3-9ef4-0453d511c993", "phone_call"=>"aadf55f1-7369-430f-937e-3fa1b20e5735"}
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": "bce195ad-e237-48f0-b0a8-4ffe13bfb5b2",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-05-18T07:58:27Z",
        "updated_at": "2024-05-18T07:58:27Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 200
      },
      "relationships": {
        "account": {
          "data": {
            "id": "602e3884-7264-49a3-9ef4-0453d511c993",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "aadf55f1-7369-430f-937e-3fa1b20e5735",
            "type": "phone_call"
          }
        }
      }
    },
    {
      "id": "c10b8d51-0a56-412b-a2b1-3b2ce27e4077",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-05-18T07:58:27Z",
        "updated_at": "2024-05-18T07:58:27Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 100
      },
      "relationships": {
        "account": {
          "data": {
            "id": "602e3884-7264-49a3-9ef4-0453d511c993",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "aadf55f1-7369-430f-937e-3fa1b20e5735",
            "type": "phone_call"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=602e3884-7264-49a3-9ef4-0453d511c993&filter%5Bfrom_date%5D=2024-05-17&filter%5Bphone_call%5D=aadf55f1-7369-430f-937e-3fa1b20e5735&page%5Bbefore%5D=bce195ad-e237-48f0-b0a8-4ffe13bfb5b2",
    "next": null
  }
}

Retrieve a TTS Event

Request

curl "https://api.somleng.org/carrier/v1/tts_events/9c8a0ff2-1355-4d40-879a-ba7d86c89a0f" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer w3hINjeFKR-ocyc3o3qd96gVra7eL6T0j4_c1f_3Spk"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events/9c8a0ff2-1355-4d40-879a-ba7d86c89a0f

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "9c8a0ff2-1355-4d40-879a-ba7d86c89a0f",
    "type": "tts_event",
    "attributes": {
      "created_at": "2024-05-18T07:58:27Z",
      "updated_at": "2024-05-18T07:58:27Z",
      "voice": "Basic.Kal (Male, en-US)",
      "characters": 100
    },
    "relationships": {
      "account": {
        "data": {
          "id": "9bf36d10-d92b-4877-ac6f-81bc3df91700",
          "type": "account"
        }
      },
      "phone_call": {
        "data": {
          "id": "e6e5acc8-5f0e-44a3-b5aa-9226817f66aa",
          "type": "phone_call"
        }
      }
    }
  }
}