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. Here's an example in Ruby:

JWT.decode(
  request.headers["Authorization"].sub("Bearer ", ""),
  "[your-webhook-signing-secret]",
  true,
  algorithm: "HS256",
  verify_iss: true,
  iss: "Somleng"
)

Accounts

Create an account

Request

curl "https://api.somleng.org/carrier/v1/accounts" -d '{
  "data": {
    "type": "account",
    "attributes": {
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      }
    }
  }
}' -X POST \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer M9j9XBJpJuDRjV9h7CeW81kbm3hVx_117XlQoy5SJKg"

Endpoint

POST https://api.somleng.org/carrier/v1/accounts

POST https://api.somleng.org/carrier/v1/accounts

Parameters

{
  "data": {
    "type": "account",
    "attributes": {
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      }
    }
  }
}
Name Description
data[attributes][name] required A friendly name which identifies the account
data[attributes][metadata] Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

Response


201 Created
{
  "data": {
    "id": "b135b852-fa34-44c8-89e3-c04773d7cec5",
    "type": "account",
    "attributes": {
      "created_at": "2023-09-20T01:56:26Z",
      "updated_at": "2023-09-20T01:56:26Z",
      "name": "Rocket Rides",
      "metadata": {
        "foo": "bar"
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "oHo4qKRR-olHtxUqgPTcBP3ZslbMaMizJeOoLmhJZRU"
    }
  }
}

Delete an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/76477d9d-f48d-46de-9959-5f13a4b3adf4" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer meA21xAQptlrS5js0dr_bsGUJG2ZnjGACqkSOANghF8"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/accounts/76477d9d-f48d-46de-9959-5f13a4b3adf4

Parameters

None known.

Response


204 No Content

List all accounts

Request

curl -g "https://api.somleng.org/carrier/v1/accounts" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer FND7nSEj9OWusYLJ5ZVZ96K-s_7dvuPFvZoY2ucZlQ8"

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": "b87ecd86-55c0-4e9f-bf98-dbfa684a4808",
      "type": "account",
      "attributes": {
        "created_at": "2023-09-20T01:56:26Z",
        "updated_at": "2023-09-20T01:56:26Z",
        "name": "Telco Net",
        "metadata": {
        },
        "status": "enabled",
        "type": "carrier_managed",
        "auth_token": "coMb1Vh688kI6lTabflTFSxpyiSl24m-LVGUsMMbV-4"
      }
    },
    {
      "id": "10aed524-1b6c-471c-98b0-5ea746c385a9",
      "type": "account",
      "attributes": {
        "created_at": "2023-09-20T01:56:26Z",
        "updated_at": "2023-09-20T01:56:26Z",
        "name": "Rocket Rides",
        "metadata": {
        },
        "status": "enabled",
        "type": "customer_managed"
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/accounts?page%5Bbefore%5D=b87ecd86-55c0-4e9f-bf98-dbfa684a4808",
    "next": null
  }
}

Retrieve an account

Request

curl -g "https://api.somleng.org/carrier/v1/accounts/7d01dbd2-d39d-4536-8de9-62b32debeb3c" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer AnqVljAp_PCNVuEcLmZAsGCmduDleX2tuWcvvneCBe0"

Endpoint

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

GET https://api.somleng.org/carrier/v1/accounts/7d01dbd2-d39d-4536-8de9-62b32debeb3c

Parameters

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

Response


200 OK
{
  "data": {
    "id": "7d01dbd2-d39d-4536-8de9-62b32debeb3c",
    "type": "account",
    "attributes": {
      "created_at": "2023-09-20T01:56:26Z",
      "updated_at": "2023-09-20T01:56:26Z",
      "name": "Rocket Rides",
      "metadata": {
      },
      "status": "enabled",
      "type": "carrier_managed",
      "auth_token": "vhw65Sow-0J5iwI2lefuJKy341_kPGLeh6nDVxzna9k"
    }
  }
}

Update an account

Request

curl "https://api.somleng.org/carrier/v1/accounts/4be207a0-634f-4e31-a2d0-e6ae40ae6eca" -d '{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "4be207a0-634f-4e31-a2d0-e6ae40ae6eca"
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer shEnlo4o0mnWdHYH4e3RaFhpd0ndx4j7v8mIKYUUy_Q"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/accounts/4be207a0-634f-4e31-a2d0-e6ae40ae6eca

Parameters

{
  "data": {
    "attributes": {
      "status": null,
      "name": "Bob Cats",
      "status": "disabled",
      "metadata": {
        "bar": "foo"
      }
    },
    "type": "account",
    "id": "4be207a0-634f-4e31-a2d0-e6ae40ae6eca"
  }
}
Name Description
data[attributes][status] Update the status of the account. One of either enabled or disabled.

Response


200 OK
{
  "data": {
    "id": "4be207a0-634f-4e31-a2d0-e6ae40ae6eca",
    "type": "account",
    "attributes": {
      "created_at": "2023-09-20T01:56:26Z",
      "updated_at": "2023-09-20T01:56:26Z",
      "name": "Bob Cats",
      "metadata": {
        "foo": "bar",
        "bar": "foo"
      },
      "status": "disabled",
      "type": "carrier_managed",
      "auth_token": "aeHlJ7Fhlst5R-D4XHjc1PtBP759DaRcqB9HaE6zI1U"
    }
  }
}

Events

List all events

Types of events

This is a list of all the types of events we currently send. We may add more at any time, so in developing and maintaining your code, you should not assume that only these types exist.

You'll notice that these events follow a pattern: resource.event. Our goal is to design a consistent system that makes things easier to anticipate and code against.

Event
phone_call.completed
message.sent
message.delivered

Request

curl -g "https://api.somleng.org/carrier/v1/events" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer vwTDTQTNZHpzWWbsn4wHAp5pzfxNPEvS6m5UjvFoBus"

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": "38e28cbd-ca78-4fdd-bec4-87b85d2d8530",
      "type": "event",
      "attributes": {
        "created_at": "2023-09-20T01:56:24Z",
        "updated_at": "2023-09-20T01:56:24Z",
        "type": "phone_call.completed",
        "details": {
          "data": {
            "id": "00c59cde-5fa6-480f-a2fd-fb7ed7829689",
            "type": "phone_call",
            "attributes": {
              "to": "+85512334667",
              "sid": "00c59cde-5fa6-480f-a2fd-fb7ed7829689",
              "from": "2442",
              "price": null,
              "status": "queued",
              "duration": null,
              "direction": "outbound-api",
              "created_at": "2023-09-20T01:56:24Z",
              "price_unit": null,
              "updated_at": "2023-09-20T01:56:24Z",
              "account_sid": "df76373d-8840-47b0-99d2-70636c66cce9"
            }
          }
        }
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/events?page%5Bbefore%5D=38e28cbd-ca78-4fdd-bec4-87b85d2d8530",
    "next": null
  }
}

Retrieve an Event

Request

curl -g "https://api.somleng.org/carrier/v1/events/7a525532-938c-4d56-86b3-959f2f2e4a2a" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer x7bkTqQOmdieD5X_H8vS3gpJ5Yw5DxE_UGg31tBKoic"

Endpoint

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

GET https://api.somleng.org/carrier/v1/events/7a525532-938c-4d56-86b3-959f2f2e4a2a

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "7a525532-938c-4d56-86b3-959f2f2e4a2a",
    "type": "event",
    "attributes": {
      "created_at": "2023-09-20T01:56:24Z",
      "updated_at": "2023-09-20T01:56:24Z",
      "type": "phone_call.completed",
      "details": {
        "data": {
          "id": "7b65fa50-b51e-4075-b2ba-edcf73c7a335",
          "type": "phone_call",
          "attributes": {
            "to": "+85512334667",
            "sid": "7b65fa50-b51e-4075-b2ba-edcf73c7a335",
            "from": "2442",
            "price": null,
            "status": "queued",
            "duration": null,
            "direction": "outbound-api",
            "created_at": "2023-09-20T01:56:24Z",
            "price_unit": null,
            "updated_at": "2023-09-20T01:56:24Z",
            "account_sid": "503e2a49-8482-405d-acd7-73bbd1a2ccbf"
          }
        }
      }
    }
  }
}

Messages

List messages

Request

curl -g "https://api.somleng.org/carrier/v1/messages?filter[status]=sent&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T11%3A00%3A00Z&filter[account]=fb647581-ff71-4d14-b85a-b72f438051ee&filter[direction]=outbound-api" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 30m05i5Ght2fcp1Nxjf492AADsoVLa-nsSVQbvGLyN4"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages?filter[status]=sent&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T11%3A00%3A00Z&filter[account]=fb647581-ff71-4d14-b85a-b72f438051ee&filter[direction]=outbound-api

Parameters

filter: {"status"=>"sent", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T11:00:00Z", "account"=>"fb647581-ff71-4d14-b85a-b72f438051ee", "direction"=>"outbound-api"}
Name Description
filter[account] Return messages from the provided account-sid
filter[from_date] Return messages on or after the provided date/time in ISO 8601 format.
filter[to_date] Return messages on or before the provided date/time in ISO 8601 format.
filter[direction] One of inbound, outbound-api, outbound-call, and outbound-reply
filter[status] One of accepted, scheduled, queued, sending, sent, failed, received, canceled, and delivered

Response


200 OK
{
  "data": [
    {
      "id": "3a645c71-d654-4484-bdbc-2e153b85d7c8",
      "type": "message",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2023-09-20T01:56:14Z",
        "to": "+85512334667",
        "from": "2442",
        "sid": "3a645c71-d654-4484-bdbc-2e153b85d7c8",
        "account_sid": "fb647581-ff71-4d14-b85a-b72f438051ee",
        "price": null,
        "price_unit": null,
        "direction": "outbound-api",
        "status": "sent",
        "body": "Hello World"
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/messages?filter%5Baccount%5D=fb647581-ff71-4d14-b85a-b72f438051ee&filter%5Bdirection%5D=outbound-api&filter%5Bfrom_date%5D=2021-11-01T00%3A00%3A00Z&filter%5Bstatus%5D=sent&filter%5Bto_date%5D=2021-11-01T11%3A00%3A00Z&page%5Bbefore%5D=3a645c71-d654-4484-bdbc-2e153b85d7c8",
    "next": null
  }
}

Retrieve a message

Request

curl -g "https://api.somleng.org/carrier/v1/messages/2186dbe9-9bbc-4ad2-9072-a287e416c294" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer ckgvSNLwBgGJxT0h3_vE5vnFR0CtSA9wUIXbmMhuLCU"

Endpoint

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

GET https://api.somleng.org/carrier/v1/messages/2186dbe9-9bbc-4ad2-9072-a287e416c294

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "2186dbe9-9bbc-4ad2-9072-a287e416c294",
    "type": "message",
    "attributes": {
      "created_at": "2023-09-20T01:56:14Z",
      "updated_at": "2023-09-20T01:56:14Z",
      "to": "+85512334667",
      "from": "2442",
      "sid": "2186dbe9-9bbc-4ad2-9072-a287e416c294",
      "account_sid": "8dc8a284-b0ba-41e9-a746-f256ce22dab3",
      "price": null,
      "price_unit": null,
      "direction": "outbound-api",
      "status": "accepted",
      "body": "Hello World"
    }
  }
}

Update a message

Request

curl "https://api.somleng.org/carrier/v1/messages/6473a432-1564-4502-8a78-6bfe928d94e5" -d '{
  "data": {
    "id": "6473a432-1564-4502-8a78-6bfe928d94e5",
    "type": "message",
    "attributes": {
      "price": "-0.05",
      "price_unit": "USD"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Mm_OMTAO3DiwiNR248ivDJLl-5MSHKSSU5zw0hlXZYo"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/messages/6473a432-1564-4502-8a78-6bfe928d94e5

Parameters

{
  "data": {
    "id": "6473a432-1564-4502-8a78-6bfe928d94e5",
    "type": "message",
    "attributes": {
      "price": "-0.05",
      "price_unit": "USD"
    }
  }
}
Name Description
data[attributes][price] The charge for this message.
data[attributes][price_unit] The currency in which price is measured, in ISO 4127 format. (e.g., USD, EUR, JPY). Always capitalized for messages.

Response


200 OK
{
  "data": {
    "id": "6473a432-1564-4502-8a78-6bfe928d94e5",
    "type": "message",
    "attributes": {
      "created_at": "2023-09-20T01:56:14Z",
      "updated_at": "2023-09-20T01:56:14Z",
      "to": "+85512334667",
      "from": "2442",
      "sid": "6473a432-1564-4502-8a78-6bfe928d94e5",
      "account_sid": "34901f12-2f99-4222-ab67-c06d09b474ee",
      "price": "-0.05",
      "price_unit": "USD",
      "direction": "outbound-api",
      "status": "sent",
      "body": "Hello World"
    }
  }
}

Phone Calls

List phone calls

Request

curl -g "https://api.somleng.org/carrier/v1/phone_calls?filter[status]=queued&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T11%3A00%3A00Z&filter[account]=e18c7712-e7a0-43c8-9068-be44e2725f28&filter[direction]=outbound-api" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer WTGea6dVJAbuOUWHSgB3Kj0UuadlLQJ3YMiN5aQE4No"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls?filter[status]=queued&filter[from_date]=2021-11-01T00%3A00%3A00Z&filter[to_date]=2021-11-01T11%3A00%3A00Z&filter[account]=e18c7712-e7a0-43c8-9068-be44e2725f28&filter[direction]=outbound-api

Parameters

filter: {"status"=>"queued", "from_date"=>"2021-11-01T00:00:00Z", "to_date"=>"2021-11-01T11:00:00Z", "account"=>"e18c7712-e7a0-43c8-9068-be44e2725f28", "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": "b87482b7-0565-4462-97a8-106df8bd7073",
      "type": "phone_call",
      "attributes": {
        "created_at": "2021-11-01T01:00:00Z",
        "updated_at": "2023-09-20T01:56:20Z",
        "to": "+85512334667",
        "from": "2442",
        "sid": "b87482b7-0565-4462-97a8-106df8bd7073",
        "account_sid": "e18c7712-e7a0-43c8-9068-be44e2725f28",
        "price": null,
        "price_unit": null,
        "duration": null,
        "direction": "outbound-api",
        "status": "queued"
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_calls?filter%5Baccount%5D=e18c7712-e7a0-43c8-9068-be44e2725f28&filter%5Bdirection%5D=outbound-api&filter%5Bfrom_date%5D=2021-11-01T00%3A00%3A00Z&filter%5Bstatus%5D=queued&filter%5Bto_date%5D=2021-11-01T11%3A00%3A00Z&page%5Bbefore%5D=b87482b7-0565-4462-97a8-106df8bd7073",
    "next": null
  }
}

Retrieve a phone call

Request

curl -g "https://api.somleng.org/carrier/v1/phone_calls/8282ed8c-7e61-4c76-be67-226e56a640e9" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Povon2i7p_xp8uWFK3YjYKBH-XayZ_yrHeZqVg0Yzak"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_calls/8282ed8c-7e61-4c76-be67-226e56a640e9

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "8282ed8c-7e61-4c76-be67-226e56a640e9",
    "type": "phone_call",
    "attributes": {
      "created_at": "2023-09-20T01:56:20Z",
      "updated_at": "2023-09-20T01:56:20Z",
      "to": "+85512334667",
      "from": "2442",
      "sid": "8282ed8c-7e61-4c76-be67-226e56a640e9",
      "account_sid": "24bf4331-d146-465b-a17e-ee5d3b18a1bd",
      "price": null,
      "price_unit": null,
      "duration": null,
      "direction": "outbound-api",
      "status": "queued"
    }
  }
}

Update a phone call

Request

curl "https://api.somleng.org/carrier/v1/phone_calls/15876c4e-bf50-46a6-bdd3-fad0a7115125" -d '{
  "data": {
    "id": "15876c4e-bf50-46a6-bdd3-fad0a7115125",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05",
      "price_unit": "USD"
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer Y7049wodp-NjNGw5cxxmy_ZSj2Kbdy1dsB-egrMlXS0"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_calls/15876c4e-bf50-46a6-bdd3-fad0a7115125

Parameters

{
  "data": {
    "id": "15876c4e-bf50-46a6-bdd3-fad0a7115125",
    "type": "phone_call",
    "attributes": {
      "price": "-0.05",
      "price_unit": "USD"
    }
  }
}
Name Description
data[attributes][price] The charge for this call.
data[attributes][price_unit] The currency in which price is measured, in ISO 4127 format. (e.g., USD, EUR, JPY). Always capitalized for calls.

Response


200 OK
{
  "data": {
    "id": "15876c4e-bf50-46a6-bdd3-fad0a7115125",
    "type": "phone_call",
    "attributes": {
      "created_at": "2023-09-20T01:56:20Z",
      "updated_at": "2023-09-20T01:56:20Z",
      "to": "+85512334667",
      "from": "2442",
      "sid": "15876c4e-bf50-46a6-bdd3-fad0a7115125",
      "account_sid": "f3009bb9-c028-4765-9156-c9178150aa1f",
      "price": "-0.05",
      "price_unit": "USD",
      "duration": "5",
      "direction": "outbound-api",
      "status": "completed"
    }
  }
}

Phone Numbers

Assign an account to a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/f5cc9a72-a50f-4b86-8d56-2f1bdd686951" -d '{
  "data": {
    "type": "phone_number",
    "id": "f5cc9a72-a50f-4b86-8d56-2f1bdd686951",
    "relationships": {
      "account": {
        "data": {
          "type": "account",
          "id": "c6340548-eb79-40c4-a89d-3f1e7807eb62"
        }
      }
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer PO9ye2e8UWHXejDqWm6nQDWY3jxalfgWErFvdmghCbA"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/f5cc9a72-a50f-4b86-8d56-2f1bdd686951

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "f5cc9a72-a50f-4b86-8d56-2f1bdd686951",
    "relationships": {
      "account": {
        "data": {
          "type": "account",
          "id": "c6340548-eb79-40c4-a89d-3f1e7807eb62"
        }
      }
    }
  }
}
Name Description
data[relationships][account] The id of the account to associate the phone number with.

Response


200 OK
{
  "data": {
    "id": "f5cc9a72-a50f-4b86-8d56-2f1bdd686951",
    "type": "phone_number",
    "attributes": {
      "created_at": "2023-09-20T01:55:45Z",
      "updated_at": "2023-09-20T01:55:45Z",
      "number": "855972345696",
      "enabled": true
    },
    "relationships": {
      "account": {
        "data": {
          "id": "c6340548-eb79-40c4-a89d-3f1e7807eb62",
          "type": "account"
        }
      }
    }
  }
}

Create a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers" -d '{
  "data": {
    "type": "phone_number",
    "attributes": {
      "number": "1294"
    },
    "relationships": {
      "account": {
        "data": {
          "type": "account",
          "id": "5cfcb193-76ba-407c-81f7-4db3ed4289da"
        }
      }
    }
  }
}' -X POST \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer p6rcBupcLFvfW1t51QXFCe7T4BMJvyOk2mKGAS1S0pA"

Endpoint

POST https://api.somleng.org/carrier/v1/phone_numbers

POST https://api.somleng.org/carrier/v1/phone_numbers

Parameters

{
  "data": {
    "type": "phone_number",
    "attributes": {
      "number": "1294"
    },
    "relationships": {
      "account": {
        "data": {
          "type": "account",
          "id": "5cfcb193-76ba-407c-81f7-4db3ed4289da"
        }
      }
    }
  }
}
Name Description
data[attributes][number] required Phone number or shortcode.
data[attributes][enabled] Set to false to disable this number. Disabled phone numbers cannot be used by accounts. Enabled by default.
data[relationships][account] The id of the account to associate the phone number with.

Response


201 Created
{
  "data": {
    "id": "ee038983-d7a2-4462-b56c-2a13731f5d89",
    "type": "phone_number",
    "attributes": {
      "created_at": "2023-09-20T01:55:45Z",
      "updated_at": "2023-09-20T01:55:45Z",
      "number": "1294",
      "enabled": true
    },
    "relationships": {
      "account": {
        "data": {
          "id": "5cfcb193-76ba-407c-81f7-4db3ed4289da",
          "type": "account"
        }
      }
    }
  }
}

Delete a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/176aefd5-9827-4fcf-97bc-f691ac5769f9" -d '' -X DELETE \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer SHQOtA8kQPl-meM_rAQu8r2fFh-MT1qMdu47GfLvQXI"

Endpoint

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

DELETE https://api.somleng.org/carrier/v1/phone_numbers/176aefd5-9827-4fcf-97bc-f691ac5769f9

Parameters

None known.

Response


204 No Content

List all phone numbers

Request

curl -g "https://api.somleng.org/carrier/v1/phone_numbers" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 7gws5wKLUegpDwi_dBUC_1VcwRxP1SHMZw79imktQLw"

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": "84dd449e-64ee-4fe8-8c70-403afc4b6afe",
      "type": "phone_number",
      "attributes": {
        "created_at": "2023-09-20T01:55:45Z",
        "updated_at": "2023-09-20T01:55:45Z",
        "number": "855972345690",
        "enabled": true
      },
      "relationships": {
      }
    },
    {
      "id": "c28284f3-f963-411c-baec-1da075b31048",
      "type": "phone_number",
      "attributes": {
        "created_at": "2023-09-20T01:55:45Z",
        "updated_at": "2023-09-20T01:55:45Z",
        "number": "855972345689",
        "enabled": true
      },
      "relationships": {
      }
    }
  ],
  "links": {
    "prev": "https://api.somleng.org/carrier/v1/phone_numbers?page%5Bbefore%5D=84dd449e-64ee-4fe8-8c70-403afc4b6afe",
    "next": null
  }
}

Release a phone number

Releases a phone number by unassigning the account and removing any configuration.

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/adc8c171-1571-47f7-bf91-9f12844e7312/release" -d '' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer _6Db18bvgBRBQAa_z21knwny7oRwZu3-4wlZCtefR7I"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/adc8c171-1571-47f7-bf91-9f12844e7312/release

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "adc8c171-1571-47f7-bf91-9f12844e7312",
    "type": "phone_number",
    "attributes": {
      "created_at": "2023-09-20T01:55:45Z",
      "updated_at": "2023-09-20T01:55:45Z",
      "number": "855972345694",
      "enabled": true
    },
    "relationships": {
    }
  }
}

Retrieve a phone number

Request

curl -g "https://api.somleng.org/carrier/v1/phone_numbers/38fe9a3c-0c99-4b63-a8ba-f1edcaae8ddc" -X GET \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer 7tiCU7ulOdZFHzNSjOGGO_1kdhnFGmDO4xaegws7gXc"

Endpoint

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

GET https://api.somleng.org/carrier/v1/phone_numbers/38fe9a3c-0c99-4b63-a8ba-f1edcaae8ddc

Parameters

None known.

Response


200 OK
{
  "data": {
    "id": "38fe9a3c-0c99-4b63-a8ba-f1edcaae8ddc",
    "type": "phone_number",
    "attributes": {
      "created_at": "2023-09-20T01:55:45Z",
      "updated_at": "2023-09-20T01:55:45Z",
      "number": "855972345692",
      "enabled": true
    },
    "relationships": {
    }
  }
}

Update a phone number

Request

curl "https://api.somleng.org/carrier/v1/phone_numbers/b6ef265a-745b-4708-a424-7220e102a720" -d '{
  "data": {
    "type": "phone_number",
    "id": "b6ef265a-745b-4708-a424-7220e102a720",
    "attributes": {
      "enabled": false
    }
  }
}' -X PATCH \
    -H "Content-Type: application/vnd.api+json" \
    -H "Authorization: Bearer PA9Pzt7eBFv8_5mzSNsigdkJfgGHpAAkLk_ETcRJSls"

Endpoint

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

PATCH https://api.somleng.org/carrier/v1/phone_numbers/b6ef265a-745b-4708-a424-7220e102a720

Parameters

{
  "data": {
    "type": "phone_number",
    "id": "b6ef265a-745b-4708-a424-7220e102a720",
    "attributes": {
      "enabled": false
    }
  }
}
Name Description
data[attributes][enabled] Set to false to disable the phone number or true to enable it. Disabled phone numbers cannot be used by accounts.

Response


200 OK
{
  "data": {
    "id": "b6ef265a-745b-4708-a424-7220e102a720",
    "type": "phone_number",
    "attributes": {
      "created_at": "2023-09-20T01:55:45Z",
      "updated_at": "2023-09-20T01:55:45Z",
      "number": "855972345695",
      "enabled": false
    },
    "relationships": {
    }
  }
}