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 JFYvNuXA2Hz8tRrulTWvf-24s0rJA2TxYOodY1r0tQ4" \
    --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": "f49bdf8b-4ed3-4170-8fa1-99abadfa7c34",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-13T11:23:42Z",
      "updated_at": "2024-05-13T11:23:42Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "jVuLXwXeoJwJcT-hbEYWGGK5BWfPCLbvBEGEX20lZoQ",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/face7f85-a536-4687-b35b-987b711379aa" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer yser-nFkHNNYyCS0JL1JoA9wwlXAACUhnigos5w1tyA"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/accounts/face7f85-a536-4687-b35b-987b711379aa

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 dRz12a2rJkE9qYW-emgQJic6A68-TArdgj5fFMv7X4Q"

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": "ce72d081-bcaf-48c3-9e71-27f758c5c99b",
      "type": "account",
      "attributes": {
        "created_at": "2024-05-13T11:23:42Z",
        "updated_at": "2024-05-13T11:23:42Z",
        "name": "Telco Net",
        "metadata": {
        },
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "VG5vZQ675-bdqN293iTUS0GT4gjSbMGXSaOvJBPfnhM",
        "default_tts_voice": "Basic.Kal"
      }
    },
    {
      "id": "5b118b8b-5c58-4be4-b675-ea1af4cf598c",
      "type": "account",
      "attributes": {
        "created_at": "2024-05-13T11:23:42Z",
        "updated_at": "2024-05-13T11:23:42Z",
        "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=ce72d081-bcaf-48c3-9e71-27f758c5c99b",
    "next": null
  }
}

Retrieve an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/582a3cf4-1476-4376-ab79-40122f3d61fc" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ic9D2kh_gG72dIwqr5HPfdGkpQf7hQs4LIL8QHmgGLg"

Endpoint

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

GET https://api.somleng.org/carrier/v1/accounts/582a3cf4-1476-4376-ab79-40122f3d61fc

Parameters

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

Response


200 OK
{
  "data": {
    "id": "582a3cf4-1476-4376-ab79-40122f3d61fc",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-13T11:23:42Z",
      "updated_at": "2024-05-13T11:23:42Z",
      "name": "Rocket Rides",
      "metadata": {
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "OdbjawyoOucPWHZeXnHadG_0iDbT9OQeyiMG6tJHC_0",
      "default_tts_voice": "Basic.Kal"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/7052da4e-8f6b-4cd0-a275-815f5087fde9" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "7052da4e-8f6b-4cd0-a275-815f5087fde9"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer S8vAw9xZ5tlL3YRjXOyvLCQePLiGrSVtveatapvO3ek"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/accounts/7052da4e-8f6b-4cd0-a275-815f5087fde9

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "default_tts_voice": "Basic.Kal",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "7052da4e-8f6b-4cd0-a275-815f5087fde9"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "7052da4e-8f6b-4cd0-a275-815f5087fde9",
    "type": "account",
    "attributes": {
      "created_at": "2024-05-13T11:23:42Z",
      "updated_at": "2024-05-13T11:23:42Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "EGTsXrA8mecPieg5plMlNTEXHEsgqKUjtAm46l43cZw",
      "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 dMEpATpmHUSdZtp8FJtKCiI4eEA3XSGxrcbzGik_VFA"

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": "3f48c3ae-e610-49b1-9076-2aee82a96606",
      "type": "event",
      "attributes": {
        "created_at": "2024-05-13T11:24:08Z",
        "updated_at": "2024-05-13T11:24:08Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "3f3cfb65-a629-4894-a85d-c268bc0dc166",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2024-05-13T11:24:08Z",
              "price_unit": null,
              "updated_at": "2024-05-13T11:24:08Z"
            },
            "relationships": {
              "account": {
                "data": {
                  "id": "342ee054-6d58-42c5-bdee-cd67d459a4a9",
                  "type": "account"
                }
              }
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=3f48c3ae-e610-49b1-9076-2aee82a96606",
    "next": null
  }
}

Retrieve an Event

Request

curl "https://api.somleng.org/carrier/v1/events/c9cb75c4-e490-4bd0-91ea-971076058412" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer lWpk_NWOw4pBmo_aFZCwsIEQ-o2xJi1HYMA-4CKtP8A"

Endpoint

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

GET https://api.somleng.org/carrier/v1/events/c9cb75c4-e490-4bd0-91ea-971076058412

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "c9cb75c4-e490-4bd0-91ea-971076058412",
    "type": "event",
    "attributes": {
      "created_at": "2024-05-13T11:24:08Z",
      "updated_at": "2024-05-13T11:24:08Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "d1e6bd23-bd2b-4e09-8fda-1da35fb2b6c0",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2024-05-13T11:24:08Z",
            "price_unit": null,
            "updated_at": "2024-05-13T11:24:08Z"
          },
          "relationships": {
            "account": {
              "data": {
                "id": "7df76cc4-6e45-4b40-ac91-7c8b0c337a45",
                "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]=fe8119f8-b3e2-4808-9215-e0d8e88e5de6&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 4cs132v5elXoLr6j5bDk1Gg6-lEtHxeLqsAqGa04uY4"

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]=fe8119f8-b3e2-4808-9215-e0d8e88e5de6&filter[direction]=outbound-api

Parameters

filter: {"status"=>"sent", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T00:00:00Z", "account"=>"fe8119f8-b3e2-4808-9215-e0d8e88e5de6", "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": "9a3fa635-5b8b-47e3-9404-d527736a4d20",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-05-13T11:23:37Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "fe8119f8-b3e2-4808-9215-e0d8e88e5de6",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=fe8119f8-b3e2-4808-9215-e0d8e88e5de6&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=9a3fa635-5b8b-47e3-9404-d527736a4d20",
    "next": null
  }
}

Retrieve a message

Request

curl "https://api.somleng.org/carrier/v1/messages/51e7da70-4b79-4301-8b46-8c54d08a1518" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer h59_80nkqI_xb9Nh3iOmToq5RlX0k7TCE-HgwQSb2Pk"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages/51e7da70-4b79-4301-8b46-8c54d08a1518

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "51e7da70-4b79-4301-8b46-8c54d08a1518",
    "type": "message",
    "attributes": {
      "created_at": "2024-05-13T11:23:37Z",
      "updated_at": "2024-05-13T11:23:37Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "fefb169b-6d35-4f87-be0f-f5fdfd3fb7ac",
          "type": "account"
        }
      }
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/7b452dbb-a9b9-4465-8950-cc9540ab80ca" -d '{
  "data": {
    "id": "7b452dbb-a9b9-4465-8950-cc9540ab80ca",
    "type": "message",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer rvOZ_LoCWkJrnvrJU5u0Y9X_WhYOcypnKbvg4lwEIA8"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/messages/7b452dbb-a9b9-4465-8950-cc9540ab80ca

Parameters

{
  "data": {
    "id": "7b452dbb-a9b9-4465-8950-cc9540ab80ca",
    "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": "7b452dbb-a9b9-4465-8950-cc9540ab80ca",
    "type": "message",
    "attributes": {
      "created_at": "2024-05-13T11:23:37Z",
      "updated_at": "2024-05-13T11:23:37Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "d618a636-e60e-4d72-8632-51177f3ae816",
          "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]=469af5ef-9460-4145-af75-69ae43961ff2&filter[direction]=outbound-api" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer r1xbvkWP-9NcO-HBjghVBov1z0KqftyGtQcnBEJkAvc"

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]=469af5ef-9460-4145-af75-69ae43961ff2&filter[direction]=outbound-api

Parameters

filter: {"status"=>"queued", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T00:00:00Z", "account"=>"469af5ef-9460-4145-af75-69ae43961ff2", "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": "4cfe2012-d68d-429b-b070-4d1c9c8228bb",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2024-05-13T11:23:54Z",
        "to": "+85512334667",
        "from": "2442",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "469af5ef-9460-4145-af75-69ae43961ff2",
            "type": "account"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=469af5ef-9460-4145-af75-69ae43961ff2&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=4cfe2012-d68d-429b-b070-4d1c9c8228bb",
    "next": null
  }
}

Retrieve a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/bfbe26a2-3a3c-47b1-b261-08ebf6df581d" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 6aAKj58cqUstldJZEq5KuyEAYOjcp7n-ItqXfrsxMo4"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls/bfbe26a2-3a3c-47b1-b261-08ebf6df581d

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "bfbe26a2-3a3c-47b1-b261-08ebf6df581d",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-05-13T11:23:55Z",
      "updated_at": "2024-05-13T11:23:55Z",
      "to": "+85512334667",
      "from": "2442",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "3c10f7ca-b633-4689-810b-aac0019dc715",
          "type": "account"
        }
      }
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/4cad6b40-e786-4629-b438-04423f404161" -d '{
  "data": {
    "id": "4cad6b40-e786-4629-b438-04423f404161",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer NbNxj09x4NFAiTj-PLUy2QEYKbYsj11gE_kDO2lZuxM"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_calls/4cad6b40-e786-4629-b438-04423f404161

Parameters

{
  "data": {
    "id": "4cad6b40-e786-4629-b438-04423f404161",
    "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": "4cad6b40-e786-4629-b438-04423f404161",
    "type": "phone_call",
    "attributes": {
      "created_at": "2024-05-13T11:23:54Z",
      "updated_at": "2024-05-13T11:23:54Z",
      "to": "+85512334667",
      "from": "2442",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "5611137d-f961-4b22-a348-20f2fb98551b",
          "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 G7tSkMvsTUKA7oKoRyHihxnLL-YqavbDnhiQe_tgL-U" \
    --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.

Response


201 Created
{
  "data": {
    "id": "6b3de240-0314-49d0-91f2-741d85504a79",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-13T11:24:14Z",
      "updated_at": "2024-05-13T11:24:14Z",
      "number": "1294",
      "country": "KH",
      "visibility": "private",
      "type": "short_code",
      "currency": "KHR",
      "price": "0.00"
    }
  }
}

Delete a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/4ba12294-ceb0-435d-97b9-c506cc238225" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer auMbHYti_OqUWb826_7FbsFV1RD2dlCvNeYO_NPFDms"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/phone_numbers/4ba12294-ceb0-435d-97b9-c506cc238225

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 iZP4a7pNTiQrbcOnKUg--fxBFxuALbTj-OhDXX4RpY8"

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": "5c5141f3-d15f-4296-a50c-5e3cb815625e",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-05-13T11:24:14Z",
        "updated_at": "2024-05-13T11:24:14Z",
        "number": "+855972345816",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "currency": "KHR",
        "price": "0.00"
      }
    },
    {
      "id": "7f90bda7-bed3-4bb4-a708-fba0ab439588",
      "type": "phone_number",
      "attributes": {
        "created_at": "2024-05-13T11:24:14Z",
        "updated_at": "2024-05-13T11:24:14Z",
        "number": "+855972345815",
        "country": "KH",
        "visibility": "private",
        "type": "mobile",
        "currency": "KHR",
        "price": "0.00"
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_numbers?page%5Bbefore%5D=5c5141f3-d15f-4296-a50c-5e3cb815625e",
    "next": null
  }
}

Retrieve a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/05ae133c-7bd1-4cb9-a24c-e85d7b63fbd1" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ZIysZ_wCUvIq2gu5CDgrkjEMNFSaVLnfww_kqPblfUo"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_numbers/05ae133c-7bd1-4cb9-a24c-e85d7b63fbd1

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "05ae133c-7bd1-4cb9-a24c-e85d7b63fbd1",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-13T11:24:14Z",
      "updated_at": "2024-05-13T11:24:14Z",
      "number": "+855972345818",
      "country": "KH",
      "visibility": "private",
      "type": "mobile",
      "currency": "KHR",
      "price": "0.00"
    }
  }
}

Update a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/5dae3489-7c0f-44dc-9d1b-13397df427a2" -d '{
  "data": {
    "type": "phone_number",
    "id": "5dae3489-7c0f-44dc-9d1b-13397df427a2",
    "attributes": {
      "type": "mobile",
      "visibility": "public",
      "country": "US",
      "price": "1.15"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer dLdcee8mApkkUQFwJVRdM1t1HAtNSCrJtfBmq_7VePc"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/5dae3489-7c0f-44dc-9d1b-13397df427a2

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "5dae3489-7c0f-44dc-9d1b-13397df427a2",
    "attributes": {
      "type": "mobile",
      "visibility": "public",
      "country": "US",
      "price": "1.15"
    }
  }
}
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": "5dae3489-7c0f-44dc-9d1b-13397df427a2",
    "type": "phone_number",
    "attributes": {
      "created_at": "2024-05-13T11:24:14Z",
      "updated_at": "2024-05-13T11:24:14Z",
      "number": "+15067020972",
      "country": "US",
      "visibility": "public",
      "type": "mobile",
      "currency": "CAD",
      "price": "1.15"
    }
  }
}

TTS Events

List all TTS events

Request

curl "https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2024-05-12&filter[account]=2bdb67ff-4218-4e4f-8e9c-bf1fb1c150d0&filter[phone_call]=5830c139-5ac0-4792-b991-ce1741962601" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer E3Y-HOCqxjEgQ-FzqeiDxIjJRLtSg9nDBFQkUcG61lg"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events?filter[from_date]=2024-05-12&filter[account]=2bdb67ff-4218-4e4f-8e9c-bf1fb1c150d0&filter[phone_call]=5830c139-5ac0-4792-b991-ce1741962601

Parameters

filter: {"from_date"=>"2024-05-12", "account"=>"2bdb67ff-4218-4e4f-8e9c-bf1fb1c150d0", "phone_call"=>"5830c139-5ac0-4792-b991-ce1741962601"}
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": "dd9439e7-c94d-46a4-988a-b9224814a359",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-05-13T11:23:43Z",
        "updated_at": "2024-05-13T11:23:43Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 200
      },
      "relationships": {
        "account": {
          "data": {
            "id": "2bdb67ff-4218-4e4f-8e9c-bf1fb1c150d0",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "5830c139-5ac0-4792-b991-ce1741962601",
            "type": "phone_call"
          }
        }
      }
    },
    {
      "id": "71d5d0f1-5458-427a-820f-6f4e37cd03e0",
      "type": "tts_event",
      "attributes": {
        "created_at": "2024-05-13T11:23:43Z",
        "updated_at": "2024-05-13T11:23:43Z",
        "voice": "Basic.Kal (Male, en-US)",
        "characters": 100
      },
      "relationships": {
        "account": {
          "data": {
            "id": "2bdb67ff-4218-4e4f-8e9c-bf1fb1c150d0",
            "type": "account"
          }
        },
        "phone_call": {
          "data": {
            "id": "5830c139-5ac0-4792-b991-ce1741962601",
            "type": "phone_call"
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/tts_events?filter%5Baccount%5D=2bdb67ff-4218-4e4f-8e9c-bf1fb1c150d0&filter%5Bfrom_date%5D=2024-05-12&filter%5Bphone_call%5D=5830c139-5ac0-4792-b991-ce1741962601&page%5Bbefore%5D=dd9439e7-c94d-46a4-988a-b9224814a359",
    "next": null
  }
}

Retrieve a TTS Event

Request

curl "https://api.somleng.org/carrier/v1/tts_events/8e76f80c-7e62-4212-9ac3-a56f382f4b6f" \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer EbMZtgPCo5WyyMZX8X-tH5jESkZdDjUgaLDHWWDM1-I"

Endpoint

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

GET https://api.somleng.org/carrier/v1/tts_events/8e76f80c-7e62-4212-9ac3-a56f382f4b6f

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "8e76f80c-7e62-4212-9ac3-a56f382f4b6f",
    "type": "tts_event",
    "attributes": {
      "created_at": "2024-05-13T11:23:43Z",
      "updated_at": "2024-05-13T11:23:43Z",
      "voice": "Basic.Kal (Male, en-US)",
      "characters": 100
    },
    "relationships": {
      "account": {
        "data": {
          "id": "889419e1-2af2-418c-9a7c-ed96be47c7ac",
          "type": "account"
        }
      },
      "phone_call": {
        "data": {
          "id": "db251335-81b6-4df0-be87-6a527dc8f0a6",
          "type": "phone_call"
        }
      }
    }
  }
}