NAV
cURL

Introduction

Dive into our full API Reference Documentation and seamlessly integrate Voice and SMS functionalities into your website or application. This API uses HTTP verbs and a RESTful endpoint structure. Your Account SID and Auth Token is used as the API Authorization framework. Request and response payloads are formatted as JSON using UTF-8 encoding and URL encoded values.

Make an HTTP Request

There are a lot of ways you can make an HTTP request to Somleng. You can use a Helper Library or SDK for your preferred programming language or you can make a raw HTTP request in your code by using a tool like Postman.

Credentials

All requests to Somleng need to be authenticated. Somleng using HTTP basic auth, which use the following username/password schemes:

Account SID and Auth Token

The account SID and auth token are the master keys to your account.

Username Password
AccountSid AuthToken

Store Your Somleng Credentials Securely

It's important to keep credentials such as your Somleng Account SID and Auth token secure by storing them in a way that prevents unauthorized access. One common method is to store them in environment variables which are then accessed from your app. This keeps them out of code and other places where credentials don't belong.

On the right is an example in Node.js ---->

const accountSid = process.env.SOMLENG_ACCOUNT_SID;
const authToken = process.env.SOMLENG_AUTH_TOKEN;
const client = require('somleng')(accountSid, authToken);

// Make API calls here...

Helper Libraries

The following is a list of officially supported helper libraries for Somleng. Please refer to the documentation in each library for more details.

Demo Applications

The following is a list of demo applications which you can use to get started with Somleng.

Accounts

1. Fetch an account

Returns a representation of an account, including the properties above.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/7034b25d-dc60-4488-b506-b9aeee21e0bd" \
    -u 7034b25d-dc60-4488-b506-b9aeee21e0bd:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:Sid

GET https://api.somleng.org/2010-04-01/Accounts/7034b25d-dc60-4488-b506-b9aeee21e0bd

Parameters

Name Description
Sid Path Parameter: The Account Sid that uniquely identifies the account to fetch.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "7034b25d-dc60-4488-b506-b9aeee21e0bd",
  "date_created": "Thu, 30 May 2024 07:53:15 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:15 -0000",
  "auth_token": "boE5sEIHbh-YrzQ4bgjNB_WPNcFN92otQpC8yDBkmh4",
  "friendly_name": "Rocket Rides",
  "owner_account_sid": "7034b25d-dc60-4488-b506-b9aeee21e0bd",
  "status": "active",
  "type": "Full",
  "uri": "/2010-04-01/Accounts/7034b25d-dc60-4488-b506-b9aeee21e0bd",
  "subresource_uris": {
    "calls": "/2010-04-01/Accounts/7034b25d-dc60-4488-b506-b9aeee21e0bd/Calls",
    "messages": "/2010-04-01/Accounts/7034b25d-dc60-4488-b506-b9aeee21e0bd/Messages",
    "recordings": "/2010-04-01/Accounts/7034b25d-dc60-4488-b506-b9aeee21e0bd/Recordings"
  }
}

Available Phone Numbers

1. List the available Local phone numbers for a specific country

This API lets you search for Local phone numbers that are available for you to purchase.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/9c021d63-2fcc-4d89-b3cb-98556c44cd68/AvailablePhoneNumbers/CA/Local" \
    -u 9c021d63-2fcc-4d89-b3cb-98556c44cd68:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/9c021d63-2fcc-4d89-b3cb-98556c44cd68/AvailablePhoneNumbers/CA/Local

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "+1 (251) 309-5500",
      "phone_number": "+12513095500",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": null,
      "region": null,
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/9c021d63-2fcc-4d89-b3cb-98556c44cd68/AvailablePhoneNumbers/CA/Local",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/9c021d63-2fcc-4d89-b3cb-98556c44cd68/AvailablePhoneNumbers/CA/Local?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/9c021d63-2fcc-4d89-b3cb-98556c44cd68/AvailablePhoneNumbers/CA/Local?Page=0&PageToken=PBfab46427-3d9a-4728-8fc8-e2304e82846b",
  "next_page_uri": null
}

2. Find available local phone numbers by area code

Find available Local phone numbers in Canada in the 201 area code.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/9ed5c37b-5d3a-490b-99f7-d14b5d6b7053/AvailablePhoneNumbers/CA/Local?AreaCode=201" \
    -u 9ed5c37b-5d3a-490b-99f7-d14b5d6b7053:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/9ed5c37b-5d3a-490b-99f7-d14b5d6b7053/AvailablePhoneNumbers/CA/Local?AreaCode=201

Parameters

AreaCode: 201
Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "+1 (201) 309-5500",
      "phone_number": "+12013095500",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": null,
      "region": null,
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/9ed5c37b-5d3a-490b-99f7-d14b5d6b7053/AvailablePhoneNumbers/CA/Local?AreaCode=201",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/9ed5c37b-5d3a-490b-99f7-d14b5d6b7053/AvailablePhoneNumbers/CA/Local?AreaCode=201&Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/9ed5c37b-5d3a-490b-99f7-d14b5d6b7053/AvailablePhoneNumbers/CA/Local?AreaCode=201&Page=0&PageToken=PBcf28c9a7-a879-46be-bf46-2a5967e8ff61",
  "next_page_uri": null
}

3. Find available local phone numbers by region

Find available Local phone numbers in Ontario.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/83c621ec-40d6-4799-a439-99595b20e16e/AvailablePhoneNumbers/CA/Local?InRegion=ON" \
    -u 83c621ec-40d6-4799-a439-99595b20e16e:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/83c621ec-40d6-4799-a439-99595b20e16e/AvailablePhoneNumbers/CA/Local?InRegion=ON

Parameters

InRegion: ON
Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "+1 (647) 309-5500",
      "phone_number": "+16473095500",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": null,
      "region": "ON",
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/83c621ec-40d6-4799-a439-99595b20e16e/AvailablePhoneNumbers/CA/Local?InRegion=ON",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/83c621ec-40d6-4799-a439-99595b20e16e/AvailablePhoneNumbers/CA/Local?InRegion=ON&Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/83c621ec-40d6-4799-a439-99595b20e16e/AvailablePhoneNumbers/CA/Local?InRegion=ON&Page=0&PageToken=PB4dd56b4d-3dea-4c0c-a2db-3fe0d35008d5",
  "next_page_uri": null
}

4. Find available local phone numbers by locality

Find available Local phone numbers in Toronto.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/d467110d-e240-4c73-a7f3-00dacb64607b/AvailablePhoneNumbers/CA/Local?InLocality=Toronto" \
    -u d467110d-e240-4c73-a7f3-00dacb64607b:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/d467110d-e240-4c73-a7f3-00dacb64607b/AvailablePhoneNumbers/CA/Local?InLocality=Toronto

Parameters

InLocality: Toronto
Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "+1 (647) 309-5500",
      "phone_number": "+16473095500",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": "Toronto",
      "region": "ON",
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/d467110d-e240-4c73-a7f3-00dacb64607b/AvailablePhoneNumbers/CA/Local?InLocality=Toronto",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/d467110d-e240-4c73-a7f3-00dacb64607b/AvailablePhoneNumbers/CA/Local?InLocality=Toronto&Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/d467110d-e240-4c73-a7f3-00dacb64607b/AvailablePhoneNumbers/CA/Local?InLocality=Toronto&Page=0&PageToken=PBae65f991-aced-4ad4-b02f-622ca3888b4e",
  "next_page_uri": null
}

5. List the available Mobile phone numbers for a specific country

This API lets you search for Mobile phone numbers that are available for you to purchase.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/f9f3758c-c004-46d1-9a30-a9345dc5f8ad/AvailablePhoneNumbers/CA/Mobile" \
    -u f9f3758c-c004-46d1-9a30-a9345dc5f8ad:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/f9f3758c-c004-46d1-9a30-a9345dc5f8ad/AvailablePhoneNumbers/CA/Mobile

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "+1 (251) 309-5500",
      "phone_number": "+12513095500",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": null,
      "region": null,
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/f9f3758c-c004-46d1-9a30-a9345dc5f8ad/AvailablePhoneNumbers/CA/Mobile",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/f9f3758c-c004-46d1-9a30-a9345dc5f8ad/AvailablePhoneNumbers/CA/Mobile?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/f9f3758c-c004-46d1-9a30-a9345dc5f8ad/AvailablePhoneNumbers/CA/Mobile?Page=0&PageToken=PBc1af93d3-fe0e-406e-ac11-065280a78f2d",
  "next_page_uri": null
}

6. List the available Toll Free phone numbers for a specific country

This API lets you search for TollFree phone numbers that are available for you to purchase.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/2de6b7bf-3e0a-4d27-8b73-daeb2ec6b59e/AvailablePhoneNumbers/CA/TollFree" \
    -u 2de6b7bf-3e0a-4d27-8b73-daeb2ec6b59e:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/2de6b7bf-3e0a-4d27-8b73-daeb2ec6b59e/AvailablePhoneNumbers/CA/TollFree

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "+1 (877) 731-8091",
      "phone_number": "+18777318091",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": null,
      "region": null,
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/2de6b7bf-3e0a-4d27-8b73-daeb2ec6b59e/AvailablePhoneNumbers/CA/TollFree",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/2de6b7bf-3e0a-4d27-8b73-daeb2ec6b59e/AvailablePhoneNumbers/CA/TollFree?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/2de6b7bf-3e0a-4d27-8b73-daeb2ec6b59e/AvailablePhoneNumbers/CA/TollFree?Page=0&PageToken=PBb2b4c636-c9ff-415d-beb5-786b9232537e",
  "next_page_uri": null
}

7. List the available Short Code numbers for a specific country

This API lets you search for Short Code phone numbers that are available for you to purchase.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/8322a101-02ab-459a-a9bf-8a54fd5e7478/AvailablePhoneNumbers/CA/ShortCode" \
    -u 8322a101-02ab-459a-a9bf-8a54fd5e7478:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type

GET https://api.somleng.org/2010-04-01/Accounts/8322a101-02ab-459a-a9bf-8a54fd5e7478/AvailablePhoneNumbers/CA/ShortCode

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account requesting the AvailablePhoneNumber resources.
CountryCode Path Parameter: The ISO-3166-1 country code of the country from which to read phone numbers.
Type Path Parameter: Type of phone numbers to read. One of ShortCode, Local, Mobile, TollFree.
AreaCode Query Parameter: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
InRegion Query Parameter: Limit results to a particular region, state, or province.
InLocality Query Parameter: Limit results to a particular locality or city.

Response


200 OK
{
  "available_phone_numbers": [
    {
      "friendly_name": "1294",
      "phone_number": "1294",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "locality": null,
      "region": null,
      "postal_code": null,
      "iso_country": "CA",
      "address_requirements": "none",
      "beta": false,
      "capabilities": {
        "voice": true,
        "SMS": true,
        "MMS": false
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/8322a101-02ab-459a-a9bf-8a54fd5e7478/AvailablePhoneNumbers/CA/ShortCode",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/8322a101-02ab-459a-a9bf-8a54fd5e7478/AvailablePhoneNumbers/CA/ShortCode?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/8322a101-02ab-459a-a9bf-8a54fd5e7478/AvailablePhoneNumbers/CA/ShortCode?Page=0&PageToken=PB2f56bb0e-65f8-46b5-8377-4223e00f6098",
  "next_page_uri": null
}

8. Read a list of countries

You can query the AvailablePhoneNumbers to get a list of subresources available for your account by ISO Country. This API gets the subresources available for all supported countries.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers" \
    -u 4342576a-6e24-47b4-82a8-7547a7428ccc:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers

GET https://api.somleng.org/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account requesting the available phone number Country resources.

Response


200 OK
{
  "countries": [
    {
      "country_code": "CA",
      "country": "Canada",
      "uri": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/CA",
      "beta": false,
      "subresource_uris": {
        "short_code": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/CA/ShortCode",
        "local": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/CA/Local",
        "mobile": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/CA/Mobile",
        "toll_free": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/CA/TollFree"
      }
    },
    {
      "country_code": "KH",
      "country": "Cambodia",
      "uri": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/KH",
      "beta": false,
      "subresource_uris": {
        "short_code": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/KH/ShortCode",
        "local": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/KH/Local",
        "mobile": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/KH/Mobile",
        "toll_free": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers/KH/TollFree"
      }
    }
  ],
  "uri": "/2010-04-01/Accounts/4342576a-6e24-47b4-82a8-7547a7428ccc/AvailablePhoneNumbers"
}

9. Fetch a specific country

Fetch the subresources available for a specific country. The subresources will contain a list of endpoints which can be used to fetch available phone numbers for that country.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA" \
    -u dbf7ceb2-04a6-4200-881d-232c01a2b867:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode

GET https://api.somleng.org/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account requesting the available phone number Country resource.
CountryCode Path Parameter: The ISO-3166-1 country code of the country to fetch available phone number information about.

Response


200 OK
{
  "country_code": "CA",
  "country": "Canada",
  "uri": "/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA",
  "beta": false,
  "subresource_uris": {
    "short_code": "/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA/ShortCode",
    "local": "/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA/Local",
    "mobile": "/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA/Mobile",
    "toll_free": "/2010-04-01/Accounts/dbf7ceb2-04a6-4200-881d-232c01a2b867/AvailablePhoneNumbers/CA/TollFree"
  }
}

Incoming Phone Numbers

An IncomingPhoneNumber resource represents a phone number provisioned to your account. The IncomingPhoneNumbers list resource represents an account's phone numbers. You can POST to the list resource to provision a new number. To find a new number to provision use the subresources of the [Available Phone Numbers] resource.

1. Provision a Phone Number

You can POST to this API to provision a new phone number. To find a new number to provision use the Available Phone Numbers API.

You will be charged when you provision the number, and the number will appear on the Active Numbers page in the console.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/a180227d-36a9-4875-b457-41e5f0ef28f1/IncomingPhoneNumbers" \
    -u a180227d-36a9-4875-b457-41e5f0ef28f1:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "PhoneNumber=+12513095500"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers

POST https://api.somleng.org/2010-04-01/Accounts/a180227d-36a9-4875-b457-41e5f0ef28f1/IncomingPhoneNumbers

Parameters

{
  "PhoneNumber": "+12513095500"
}
Name Description
AccountSid Path Parameter: The SID of the Account that will create the resource.
PhoneNumber required Request Body Parameter: The phone number to purchase specified in E.164 format.
FriendlyName Request Body Parameter: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number.
SmsUrl Request Body Parameter: The URL we should call when the new phone number receives an incoming SMS message.
SmsMethod Request Body Parameter: The HTTP method that we should use to call sms_url. Can be: GET or POST and defaults to POST.
VoiceUrl Request Body Parameter: The URL that we should call to answer a call to the new phone number.
VoiceMethod Request Body Parameter: The HTTP method that we should use to call voice_url. Can be: GET or POST and defaults to POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application.
StatusCallbackMethod Request Body Parameter: The HTTP method we should use to call status_callback. Can be: GET or POST and defaults to POST.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "d444a4c5-ecde-4f99-895d-6901f1ce69fa",
  "date_created": "Thu, 30 May 2024 07:53:00 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:00 -0000",
  "account_sid": "a180227d-36a9-4875-b457-41e5f0ef28f1",
  "address_requirements": "none",
  "address_sid": null,
  "beta": false,
  "capabilities": {
    "voice": true,
    "sms": true,
    "mms": false,
    "fax": false
  },
  "emergency_status": "Inactive",
  "emergency_address_sid": null,
  "emergency_address_status": "unregistered",
  "friendly_name": "+1 (251) 309-5500",
  "identity_sid": null,
  "origin": "hosted",
  "phone_number": "+12513095500",
  "sms_application_sid": null,
  "sms_fallback_method": "POST",
  "sms_fallback_url": null,
  "sms_method": "POST",
  "sms_url": null,
  "status_callback": null,
  "status_callback_method": "POST",
  "trunk_sid": null,
  "uri": "/2010-04-01/Accounts/a180227d-36a9-4875-b457-41e5f0ef28f1/IncomingPhoneNumbers/d444a4c5-ecde-4f99-895d-6901f1ce69fa",
  "voice_application_sid": null,
  "voice_caller_id_lookup": false,
  "voice_fallback_method": "POST",
  "voice_fallback_url": null,
  "voice_method": "POST",
  "voice_url": null,
  "bundle_sid": null,
  "voice_receive_mode": "voice",
  "status": "in-use"
}

2. Provision a Phone Number with a Voice URL

You will receive a HTTP request to this URL when a call comes in to your phone number.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/6e5c3bac-cc3a-4602-b485-f082caca0613/IncomingPhoneNumbers" \
    -u 6e5c3bac-cc3a-4602-b485-f082caca0613:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "PhoneNumber=+12513095500" \
    --data-urlencode "VoiceUrl=https://www.your-voice-url.com/example"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers

POST https://api.somleng.org/2010-04-01/Accounts/6e5c3bac-cc3a-4602-b485-f082caca0613/IncomingPhoneNumbers

Parameters

{
  "PhoneNumber": "+12513095500",
  "VoiceUrl": "https://www.your-voice-url.com/example"
}
Name Description
AccountSid Path Parameter: The SID of the Account that will create the resource.
PhoneNumber required Request Body Parameter: The phone number to purchase specified in E.164 format.
FriendlyName Request Body Parameter: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number.
SmsUrl Request Body Parameter: The URL we should call when the new phone number receives an incoming SMS message.
SmsMethod Request Body Parameter: The HTTP method that we should use to call sms_url. Can be: GET or POST and defaults to POST.
VoiceUrl Request Body Parameter: The URL that we should call to answer a call to the new phone number.
VoiceMethod Request Body Parameter: The HTTP method that we should use to call voice_url. Can be: GET or POST and defaults to POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application.
StatusCallbackMethod Request Body Parameter: The HTTP method we should use to call status_callback. Can be: GET or POST and defaults to POST.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "e7334364-857f-46f5-b83e-a1d89d8c7ff8",
  "date_created": "Thu, 30 May 2024 07:53:00 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:00 -0000",
  "account_sid": "6e5c3bac-cc3a-4602-b485-f082caca0613",
  "address_requirements": "none",
  "address_sid": null,
  "beta": false,
  "capabilities": {
    "voice": true,
    "sms": true,
    "mms": false,
    "fax": false
  },
  "emergency_status": "Inactive",
  "emergency_address_sid": null,
  "emergency_address_status": "unregistered",
  "friendly_name": "+1 (251) 309-5500",
  "identity_sid": null,
  "origin": "hosted",
  "phone_number": "+12513095500",
  "sms_application_sid": null,
  "sms_fallback_method": "POST",
  "sms_fallback_url": null,
  "sms_method": "POST",
  "sms_url": null,
  "status_callback": null,
  "status_callback_method": "POST",
  "trunk_sid": null,
  "uri": "/2010-04-01/Accounts/6e5c3bac-cc3a-4602-b485-f082caca0613/IncomingPhoneNumbers/e7334364-857f-46f5-b83e-a1d89d8c7ff8",
  "voice_application_sid": null,
  "voice_caller_id_lookup": false,
  "voice_fallback_method": "POST",
  "voice_fallback_url": null,
  "voice_method": "POST",
  "voice_url": "https://www.your-voice-url.com/example",
  "bundle_sid": null,
  "voice_receive_mode": "voice",
  "status": "in-use"
}

3. Provision a Phone Number with an SMS URL

You will receive a HTTP request to this URL when an SMS is sent to your phone number.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/a2e7b180-59fa-4827-acaa-b2ec98e313f1/IncomingPhoneNumbers" \
    -u a2e7b180-59fa-4827-acaa-b2ec98e313f1:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "PhoneNumber=+12513095500" \
    --data-urlencode "SmsUrl=https://www.your-sms-url.com/example"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers

POST https://api.somleng.org/2010-04-01/Accounts/a2e7b180-59fa-4827-acaa-b2ec98e313f1/IncomingPhoneNumbers

Parameters

{
  "PhoneNumber": "+12513095500",
  "SmsUrl": "https://www.your-sms-url.com/example"
}
Name Description
AccountSid Path Parameter: The SID of the Account that will create the resource.
PhoneNumber required Request Body Parameter: The phone number to purchase specified in E.164 format.
FriendlyName Request Body Parameter: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number.
SmsUrl Request Body Parameter: The URL we should call when the new phone number receives an incoming SMS message.
SmsMethod Request Body Parameter: The HTTP method that we should use to call sms_url. Can be: GET or POST and defaults to POST.
VoiceUrl Request Body Parameter: The URL that we should call to answer a call to the new phone number.
VoiceMethod Request Body Parameter: The HTTP method that we should use to call voice_url. Can be: GET or POST and defaults to POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application.
StatusCallbackMethod Request Body Parameter: The HTTP method we should use to call status_callback. Can be: GET or POST and defaults to POST.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "87a3bf18-2622-4cf7-9b0f-bb0fc742f44d",
  "date_created": "Thu, 30 May 2024 07:53:00 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:00 -0000",
  "account_sid": "a2e7b180-59fa-4827-acaa-b2ec98e313f1",
  "address_requirements": "none",
  "address_sid": null,
  "beta": false,
  "capabilities": {
    "voice": true,
    "sms": true,
    "mms": false,
    "fax": false
  },
  "emergency_status": "Inactive",
  "emergency_address_sid": null,
  "emergency_address_status": "unregistered",
  "friendly_name": "+1 (251) 309-5500",
  "identity_sid": null,
  "origin": "hosted",
  "phone_number": "+12513095500",
  "sms_application_sid": null,
  "sms_fallback_method": "POST",
  "sms_fallback_url": null,
  "sms_method": "POST",
  "sms_url": "https://www.your-sms-url.com/example",
  "status_callback": null,
  "status_callback_method": "POST",
  "trunk_sid": null,
  "uri": "/2010-04-01/Accounts/a2e7b180-59fa-4827-acaa-b2ec98e313f1/IncomingPhoneNumbers/87a3bf18-2622-4cf7-9b0f-bb0fc742f44d",
  "voice_application_sid": null,
  "voice_caller_id_lookup": false,
  "voice_fallback_method": "POST",
  "voice_fallback_url": null,
  "voice_method": "POST",
  "voice_url": null,
  "bundle_sid": null,
  "voice_receive_mode": "voice",
  "status": "in-use"
}

4. Fetch an IncomingPhoneNumber resource

Fetch an IncomingPhoneNumber

Request

curl "https://api.somleng.org/2010-04-01/Accounts/8d397875-c438-4c3d-990f-d2361ef50d91/IncomingPhoneNumbers/2329435c-7d87-4ab6-b7b7-8b5745cabcb8" \
    -u 8d397875-c438-4c3d-990f-d2361ef50d91:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers/:Sid

GET https://api.somleng.org/2010-04-01/Accounts/8d397875-c438-4c3d-990f-d2361ef50d91/IncomingPhoneNumbers/2329435c-7d87-4ab6-b7b7-8b5745cabcb8

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account that created the IncomingPhoneNumber resource to fetch.
Sid Path Parameter: The SID of the IncomingPhoneNumber resource to be fetched.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "2329435c-7d87-4ab6-b7b7-8b5745cabcb8",
  "date_created": "Thu, 30 May 2024 07:53:00 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:00 -0000",
  "account_sid": "8d397875-c438-4c3d-990f-d2361ef50d91",
  "address_requirements": "none",
  "address_sid": null,
  "beta": false,
  "capabilities": {
    "voice": true,
    "sms": true,
    "mms": false,
    "fax": false
  },
  "emergency_status": "Inactive",
  "emergency_address_sid": null,
  "emergency_address_status": "unregistered",
  "friendly_name": "+1 (251) 309-5500",
  "identity_sid": null,
  "origin": "hosted",
  "phone_number": "+12513095500",
  "sms_application_sid": null,
  "sms_fallback_method": "POST",
  "sms_fallback_url": null,
  "sms_method": "POST",
  "sms_url": null,
  "status_callback": null,
  "status_callback_method": "POST",
  "trunk_sid": null,
  "uri": "/2010-04-01/Accounts/8d397875-c438-4c3d-990f-d2361ef50d91/IncomingPhoneNumbers/2329435c-7d87-4ab6-b7b7-8b5745cabcb8",
  "voice_application_sid": null,
  "voice_caller_id_lookup": false,
  "voice_fallback_method": "POST",
  "voice_fallback_url": null,
  "voice_method": "POST",
  "voice_url": null,
  "bundle_sid": null,
  "voice_receive_mode": "voice",
  "status": "in-use"
}

5. Read a list of Incoming Phone Numbers

List all IncomingPhoneNumber resources for your account.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/8cc8ac8b-e238-445c-8b96-f01b47fcd691/IncomingPhoneNumbers?PhoneNumber=%2B12513095500" \
    -u 8cc8ac8b-e238-445c-8b96-f01b47fcd691:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers

GET https://api.somleng.org/2010-04-01/Accounts/8cc8ac8b-e238-445c-8b96-f01b47fcd691/IncomingPhoneNumbers?PhoneNumber=%2B12513095500

Parameters

PhoneNumber: +12513095500
Name Description
AccountSid Path Parameter: The SID of the Account that created the IncomingPhoneNumber resource to read.
PhoneNumber Query Parameter: The phone number of the IncomingPhoneNumber resources to read.

Response


200 OK
{
  "incoming_phone_numbers": [
    {
      "api_version": "2010-04-01",
      "sid": "7d600bdb-6fc0-446e-b4af-84d2a67f0026",
      "date_created": "Thu, 30 May 2024 07:53:00 -0000",
      "date_updated": "Thu, 30 May 2024 07:53:00 -0000",
      "account_sid": "8cc8ac8b-e238-445c-8b96-f01b47fcd691",
      "address_requirements": "none",
      "address_sid": null,
      "beta": false,
      "capabilities": {
        "voice": true,
        "sms": true,
        "mms": false,
        "fax": false
      },
      "emergency_status": "Inactive",
      "emergency_address_sid": null,
      "emergency_address_status": "unregistered",
      "friendly_name": "+1 (251) 309-5500",
      "identity_sid": null,
      "origin": "hosted",
      "phone_number": "+12513095500",
      "sms_application_sid": null,
      "sms_fallback_method": "POST",
      "sms_fallback_url": null,
      "sms_method": "POST",
      "sms_url": null,
      "status_callback": null,
      "status_callback_method": "POST",
      "trunk_sid": null,
      "uri": "/2010-04-01/Accounts/8cc8ac8b-e238-445c-8b96-f01b47fcd691/IncomingPhoneNumbers/7d600bdb-6fc0-446e-b4af-84d2a67f0026",
      "voice_application_sid": null,
      "voice_caller_id_lookup": false,
      "voice_fallback_method": "POST",
      "voice_fallback_url": null,
      "voice_method": "POST",
      "voice_url": null,
      "bundle_sid": null,
      "voice_receive_mode": "voice",
      "status": "in-use"
    }
  ],
  "uri": "/2010-04-01/Accounts/8cc8ac8b-e238-445c-8b96-f01b47fcd691/IncomingPhoneNumbers?PhoneNumber=%2B12513095500",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/8cc8ac8b-e238-445c-8b96-f01b47fcd691/IncomingPhoneNumbers?Page=0&PhoneNumber=%2B12513095500",
  "previous_page_uri": "/2010-04-01/Accounts/8cc8ac8b-e238-445c-8b96-f01b47fcd691/IncomingPhoneNumbers?Page=0&PageToken=PB7d600bdb-6fc0-446e-b4af-84d2a67f0026&PhoneNumber=%2B12513095500",
  "next_page_uri": null
}

6. Update IncomingPhoneNumber to use a new Voice URL

You will receive a HTTP request to this URL when a call comes in to your phone number.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/14bd8ad4-3497-4ff9-8e5b-f5aea6b622a4/IncomingPhoneNumbers/c44388a5-b99e-49bb-b1e4-cb097e1f2822" \
    -u 14bd8ad4-3497-4ff9-8e5b-f5aea6b622a4:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "VoiceUrl=https://www.your-voice-url.com/example"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers/:Sid

POST https://api.somleng.org/2010-04-01/Accounts/14bd8ad4-3497-4ff9-8e5b-f5aea6b622a4/IncomingPhoneNumbers/c44388a5-b99e-49bb-b1e4-cb097e1f2822

Parameters

{
  "VoiceUrl": "https://www.your-voice-url.com/example"
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the IncomingPhoneNumber resource to update.
Sid Path Parameter: The SID of the IncomingPhoneNumber resource to update.
FriendlyName Request Body Parameter: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number.
SmsUrl Request Body Parameter: The URL we should call when the new phone number receives an incoming SMS message.
SmsMethod Request Body Parameter: The HTTP method that we should use to call sms_url. Can be: GET or POST and defaults to POST.
VoiceUrl Request Body Parameter: The URL that we should call to answer a call to the new phone number.
VoiceMethod Request Body Parameter: The HTTP method that we should use to call voice_url. Can be: GET or POST and defaults to POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application.
StatusCallbackMethod Request Body Parameter: The HTTP method we should use to call status_callback. Can be: GET or POST and defaults to POST.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "c44388a5-b99e-49bb-b1e4-cb097e1f2822",
  "date_created": "Thu, 30 May 2024 07:53:00 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:00 -0000",
  "account_sid": "14bd8ad4-3497-4ff9-8e5b-f5aea6b622a4",
  "address_requirements": "none",
  "address_sid": null,
  "beta": false,
  "capabilities": {
    "voice": true,
    "sms": true,
    "mms": false,
    "fax": false
  },
  "emergency_status": "Inactive",
  "emergency_address_sid": null,
  "emergency_address_status": "unregistered",
  "friendly_name": "+855 97 234 5750",
  "identity_sid": null,
  "origin": "hosted",
  "phone_number": "+855972345750",
  "sms_application_sid": null,
  "sms_fallback_method": "POST",
  "sms_fallback_url": null,
  "sms_method": "POST",
  "sms_url": null,
  "status_callback": null,
  "status_callback_method": "POST",
  "trunk_sid": null,
  "uri": "/2010-04-01/Accounts/14bd8ad4-3497-4ff9-8e5b-f5aea6b622a4/IncomingPhoneNumbers/c44388a5-b99e-49bb-b1e4-cb097e1f2822",
  "voice_application_sid": null,
  "voice_caller_id_lookup": false,
  "voice_fallback_method": "POST",
  "voice_fallback_url": null,
  "voice_method": "POST",
  "voice_url": "https://www.your-voice-url.com/example",
  "bundle_sid": null,
  "voice_receive_mode": "voice",
  "status": "in-use"
}

7. Delete an IncomingPhoneNumber

Release this phone number from your account. We will no longer answer calls to this number, and you will stop being billed the monthly phone number fee. The phone number will be recycled and potentially given to another customer, so use with care.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/b623b4df-2ae5-46fa-a9e8-65269529ffda/IncomingPhoneNumbers/1fc2db26-c277-4bce-ba39-c83b80d29de1" -d '' -X DELETE \
    -u b623b4df-2ae5-46fa-a9e8-65269529ffda:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded"

Endpoint

DELETE https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers/:Sid

DELETE https://api.somleng.org/2010-04-01/Accounts/b623b4df-2ae5-46fa-a9e8-65269529ffda/IncomingPhoneNumbers/1fc2db26-c277-4bce-ba39-c83b80d29de1

Parameters

{
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the IncomingPhoneNumber resource to delete.
Sid Path Parameter: The SID of the IncomingPhoneNumber resource to delete.

Response


204 No Content

Messages

1. Send an SMS Message

The example below shows how to create a Message resource with an SMS recipient. Sending this POST request creates text message from +855716788999 (a phone number belonging to the Account sending the request) to +855716788123. The content of the text message is Hello World.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/9d40bd7f-44b4-4007-87aa-339c49a7c58e/Messages" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 9d40bd7f-44b4-4007-87aa-339c49a7c58e:AuthToken \
    --data-urlencode "To=+855716788123" \
    --data-urlencode "From=+855716788999" \
    --data-urlencode "Body=Hello World"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages

POST https://api.somleng.org/2010-04-01/Accounts/9d40bd7f-44b4-4007-87aa-339c49a7c58e/Messages

Parameters

{
  "To": "+855716788123",
  "From": "+855716788999",
  "Body": "Hello World"
}
Name Description
AccountSid Path Parameter: The SID of the Account creating the Message resource.
From Request Body Parameter: A phone number in E.164 format. Required if MessagingServiceSid is not passed
MessagingServiceSid Request Body Parameter: The SID of the Messaging Service you want to associate with the Message. Set this parameter to use the Messaging Service Settings you have configured and leave the From parameter empty. When only this parameter is set, we will select the From phone number for delivery.
Body required Request Body Parameter: The text of the message you want to send. Can be up to 1,600 characters in length.
To required Request Body Parameter: The destination phone number in E.164 format
StatusCallback Request Body Parameter: The URL we should call to send status information to your application. If specified, we POST these message status changes to the URL: queued, failed, sent, delivered, or undelivered. Somleng will POST its standard request parameters as well as some additional parameters including MessageSid, MessageStatus, and ErrorCode. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when calling the status_callback URL. Can be: GET or POST and the default is POST.
ValidityPeriod Request Body Parameter: How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds.
SmartEncoded Request Body Parameter: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: true or false.
ScheduleType Request Body Parameter: Indicates your intent to schedule a message. Pass the value fixed to schedule a message at a fixed time.
SendAt Request Body Parameter: The time that we will send the message. Must be in ISO 8601 format.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "2af43132-4c31-4959-85e8-985f5c490a53",
  "date_created": "Thu, 30 May 2024 07:53:26 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
  "account_sid": "9d40bd7f-44b4-4007-87aa-339c49a7c58e",
  "body": "Hello World",
  "date_sent": null,
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": "+855716788999",
  "messaging_service_sid": null,
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "status": "queued",
  "subresource_uris": {
  },
  "tags": {
  },
  "to": "+855716788123",
  "uri": "/2010-04-01/Accounts/9d40bd7f-44b4-4007-87aa-339c49a7c58e/Messages/2af43132-4c31-4959-85e8-985f5c490a53"
}

2. Send a message with a Messaging Service

When sending a message with a Messaging Service, you must provide a recipient via the To parameter and content via the Body parameter. In addition, you must provide the MessagingServiceSid.

If you provide a MessagingServiceSid and no From parameter, the optimal From value wil be determined from your Sender Pool. In this case, the Message resource's initial Status value is accepted.

Optionally, you can provide aMessagingServiceSid and a From parameter. The From parameter must be a sender from your Messaging Service's Sender Pool. In this case, the Message resource's initial Status value is queued.

With Messaging Services, you can also schedule messages to be sent in the future.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/faf10ece-7d6d-49b1-8140-22352b1aa80f/Messages" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u faf10ece-7d6d-49b1-8140-22352b1aa80f:AuthToken \
    --data-urlencode "To=+855716788123" \
    --data-urlencode "MessagingServiceSid=66298be9-84c3-446c-8ac9-67f5cefa540c" \
    --data-urlencode "Body=Hello World"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages

POST https://api.somleng.org/2010-04-01/Accounts/faf10ece-7d6d-49b1-8140-22352b1aa80f/Messages

Parameters

{
  "To": "+855716788123",
  "MessagingServiceSid": "66298be9-84c3-446c-8ac9-67f5cefa540c",
  "Body": "Hello World"
}
Name Description
AccountSid Path Parameter: The SID of the Account creating the Message resource.
From Request Body Parameter: A phone number in E.164 format. Required if MessagingServiceSid is not passed
MessagingServiceSid Request Body Parameter: The SID of the Messaging Service you want to associate with the Message. Set this parameter to use the Messaging Service Settings you have configured and leave the From parameter empty. When only this parameter is set, we will select the From phone number for delivery.
Body required Request Body Parameter: The text of the message you want to send. Can be up to 1,600 characters in length.
To required Request Body Parameter: The destination phone number in E.164 format
StatusCallback Request Body Parameter: The URL we should call to send status information to your application. If specified, we POST these message status changes to the URL: queued, failed, sent, delivered, or undelivered. Somleng will POST its standard request parameters as well as some additional parameters including MessageSid, MessageStatus, and ErrorCode. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when calling the status_callback URL. Can be: GET or POST and the default is POST.
ValidityPeriod Request Body Parameter: How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds.
SmartEncoded Request Body Parameter: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: true or false.
ScheduleType Request Body Parameter: Indicates your intent to schedule a message. Pass the value fixed to schedule a message at a fixed time.
SendAt Request Body Parameter: The time that we will send the message. Must be in ISO 8601 format.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "56de5701-38cb-4f80-a538-579a8275264a",
  "date_created": "Thu, 30 May 2024 07:53:26 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
  "account_sid": "faf10ece-7d6d-49b1-8140-22352b1aa80f",
  "body": "Hello World",
  "date_sent": null,
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": null,
  "messaging_service_sid": "66298be9-84c3-446c-8ac9-67f5cefa540c",
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "status": "accepted",
  "subresource_uris": {
  },
  "tags": {
  },
  "to": "+855716788123",
  "uri": "/2010-04-01/Accounts/faf10ece-7d6d-49b1-8140-22352b1aa80f/Messages/56de5701-38cb-4f80-a538-579a8275264a"
}

3. Schedule a Message

The example below shows how to schedule a Message to be sent in the future.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/230e4eff-1ab2-404e-8c62-ea4deaa5b6e2/Messages" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 230e4eff-1ab2-404e-8c62-ea4deaa5b6e2:AuthToken \
    --data-urlencode "To=+855716788123" \
    --data-urlencode "Body=Hello World" \
    --data-urlencode "SendAt=2024-06-04T07:53:26Z" \
    --data-urlencode "ScheduleType=fixed" \
    --data-urlencode "MessagingServiceSid=667de91c-2471-4897-b855-330e82d94d23"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages

POST https://api.somleng.org/2010-04-01/Accounts/230e4eff-1ab2-404e-8c62-ea4deaa5b6e2/Messages

Parameters

{
  "To": "+855716788123",
  "Body": "Hello World",
  "SendAt": "2024-06-04T07:53:26Z",
  "ScheduleType": "fixed",
  "MessagingServiceSid": "667de91c-2471-4897-b855-330e82d94d23"
}
Name Description
AccountSid Path Parameter: The SID of the Account creating the Message resource.
From Request Body Parameter: A phone number in E.164 format. Required if MessagingServiceSid is not passed
MessagingServiceSid Request Body Parameter: The SID of the Messaging Service you want to associate with the Message. Set this parameter to use the Messaging Service Settings you have configured and leave the From parameter empty. When only this parameter is set, we will select the From phone number for delivery.
Body required Request Body Parameter: The text of the message you want to send. Can be up to 1,600 characters in length.
To required Request Body Parameter: The destination phone number in E.164 format
StatusCallback Request Body Parameter: The URL we should call to send status information to your application. If specified, we POST these message status changes to the URL: queued, failed, sent, delivered, or undelivered. Somleng will POST its standard request parameters as well as some additional parameters including MessageSid, MessageStatus, and ErrorCode. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when calling the status_callback URL. Can be: GET or POST and the default is POST.
ValidityPeriod Request Body Parameter: How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds.
SmartEncoded Request Body Parameter: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: true or false.
ScheduleType Request Body Parameter: Indicates your intent to schedule a message. Pass the value fixed to schedule a message at a fixed time.
SendAt Request Body Parameter: The time that we will send the message. Must be in ISO 8601 format.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "fc90b9d7-f816-46b5-a440-f4256b97046c",
  "date_created": "Thu, 30 May 2024 07:53:26 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
  "account_sid": "230e4eff-1ab2-404e-8c62-ea4deaa5b6e2",
  "body": "Hello World",
  "date_sent": null,
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": null,
  "messaging_service_sid": "667de91c-2471-4897-b855-330e82d94d23",
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "status": "scheduled",
  "subresource_uris": {
  },
  "tags": {
  },
  "to": "+855716788123",
  "uri": "/2010-04-01/Accounts/230e4eff-1ab2-404e-8c62-ea4deaa5b6e2/Messages/fc90b9d7-f816-46b5-a440-f4256b97046c"
}

4. Fetch a Message

Returns a single Message resource specified by the provided Message SID.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/e11a89eb-eb8f-407c-99f4-b650774b0955/Messages/e618958b-234b-4564-bc22-f10c0a92b323" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u e11a89eb-eb8f-407c-99f4-b650774b0955:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages/:Sid

GET https://api.somleng.org/2010-04-01/Accounts/e11a89eb-eb8f-407c-99f4-b650774b0955/Messages/e618958b-234b-4564-bc22-f10c0a92b323

Parameters

{
}
Name Description
AccountSid Path Parameter: The SID of the Account associated with the Message resource.
Sid Path Parameter: The SID of the Message resource to be fetched.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "e618958b-234b-4564-bc22-f10c0a92b323",
  "date_created": "Thu, 30 May 2024 07:53:26 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
  "account_sid": "e11a89eb-eb8f-407c-99f4-b650774b0955",
  "body": "Hello World",
  "date_sent": null,
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": "2442",
  "messaging_service_sid": null,
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "status": "accepted",
  "subresource_uris": {
  },
  "tags": {
  },
  "to": "+85512334667",
  "uri": "/2010-04-01/Accounts/e11a89eb-eb8f-407c-99f4-b650774b0955/Messages/e618958b-234b-4564-bc22-f10c0a92b323"
}

5. List all messages

Returns a list of all Message resources associated with your Account

Request

curl "https://api.somleng.org/2010-04-01/Accounts/ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2/Messages" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages

GET https://api.somleng.org/2010-04-01/Accounts/ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2/Messages

Parameters

{
}
Name Description
AccountSid Path Parameter: The SID of the Account associated with the Message resources.

Response


200 OK
{
  "messages": [
    {
      "api_version": "2010-04-01",
      "sid": "0f781460-a200-4c48-968c-fb2f07a0d602",
      "date_created": "Thu, 30 May 2024 07:53:26 -0000",
      "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
      "account_sid": "ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2",
      "body": "Hello World",
      "date_sent": null,
      "direction": "outbound-api",
      "error_code": null,
      "error_message": null,
      "from": "2442",
      "messaging_service_sid": null,
      "num_media": "0",
      "num_segments": "1",
      "price": null,
      "price_unit": null,
      "status": "accepted",
      "subresource_uris": {
      },
      "tags": {
      },
      "to": "+85512334667",
      "uri": "/2010-04-01/Accounts/ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2/Messages/0f781460-a200-4c48-968c-fb2f07a0d602"
    }
  ],
  "uri": "/2010-04-01/Accounts/ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2/Messages",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2/Messages?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/ed3a6a23-5c02-4ed5-bb06-0d9e7b19a0c2/Messages?Page=0&PageToken=PB0f781460-a200-4c48-968c-fb2f07a0d602",
  "next_page_uri": null
}

6. Redact a message

This action can be used to redact messages: to do so, POST to the above URI and set the Body parameter as an empty string: "". This will allow you to effectively redact the text of a message while keeping the other message resource properties intact.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/0f2fa38b-5d9c-4ee9-be52-095d7fd686df/Messages/56656e54-99fb-4cec-8384-dd19b7898596" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 0f2fa38b-5d9c-4ee9-be52-095d7fd686df:AuthToken \
    --data-urlencode "Body="

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages/:Sid

POST https://api.somleng.org/2010-04-01/Accounts/0f2fa38b-5d9c-4ee9-be52-095d7fd686df/Messages/56656e54-99fb-4cec-8384-dd19b7898596

Parameters

{
  "Body": ""
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Message resources to update.
Sid Path Parameter: The SID of the Message resource to be updated.
Body Request Body Parameter: The new body of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
Status Request Body Parameter: Set as canceled to prevent a not-yet-sent Message from being sent. Can be used to cancel sending a scheduled Message.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "56656e54-99fb-4cec-8384-dd19b7898596",
  "date_created": "Thu, 30 May 2024 07:53:26 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
  "account_sid": "0f2fa38b-5d9c-4ee9-be52-095d7fd686df",
  "body": "",
  "date_sent": "Thu, 30 May 2024 07:53:26 -0000",
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": "2442",
  "messaging_service_sid": null,
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "status": "sent",
  "subresource_uris": {
  },
  "tags": {
  },
  "to": "+85512334667",
  "uri": "/2010-04-01/Accounts/0f2fa38b-5d9c-4ee9-be52-095d7fd686df/Messages/56656e54-99fb-4cec-8384-dd19b7898596"
}

7. Cancel a scheduled message

Before you use this functionality:

  1. Ensure the status value of canceled is spelled with one "l", (canceled) and not two (cancelled).
  2. Ensure that you store the MessageSid of the messages you schedule. You need to reference the MessageSid for each message cancelation request.
  3. There is no bulk cancelation. If you'd like to cancel multiple messages, you must send in a cancelation request for each message and reference the MessageSid.
  4. There is a new status callback event for Canceled. You can continue to receive existing callback events by including the optional StatusCallBack parameter in the message request.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/be157d74-928c-4f7c-9c0f-76ca107f1c95/Messages/b16ff2d0-ebbd-4dae-9e31-bb6e4cc7a601" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u be157d74-928c-4f7c-9c0f-76ca107f1c95:AuthToken \
    --data-urlencode "Status=canceled"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages/:Sid

POST https://api.somleng.org/2010-04-01/Accounts/be157d74-928c-4f7c-9c0f-76ca107f1c95/Messages/b16ff2d0-ebbd-4dae-9e31-bb6e4cc7a601

Parameters

{
  "Status": "canceled"
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Message resources to update.
Sid Path Parameter: The SID of the Message resource to be updated.
Body Request Body Parameter: The new body of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
Status Request Body Parameter: Set as canceled to prevent a not-yet-sent Message from being sent. Can be used to cancel sending a scheduled Message.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "b16ff2d0-ebbd-4dae-9e31-bb6e4cc7a601",
  "date_created": "Thu, 30 May 2024 07:53:26 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:26 -0000",
  "account_sid": "be157d74-928c-4f7c-9c0f-76ca107f1c95",
  "body": "Hello World",
  "date_sent": null,
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": null,
  "messaging_service_sid": "0c8961c4-2024-485e-936b-71a4d20962b0",
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "status": "canceled",
  "subresource_uris": {
  },
  "tags": {
  },
  "to": "+85512334667",
  "uri": "/2010-04-01/Accounts/be157d74-928c-4f7c-9c0f-76ca107f1c95/Messages/b16ff2d0-ebbd-4dae-9e31-bb6e4cc7a601"
}

8. Delete a Message

To delete a Message resource, send a DELETE request to the Message resource's URI.

If the DELETE request is successful, the response status code is HTTP 204 (No Content).

A deleted Message resource no longer appears in your Account's Messaging logs. Deleted messages cannot be recovered.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/f75101f8-3fdf-4c5d-ba71-a81824684594/Messages/78ce2b70-9bd8-4dc1-90f4-e65b1dd9c33e" -d '' -X DELETE \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u f75101f8-3fdf-4c5d-ba71-a81824684594:AuthToken

Endpoint

DELETE https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages/:Sid

DELETE https://api.somleng.org/2010-04-01/Accounts/f75101f8-3fdf-4c5d-ba71-a81824684594/Messages/78ce2b70-9bd8-4dc1-90f4-e65b1dd9c33e

Parameters

{
}
Name Description
AccountSid Path Parameter: The SID of the Account associated with the Message resource.
Sid Path Parameter: The SID of the Message resource you wish to delete.

Response


204 No Content

Pagination

When fetching multiple pages of API results, use the provided next_page_uri parameter to retrieve the next page of results.

1. List Resources

Some resources are lists of other resources. For example, the Calls list resource returns a list of calls. There are several important things to know about using and manipulating these lists.

Pagination Information

Property Description
uri The URI of the current page.
first_page_uri The URI for the first page of this list.
next_page_uri The URI for the next page of this list.
previous_page_uri The URI for the previous page of this list.
page The current page number. Zero-indexed, so the first page is 0.
page_size How many items are in each page

** Paging Through API Resources **

When fetching multiple pages of API results, use the provided next_page_uri parameter to retrieve the next page of results.

You can control the size of pages with the PageSize parameter.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls?PageSize=2" \
    -u 16194a67-3da3-4da1-9ded-68f1168ae5af:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls

GET https://api.somleng.org/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls?PageSize=2

Parameters

PageSize: 2
Name Description
PageSize How many resources to return in each list page. The default is 50, and the maximum is 100.

Response


200 OK
{
  "calls": [
    {
      "api_version": "2010-04-01",
      "sid": "e96a40aa-2101-442d-a8eb-d23be0862edd",
      "date_created": "Thu, 30 May 2024 07:53:10 -0000",
      "date_updated": "Thu, 30 May 2024 07:53:10 -0000",
      "account_sid": "16194a67-3da3-4da1-9ded-68f1168ae5af",
      "annotation": null,
      "answered_by": null,
      "caller_name": null,
      "direction": "outbound-api",
      "duration": null,
      "end_time": null,
      "forwarded_from": null,
      "from": "2442",
      "from_formatted": "2442",
      "group_sid": null,
      "parent_call_sid": null,
      "phone_number_sid": null,
      "price": null,
      "price_unit": null,
      "start_time": null,
      "status": "queued",
      "subresource_uris": {
      },
      "to": "+85512334667",
      "to_formatted": "+855 12 334 667",
      "uri": "/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls/e96a40aa-2101-442d-a8eb-d23be0862edd"
    },
    {
      "api_version": "2010-04-01",
      "sid": "998f786c-f206-4e68-9375-625d8648a4d5",
      "date_created": "Thu, 30 May 2024 07:53:10 -0000",
      "date_updated": "Thu, 30 May 2024 07:53:10 -0000",
      "account_sid": "16194a67-3da3-4da1-9ded-68f1168ae5af",
      "annotation": null,
      "answered_by": null,
      "caller_name": null,
      "direction": "outbound-api",
      "duration": null,
      "end_time": null,
      "forwarded_from": null,
      "from": "2442",
      "from_formatted": "2442",
      "group_sid": null,
      "parent_call_sid": null,
      "phone_number_sid": null,
      "price": null,
      "price_unit": null,
      "start_time": null,
      "status": "queued",
      "subresource_uris": {
      },
      "to": "+85512334667",
      "to_formatted": "+855 12 334 667",
      "uri": "/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls/998f786c-f206-4e68-9375-625d8648a4d5"
    }
  ],
  "uri": "/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls?PageSize=2",
  "page": 0,
  "page_size": 2,
  "first_page_uri": "/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls?Page=0&PageSize=2",
  "previous_page_uri": "/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls?Page=0&PageSize=2&PageToken=PBe96a40aa-2101-442d-a8eb-d23be0862edd",
  "next_page_uri": "/2010-04-01/Accounts/16194a67-3da3-4da1-9ded-68f1168ae5af/Calls?Page=1&PageSize=2&PageToken=PA998f786c-f206-4e68-9375-625d8648a4d5"
}

Phone Calls

1. Create a call

Calls can be made via the REST API to phone numbers. To place a new outbound call, make an HTTP POST request to your account's Call resource.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/ab5f72ac-a876-4e5c-99c2-52db849dc8c4/Calls" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u ab5f72ac-a876-4e5c-99c2-52db849dc8c4:AuthToken \
    --data-urlencode "To=+299221234" \
    --data-urlencode "From=+12513095500" \
    --data-urlencode "Url=https://demo.twilio.com/docs/voice.xml"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls

POST https://api.somleng.org/2010-04-01/Accounts/ab5f72ac-a876-4e5c-99c2-52db849dc8c4/Calls

Parameters

{
  "To": "+299221234",
  "From": "+12513095500",
  "Url": "https://demo.twilio.com/docs/voice.xml"
}
Name Description
AccountSid Path Parameter: The SID of the Account that will create the resource.
To required Request Body Parameter: The phone number to call.
From required Request Body Parameter: The phone number to use as the caller id.
Url Request Body Parameter: The absolute URL that returns the TwiML instructions for the call. We will call this URL using the method when the call connects.
Method The HTTP method we should use when calling the url parameter's value. Can be: GET or POST and the default is POST.
Twiml Request Body Parameter: TwiML instructions for the call to be used without fetching TwiML from Url parameter. If both Twiml and Url are provided then Twiml parameter will be ignored.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when calling the status_callback URL. Can be: GET or POST and the default is POST.

Response


201 Created
{
  "api_version": "2010-04-01",
  "sid": "e3c8d06a-c335-4504-912f-e358186dae19",
  "date_created": "Thu, 30 May 2024 07:53:02 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:02 -0000",
  "account_sid": "ab5f72ac-a876-4e5c-99c2-52db849dc8c4",
  "annotation": null,
  "answered_by": null,
  "caller_name": null,
  "direction": "outbound-api",
  "duration": null,
  "end_time": null,
  "forwarded_from": null,
  "from": "+12513095500",
  "from_formatted": "+1 (251) 309-5500",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": "65b504a2-fcc0-4589-91e3-6691c1a65fc3",
  "price": null,
  "price_unit": null,
  "start_time": null,
  "status": "queued",
  "subresource_uris": {
  },
  "to": "+299221234",
  "to_formatted": "+299 22 1234",
  "uri": "/2010-04-01/Accounts/ab5f72ac-a876-4e5c-99c2-52db849dc8c4/Calls/e3c8d06a-c335-4504-912f-e358186dae19"
}

2. Fetch a call

This API call returns the Call resource of an individual call, identified by its Sid.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/10f462e9-a9b4-4de9-889f-79645394ce04/Calls/384ac9d7-2097-4282-a7fa-7d0594588f32" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 10f462e9-a9b4-4de9-889f-79645394ce04:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:Sid

GET https://api.somleng.org/2010-04-01/Accounts/10f462e9-a9b4-4de9-889f-79645394ce04/Calls/384ac9d7-2097-4282-a7fa-7d0594588f32

Parameters

{
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Call resource(s) to fetch.
Sid Path Parameter: The SID of the Call resource to fetch.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "384ac9d7-2097-4282-a7fa-7d0594588f32",
  "date_created": "Thu, 30 May 2024 07:53:02 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:02 -0000",
  "account_sid": "10f462e9-a9b4-4de9-889f-79645394ce04",
  "annotation": null,
  "answered_by": null,
  "caller_name": null,
  "direction": "outbound-api",
  "duration": null,
  "end_time": null,
  "forwarded_from": null,
  "from": "2442",
  "from_formatted": "2442",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": null,
  "price": null,
  "price_unit": null,
  "start_time": null,
  "status": "queued",
  "subresource_uris": {
  },
  "to": "+85512334667",
  "to_formatted": "+855 12 334 667",
  "uri": "/2010-04-01/Accounts/10f462e9-a9b4-4de9-889f-79645394ce04/Calls/384ac9d7-2097-4282-a7fa-7d0594588f32"
}

3. List phone calls

Return a list of phone calls made to and from an account, identified by its AccountSid.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/ee32e7c2-72b8-47f0-b5ae-6bd5216500a3/Calls" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u ee32e7c2-72b8-47f0-b5ae-6bd5216500a3:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls

GET https://api.somleng.org/2010-04-01/Accounts/ee32e7c2-72b8-47f0-b5ae-6bd5216500a3/Calls

Parameters

{
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Call resource(s) to read.

Response


200 OK
{
  "calls": [
    {
      "api_version": "2010-04-01",
      "sid": "c3467e0a-31ba-461d-98f4-2e5a9ef20db5",
      "date_created": "Thu, 30 May 2024 07:53:01 -0000",
      "date_updated": "Thu, 30 May 2024 07:53:01 -0000",
      "account_sid": "ee32e7c2-72b8-47f0-b5ae-6bd5216500a3",
      "annotation": null,
      "answered_by": null,
      "caller_name": null,
      "direction": "outbound-api",
      "duration": null,
      "end_time": null,
      "forwarded_from": null,
      "from": "2442",
      "from_formatted": "2442",
      "group_sid": null,
      "parent_call_sid": null,
      "phone_number_sid": null,
      "price": null,
      "price_unit": null,
      "start_time": null,
      "status": "queued",
      "subresource_uris": {
      },
      "to": "+85512334667",
      "to_formatted": "+855 12 334 667",
      "uri": "/2010-04-01/Accounts/ee32e7c2-72b8-47f0-b5ae-6bd5216500a3/Calls/c3467e0a-31ba-461d-98f4-2e5a9ef20db5"
    }
  ],
  "uri": "/2010-04-01/Accounts/ee32e7c2-72b8-47f0-b5ae-6bd5216500a3/Calls",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/ee32e7c2-72b8-47f0-b5ae-6bd5216500a3/Calls?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/ee32e7c2-72b8-47f0-b5ae-6bd5216500a3/Calls?Page=0&PageToken=PBc3467e0a-31ba-461d-98f4-2e5a9ef20db5",
  "next_page_uri": null
}

4. Update a Call in progress with TwiML

Updating a Call resource allows you to modify an active call.

Real-time call modification allows you to interrupt an in-progress call and terminate it or have it begin processing TwiML from either a new URL or from the TwiML provided with modification. Call modification is useful for any application where you want to change the behavior of a running call asynchronously, e.g., hold music, call queues, transferring calls, or forcing a hangup.

By sending an HTTP POST request to a specific Call instance, you can redirect a call that is in progress or you can terminate a call.

This example interrupts an in-progress call and begins processing TwiML from a the TwiML provided.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/b6ed3e08-4340-4989-b888-e880b9dcc4b8/Calls/856cec6b-11ec-4ff9-8052-ff8ee25a8657" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u b6ed3e08-4340-4989-b888-e880b9dcc4b8:AuthToken \
    --data-urlencode "Twiml=<Response><Say>Ahoy there</Say></Response>"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:Sid

POST https://api.somleng.org/2010-04-01/Accounts/b6ed3e08-4340-4989-b888-e880b9dcc4b8/Calls/856cec6b-11ec-4ff9-8052-ff8ee25a8657

Parameters

{
  "Twiml": "<Response><Say>Ahoy there</Say></Response>"
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Call resource(s) to update.
Sid Path Parameter: The ID that uniquely identifies the Call resource to update.
Url Request Body Parameter: The absolute URL that returns the TwiML instructions for the call. We will call this URL using the method when the call connects.
Method Request Body Parameter: The HTTP method we should use when calling the url. Can be: GET or POST and the default is POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when requesting the status_callback URL. Can be: GET or POST and the default is POST.
Twiml Request Body Parameter: TwiML instructions for the call to be used without fetching Twiml from url. Twiml and Url parameters are mutually exclusive.
Status Request Body Parameter: The new status of the resource. Can be: canceled or completed. Specifying canceled will attempt to hang up calls that are queued or ringing; however, it will not affect calls already in progress. Specifying completed will attempt to hang up a call even if it's already in progress.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "856cec6b-11ec-4ff9-8052-ff8ee25a8657",
  "date_created": "Thu, 30 May 2024 07:53:02 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:02 -0000",
  "account_sid": "b6ed3e08-4340-4989-b888-e880b9dcc4b8",
  "annotation": null,
  "answered_by": null,
  "caller_name": null,
  "direction": "outbound-api",
  "duration": null,
  "end_time": null,
  "forwarded_from": null,
  "from": "2442",
  "from_formatted": "2442",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": null,
  "price": null,
  "price_unit": null,
  "start_time": null,
  "status": "in-progress",
  "subresource_uris": {
  },
  "to": "+85512334667",
  "to_formatted": "+855 12 334 667",
  "uri": "/2010-04-01/Accounts/b6ed3e08-4340-4989-b888-e880b9dcc4b8/Calls/856cec6b-11ec-4ff9-8052-ff8ee25a8657"
}

5. Update a Call in progress with URL

This example interrupts an in-progress call and begins processing TwiML from a new URL.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/54c5917e-ccf0-4c79-88e2-e6f7f8d97486/Calls/dbdba58e-e53d-44c2-ab98-8d9dfd922e1e" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 54c5917e-ccf0-4c79-88e2-e6f7f8d97486:AuthToken \
    --data-urlencode "Url=https://demo.twilio.com/docs/voice.xml" \
    --data-urlencode "Method=POST"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:Sid

POST https://api.somleng.org/2010-04-01/Accounts/54c5917e-ccf0-4c79-88e2-e6f7f8d97486/Calls/dbdba58e-e53d-44c2-ab98-8d9dfd922e1e

Parameters

{
  "Url": "https://demo.twilio.com/docs/voice.xml",
  "Method": "POST"
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Call resource(s) to update.
Sid Path Parameter: The ID that uniquely identifies the Call resource to update.
Url Request Body Parameter: The absolute URL that returns the TwiML instructions for the call. We will call this URL using the method when the call connects.
Method Request Body Parameter: The HTTP method we should use when calling the url. Can be: GET or POST and the default is POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when requesting the status_callback URL. Can be: GET or POST and the default is POST.
Twiml Request Body Parameter: TwiML instructions for the call to be used without fetching Twiml from url. Twiml and Url parameters are mutually exclusive.
Status Request Body Parameter: The new status of the resource. Can be: canceled or completed. Specifying canceled will attempt to hang up calls that are queued or ringing; however, it will not affect calls already in progress. Specifying completed will attempt to hang up a call even if it's already in progress.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "dbdba58e-e53d-44c2-ab98-8d9dfd922e1e",
  "date_created": "Thu, 30 May 2024 07:53:01 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:01 -0000",
  "account_sid": "54c5917e-ccf0-4c79-88e2-e6f7f8d97486",
  "annotation": null,
  "answered_by": null,
  "caller_name": null,
  "direction": "outbound-api",
  "duration": null,
  "end_time": null,
  "forwarded_from": null,
  "from": "2442",
  "from_formatted": "2442",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": null,
  "price": null,
  "price_unit": null,
  "start_time": null,
  "status": "in-progress",
  "subresource_uris": {
  },
  "to": "+85512334667",
  "to_formatted": "+855 12 334 667",
  "uri": "/2010-04-01/Accounts/54c5917e-ccf0-4c79-88e2-e6f7f8d97486/Calls/dbdba58e-e53d-44c2-ab98-8d9dfd922e1e"
}

6. End a call

This example interrupts an in-progress call and terminates it.

Request

curl -X POST "https://api.somleng.org/2010-04-01/Accounts/c6f64bb5-35a5-4a3f-97c3-73a17f7bc238/Calls/a1d0ebdc-56d0-40f5-8f7a-9b2c332aa6eb" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u c6f64bb5-35a5-4a3f-97c3-73a17f7bc238:AuthToken \
    --data-urlencode "Status=completed"

Endpoint

POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:Sid

POST https://api.somleng.org/2010-04-01/Accounts/c6f64bb5-35a5-4a3f-97c3-73a17f7bc238/Calls/a1d0ebdc-56d0-40f5-8f7a-9b2c332aa6eb

Parameters

{
  "Status": "completed"
}
Name Description
AccountSid Path Parameter: The SID of the Account that created the Call resource(s) to update.
Sid Path Parameter: The ID that uniquely identifies the Call resource to update.
Url Request Body Parameter: The absolute URL that returns the TwiML instructions for the call. We will call this URL using the method when the call connects.
Method Request Body Parameter: The HTTP method we should use when calling the url. Can be: GET or POST and the default is POST.
StatusCallback Request Body Parameter: The URL we should call using the status_callback_method to send status information to your application. URLs must contain a valid hostname (underscores are not permitted).
StatusCallbackMethod Request Body Parameter: The HTTP method we should use when requesting the status_callback URL. Can be: GET or POST and the default is POST.
Twiml Request Body Parameter: TwiML instructions for the call to be used without fetching Twiml from url. Twiml and Url parameters are mutually exclusive.
Status Request Body Parameter: The new status of the resource. Can be: canceled or completed. Specifying canceled will attempt to hang up calls that are queued or ringing; however, it will not affect calls already in progress. Specifying completed will attempt to hang up a call even if it's already in progress.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "a1d0ebdc-56d0-40f5-8f7a-9b2c332aa6eb",
  "date_created": "Thu, 30 May 2024 07:53:02 -0000",
  "date_updated": "Thu, 30 May 2024 07:53:02 -0000",
  "account_sid": "c6f64bb5-35a5-4a3f-97c3-73a17f7bc238",
  "annotation": null,
  "answered_by": null,
  "caller_name": null,
  "direction": "outbound-api",
  "duration": null,
  "end_time": null,
  "forwarded_from": null,
  "from": "2442",
  "from_formatted": "2442",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": null,
  "price": null,
  "price_unit": null,
  "start_time": null,
  "status": "in-progress",
  "subresource_uris": {
  },
  "to": "+85512334667",
  "to_formatted": "+855 12 334 667",
  "uri": "/2010-04-01/Accounts/c6f64bb5-35a5-4a3f-97c3-73a17f7bc238/Calls/a1d0ebdc-56d0-40f5-8f7a-9b2c332aa6eb"
}

Recordings

1. Fetch a Recording's media file

You can fetch a Recording's media file by appending .wav or .mp3 to the Recording Resource's URI.

It's only possible to fetch a Recording's media file when the Recording's status is completed.

If the media associated with a Recording Resource is not available, the request returns 404 Not Found.

Without an extension, or with a .wav, a binary WAV audio file is returned with mime-type audio/x-wav.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/5357c7b4-f638-4624-bb2b-8d329e44ea34/Recordings/923e1fe3-490a-4344-b7bc-c1184ccd6f76" 

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings/:Sid

GET https://api.somleng.org/2010-04-01/Accounts/5357c7b4-f638-4624-bb2b-8d329e44ea34/Recordings/923e1fe3-490a-4344-b7bc-c1184ccd6f76

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account that created the Recording resource to fetch.
Sid Path Parameter: The SID of the Recording resource to fetch.

Response


302 Found

2. Fetch a Recording as mp3

You can fetch a Recording's media file as mp3 by appending .mp3 to the Recording Resource's URI.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/5c59f1b4-72c5-408d-bb9b-58cee33763c0/Recordings/6b577305-2813-4ddd-a77c-7bd8fcaf3e29.mp3" 

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings/:Sid.mp3

GET https://api.somleng.org/2010-04-01/Accounts/5c59f1b4-72c5-408d-bb9b-58cee33763c0/Recordings/6b577305-2813-4ddd-a77c-7bd8fcaf3e29.mp3

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account that created the Recording resource to fetch.
Sid Path Parameter: The SID of the Recording resource to fetch.

Response


302 Found

3. Fetch a Recording's metadata

A Recording's metadata can be returned in JSON format. Append .json to the Recording Resource's URI.

Request

curl "https://api.somleng.org/2010-04-01/Accounts/da53c6ef-fab6-4154-89ec-f9090a90ab56/Recordings/b59a25bc-1fd8-4de3-8215-e94018099c9c.json" 

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings/:Sid.json

GET https://api.somleng.org/2010-04-01/Accounts/da53c6ef-fab6-4154-89ec-f9090a90ab56/Recordings/b59a25bc-1fd8-4de3-8215-e94018099c9c.json

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account that created the Recording resource to fetch.
Sid Path Parameter: The SID of the Recording resource to fetch.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "b59a25bc-1fd8-4de3-8215-e94018099c9c",
  "date_created": "Thu, 30 May 2024 07:52:52 -0000",
  "date_updated": "Thu, 30 May 2024 07:52:52 -0000",
  "account_sid": "da53c6ef-fab6-4154-89ec-f9090a90ab56",
  "call_sid": "cbc0c9bb-ae4a-446a-9be2-3e781604d1b6",
  "conference_sid": null,
  "channels": 1,
  "start_time": "2024-05-30T07:52:52.132Z",
  "duration": null,
  "price": null,
  "price_unit": null,
  "source": "RecordVerb",
  "status": "processing",
  "error_code": null,
  "encryption_details": null,
  "track": "both",
  "uri": "/2010-04-01/Accounts/da53c6ef-fab6-4154-89ec-f9090a90ab56/Calls/cbc0c9bb-ae4a-446a-9be2-3e781604d1b6/Recordings/b59a25bc-1fd8-4de3-8215-e94018099c9c.json"
}

4. Get all recordings for a given call

Request

curl "https://api.somleng.org/2010-04-01/Accounts/8b88666e-36bf-4754-a163-179e434b2be5/Calls/c4bc9e0a-9634-4b60-a1bf-ac21960ca031/Recordings" \
    -u 8b88666e-36bf-4754-a163-179e434b2be5:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:CallSid/Recordings

GET https://api.somleng.org/2010-04-01/Accounts/8b88666e-36bf-4754-a163-179e434b2be5/Calls/c4bc9e0a-9634-4b60-a1bf-ac21960ca031/Recordings

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account that created the Recording resource to read.
CallSid Path Parameter: The Call SID of the Recording resources to read.

Response


200 OK
{
  "recordings": [
    {
      "api_version": "2010-04-01",
      "sid": "d57d5e37-e498-4a6e-8db5-acc4da76fd89",
      "date_created": "Thu, 30 May 2024 07:52:52 -0000",
      "date_updated": "Thu, 30 May 2024 07:52:52 -0000",
      "account_sid": "8b88666e-36bf-4754-a163-179e434b2be5",
      "call_sid": "c4bc9e0a-9634-4b60-a1bf-ac21960ca031",
      "conference_sid": null,
      "channels": 1,
      "start_time": "2024-05-30T07:52:52.063Z",
      "duration": "0",
      "price": null,
      "price_unit": null,
      "source": "RecordVerb",
      "status": "completed",
      "error_code": null,
      "encryption_details": null,
      "track": "both",
      "uri": "/2010-04-01/Accounts/8b88666e-36bf-4754-a163-179e434b2be5/Calls/c4bc9e0a-9634-4b60-a1bf-ac21960ca031/Recordings/d57d5e37-e498-4a6e-8db5-acc4da76fd89.json"
    }
  ],
  "uri": "/2010-04-01/Accounts/8b88666e-36bf-4754-a163-179e434b2be5/Calls/c4bc9e0a-9634-4b60-a1bf-ac21960ca031/Recordings",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/8b88666e-36bf-4754-a163-179e434b2be5/Calls/c4bc9e0a-9634-4b60-a1bf-ac21960ca031/Recordings?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/8b88666e-36bf-4754-a163-179e434b2be5/Calls/c4bc9e0a-9634-4b60-a1bf-ac21960ca031/Recordings?Page=0&PageToken=PBd57d5e37-e498-4a6e-8db5-acc4da76fd89",
  "next_page_uri": null
}

5. List recordings by account

Request

curl "https://api.somleng.org/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Recordings" \
    -u bbd87a89-e1c3-4b67-b3ee-390fcff3cb45:AuthToken

Endpoint

GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings

GET https://api.somleng.org/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Recordings

Parameters

Name Description
AccountSid Path Parameter: The SID of the Account that created the Recording resource to read.

Response


200 OK
{
  "recordings": [
    {
      "api_version": "2010-04-01",
      "sid": "d3c55358-227e-4bd8-8c7b-f2a00349c5f3",
      "date_created": "Thu, 30 May 2024 07:52:51 -0000",
      "date_updated": "Thu, 30 May 2024 07:52:51 -0000",
      "account_sid": "bbd87a89-e1c3-4b67-b3ee-390fcff3cb45",
      "call_sid": "fd99e7a1-3e88-4cf8-ad18-dbca667e94b8",
      "conference_sid": null,
      "channels": 1,
      "start_time": "2024-05-30T07:52:51.147Z",
      "duration": null,
      "price": null,
      "price_unit": null,
      "source": "RecordVerb",
      "status": "processing",
      "error_code": null,
      "encryption_details": null,
      "track": "both",
      "uri": "/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Calls/fd99e7a1-3e88-4cf8-ad18-dbca667e94b8/Recordings/d3c55358-227e-4bd8-8c7b-f2a00349c5f3.json"
    },
    {
      "api_version": "2010-04-01",
      "sid": "fd548d97-51ad-480a-aaf2-50b13c027463",
      "date_created": "Thu, 30 May 2024 07:52:51 -0000",
      "date_updated": "Thu, 30 May 2024 07:52:51 -0000",
      "account_sid": "bbd87a89-e1c3-4b67-b3ee-390fcff3cb45",
      "call_sid": "09f7c2bb-889d-42df-a065-73368428f1a5",
      "conference_sid": null,
      "channels": 1,
      "start_time": "2024-05-30T07:52:51.123Z",
      "duration": null,
      "price": null,
      "price_unit": null,
      "source": "RecordVerb",
      "status": "processing",
      "error_code": null,
      "encryption_details": null,
      "track": "both",
      "uri": "/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Calls/09f7c2bb-889d-42df-a065-73368428f1a5/Recordings/fd548d97-51ad-480a-aaf2-50b13c027463.json"
    }
  ],
  "uri": "/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Recordings",
  "page": 0,
  "page_size": 50,
  "first_page_uri": "/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Recordings?Page=0",
  "previous_page_uri": "/2010-04-01/Accounts/bbd87a89-e1c3-4b67-b3ee-390fcff3cb45/Recordings?Page=0&PageToken=PBd3c55358-227e-4bd8-8c7b-f2a00349c5f3",
  "next_page_uri": null
}

Verification Services

1. Create a Verification Service

A Verification Service is the set of common configurations used to create and check verifications. You can create a service with the API or in the Console.

Request

curl -X POST "https://verify.somleng.org/v2/Services" \
    -u 965ee950-e0af-4849-a494-e99a9d367cd7:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "FriendlyName=My Verification Service"

Endpoint

POST https://verify.somleng.org/v2/Services

POST https://verify.somleng.org/v2/Services

Parameters

{
  "FriendlyName": "My Verification Service"
}
Name Description
FriendlyName required Request Body Parameter: A descriptive string that you create to describe the verification service. It can be up to 32 characters long.
CodeLength Request Body Parameter: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.

Response


201 Created
{
  "sid": "867ed746-1440-4dbe-a06c-e508d02bc8c6",
  "account_sid": "965ee950-e0af-4849-a494-e99a9d367cd7",
  "date_created": "2024-05-30T07:53:04Z",
  "date_updated": "2024-05-30T07:53:04Z",
  "friendly_name": "My Verification Service",
  "url": "http://verify.lvh.me/v2/Services/867ed746-1440-4dbe-a06c-e508d02bc8c6",
  "code_length": 6
}

2. Fetch a Service

Request

curl "https://verify.somleng.org/v2/Services/092fbcff-4052-4abb-b02b-45606b015b0a" \
    -u 7a12f252-1007-42f2-ac46-ae83eaf18699:AuthToken

Endpoint

GET https://verify.somleng.org/v2/Services/:Sid

GET https://verify.somleng.org/v2/Services/092fbcff-4052-4abb-b02b-45606b015b0a

Parameters

Name Description
Sid Path Parameter: The SID of the Verification Service to fetch.

Response


200 OK
{
  "sid": "092fbcff-4052-4abb-b02b-45606b015b0a",
  "account_sid": "7a12f252-1007-42f2-ac46-ae83eaf18699",
  "date_created": "2024-05-30T07:53:04Z",
  "date_updated": "2024-05-30T07:53:04Z",
  "friendly_name": "My Verification Service",
  "url": "http://verify.lvh.me/v2/Services/092fbcff-4052-4abb-b02b-45606b015b0a",
  "code_length": 4
}

3. List all Services

Request

curl "https://verify.somleng.org/v2/Services" \
    -u 56a10bff-acc4-4888-8812-d0e73ce2eedf:AuthToken

Endpoint

GET https://verify.somleng.org/v2/Services

GET https://verify.somleng.org/v2/Services

Parameters

None known.

Response


200 OK
{
  "services": [
    {
      "sid": "68fd366f-2248-4c15-b015-9be3885a716a",
      "account_sid": "56a10bff-acc4-4888-8812-d0e73ce2eedf",
      "date_created": "2024-05-30T07:53:04Z",
      "date_updated": "2024-05-30T07:53:04Z",
      "friendly_name": "My Verification Service",
      "url": "http://verify.lvh.me/v2/Services/68fd366f-2248-4c15-b015-9be3885a716a",
      "code_length": 4
    }
  ],
  "meta": {
    "url": "https://verify.somleng.org/v2/Services",
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://verify.somleng.org/v2/Services?Page=0",
    "previous_page_url": "https://verify.somleng.org/v2/Services?Page=0&PageToken=PB68fd366f-2248-4c15-b015-9be3885a716a",
    "next_page_url": null,
    "key": "services"
  }
}

4. Update a Service

This example updates the FriendlyName and CodeLength of a Verification Service.

Request

curl -X POST "https://verify.somleng.org/v2/Services/ca92d850-e31a-4a8a-ba1e-f198f76fc2ab" \
    -u 9fae7d7f-0e22-4c34-9486-bc3d9ff284a4:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "FriendlyName=Rocket Ride Service" \
    --data-urlencode "CodeLength=6"

Endpoint

POST https://verify.somleng.org/v2/Services/:sid

POST https://verify.somleng.org/v2/Services/ca92d850-e31a-4a8a-ba1e-f198f76fc2ab

Parameters

{
  "FriendlyName": "Rocket Ride Service",
  "CodeLength": "6"
}
Name Description
Sid required Path Parameter: The SID of the Verification Service to update.
FriendlyName required Request Body Parameter: A descriptive string that you create to describe the Verification Service. It can be up to 32 characters long.
Request Body Parameter: CodeLength The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.

Response


200 OK
{
  "sid": "ca92d850-e31a-4a8a-ba1e-f198f76fc2ab",
  "account_sid": "9fae7d7f-0e22-4c34-9486-bc3d9ff284a4",
  "date_created": "2024-05-30T07:53:04Z",
  "date_updated": "2024-05-30T07:53:04Z",
  "friendly_name": "Rocket Ride Service",
  "url": "http://verify.lvh.me/v2/Services/ca92d850-e31a-4a8a-ba1e-f198f76fc2ab",
  "code_length": 6
}

5. Delete a Service

Request

curl "https://verify.somleng.org/v2/Services/f6b9bebc-d00d-4019-9ac2-e299c9cc8167" -d '' -X DELETE \
    -u aa7e9ea9-cecf-480c-a346-9bc5db19cc6c:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded"

Endpoint

DELETE https://verify.somleng.org/v2/Services/:Sid

DELETE https://verify.somleng.org/v2/Services/f6b9bebc-d00d-4019-9ac2-e299c9cc8167

Parameters

{
}
Name Description
Sid Path Parameter: The SID of the Verification Service to delete.

Response


204 No Content

Verifications

1. Start a Verification with SMS

To verify a user's phone number, start by requesting to send a verification code to their device. Phone numbers must be in E.164 format.

Request

curl -X POST "https://verify.somleng.org/v2/Services/938d761b-e284-4848-9939-bbe4cd58ed7d/Verifications" \
    -u 430fc318-d3e2-46e0-951b-d134196e26ca:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "To=+85512334667" \
    --data-urlencode "Channel=sms"

Endpoint

POST https://verify.somleng.org/v2/Services/:ServiceSid/Verifications

POST https://verify.somleng.org/v2/Services/938d761b-e284-4848-9939-bbe4cd58ed7d/Verifications

Parameters

{
  "To": "+85512334667",
  "Channel": "sms"
}
Name Description
ServiceSid Path Parameter: The SID of the verification Service to create the resource under.
To required Request Body Parameter: The phone number or email to verify. Phone numbers must be in E.164 format.
Channel required Request Body Parameter: The verification method to use. One of: sms or call
Locale Request Body Parameter: Locale will automatically resolve based on phone number country code of the recipient for SMS and call channel verifications. It will fallback to English if the selected translation is not available. This parameter will override the automatic locale resolution. The following locales are supported: en, fr, ja, nl, ar, ca, da, de, es, fi, id, it, ko, pl, pt, ru, sv, tr, uk, vi, af, cs, el, hi, hr, hu, km, kn, lt, mr, ms, nb, pt-br, ro, sk, te, th, tl, zh-cn, zh-hk, zh.

Response


200 OK
{
  "sid": "c726ad1b-0299-41de-a444-88c5ab60da31",
  "account_sid": "430fc318-d3e2-46e0-951b-d134196e26ca",
  "date_created": "2024-05-30T07:53:14Z",
  "date_updated": "2024-05-30T07:53:14Z",
  "service_sid": "938d761b-e284-4848-9939-bbe4cd58ed7d",
  "to": "+85512334667",
  "channel": "sms",
  "status": "pending",
  "url": "http://verify.lvh.me/v2/Services/938d761b-e284-4848-9939-bbe4cd58ed7d/Verifications/c726ad1b-0299-41de-a444-88c5ab60da31",
  "send_code_attempts": [
    {
      "attempt_sid": "df9242b6-13b7-47d9-b1fa-39c9a8bb2bc6",
      "channel": "sms",
      "time": "2024-05-30T07:53:14Z"
    }
  ]
}

2. Start a Verification with Voice

Request

curl -X POST "https://verify.somleng.org/v2/Services/4e2698b4-5cb3-4882-9393-ad9929e91c0e/Verifications" \
    -u a0123436-ea89-4571-b687-0222d5c94041:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "To=+85512334667" \
    --data-urlencode "Channel=call"

Endpoint

POST https://verify.somleng.org/v2/Services/:ServiceSid/Verifications

POST https://verify.somleng.org/v2/Services/4e2698b4-5cb3-4882-9393-ad9929e91c0e/Verifications

Parameters

{
  "To": "+85512334667",
  "Channel": "call"
}
Name Description
ServiceSid Path Parameter: The SID of the verification Service to create the resource under.
To required Request Body Parameter: The phone number or email to verify. Phone numbers must be in E.164 format.
Channel required Request Body Parameter: The verification method to use. One of: sms or call
Locale Request Body Parameter: Locale will automatically resolve based on phone number country code of the recipient for SMS and call channel verifications. It will fallback to English if the selected translation is not available. This parameter will override the automatic locale resolution. The following locales are supported: en, fr, ja, nl, ar, ca, da, de, es, fi, id, it, ko, pl, pt, ru, sv, tr, uk, vi, af, cs, el, hi, hr, hu, km, kn, lt, mr, ms, nb, pt-br, ro, sk, te, th, tl, zh-cn, zh-hk, zh.

Response


200 OK
{
  "sid": "3008e3dd-4f9c-4b02-badc-ebc783ca860f",
  "account_sid": "a0123436-ea89-4571-b687-0222d5c94041",
  "date_created": "2024-05-30T07:53:14Z",
  "date_updated": "2024-05-30T07:53:14Z",
  "service_sid": "4e2698b4-5cb3-4882-9393-ad9929e91c0e",
  "to": "+85512334667",
  "channel": "call",
  "status": "pending",
  "url": "http://verify.lvh.me/v2/Services/4e2698b4-5cb3-4882-9393-ad9929e91c0e/Verifications/3008e3dd-4f9c-4b02-badc-ebc783ca860f",
  "send_code_attempts": [
    {
      "attempt_sid": "9f0b3143-c0ab-48b7-8098-a5c176aaae6a",
      "channel": "call",
      "time": "2024-05-30T07:53:14Z"
    }
  ]
}

3. Check a Verification with a Phone Number

This API will check whether the user-provided verification code is correct.

⚠️ The verification SID is automatically deleted once it's:

If any of these occur, verification checks will return a 404 Not Found error. If you'd like to double check what happened with a given verification - please use the Dashboard Verify Logs.

Request

curl -X POST "https://verify.somleng.org/v2/Services/73f0a44f-619f-489b-b70f-d6390270a9e4/VerificationCheck" \
    -u e7cdce5a-69d8-4923-a2a2-afa53bc55d79:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "To=+85512334667" \
    --data-urlencode "Code=1234"

Endpoint

POST https://verify.somleng.org/v2/Services/:ServiceSid/VerificationCheck

POST https://verify.somleng.org/v2/Services/73f0a44f-619f-489b-b70f-d6390270a9e4/VerificationCheck

Parameters

{
  "To": "+85512334667",
  "Code": "1234"
}
Name Description
ServiceSid Path Parameter: The SID of the verification Service to create the resource under.
Code required Request Body Parameter: The 4-10 character string being verified.
To Request Body Parameter: The phone number to verify. Either this parameter or the verification_sid` must be specified. Phone numbers must be in E.164 format.
VerificationSid Request Body Parameter: A SID that uniquely identifies the Verification. Either this parameter or the To phone number must be specified.

Response


200 OK
{
  "sid": "686a6531-9a43-4b3d-bcef-c7674ccaa76b",
  "account_sid": "e7cdce5a-69d8-4923-a2a2-afa53bc55d79",
  "date_created": "2024-05-30T07:53:13Z",
  "date_updated": "2024-05-30T07:53:13Z",
  "service_sid": "73f0a44f-619f-489b-b70f-d6390270a9e4",
  "to": "+85512334667",
  "channel": "sms",
  "status": "approved"
}

4. Check a Verification with a SID

Request

curl -X POST "https://verify.somleng.org/v2/Services/84b66d92-6eb2-4cfa-a454-71be27e044f7/VerificationCheck" \
    -u e9a95d4f-9df1-4852-98e1-ba29529d2030:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "VerificationSid=1ddda751-52ed-4826-9c5a-288c9a1dc0bd" \
    --data-urlencode "Code=1234"

Endpoint

POST https://verify.somleng.org/v2/Services/:ServiceSid/VerificationCheck

POST https://verify.somleng.org/v2/Services/84b66d92-6eb2-4cfa-a454-71be27e044f7/VerificationCheck

Parameters

{
  "VerificationSid": "1ddda751-52ed-4826-9c5a-288c9a1dc0bd",
  "Code": "1234"
}
Name Description
ServiceSid Path Parameter: The SID of the verification Service to create the resource under.
Code required Request Body Parameter: The 4-10 character string being verified.
To Request Body Parameter: The phone number to verify. Either this parameter or the verification_sid` must be specified. Phone numbers must be in E.164 format.
VerificationSid Request Body Parameter: A SID that uniquely identifies the Verification. Either this parameter or the To phone number must be specified.

Response


200 OK
{
  "sid": "1ddda751-52ed-4826-9c5a-288c9a1dc0bd",
  "account_sid": "e9a95d4f-9df1-4852-98e1-ba29529d2030",
  "date_created": "2024-05-30T07:53:13Z",
  "date_updated": "2024-05-30T07:53:13Z",
  "service_sid": "84b66d92-6eb2-4cfa-a454-71be27e044f7",
  "to": "+85512334667",
  "channel": "sms",
  "status": "approved"
}

5. Fetch a Verification

Request

curl "https://verify.somleng.org/v2/Services/ed283952-8869-416b-8273-e347b3114ee3/Verifications/1141798b-6c9c-4047-8c92-7848d4687573" \
    -u bd22e5b9-b147-4c00-851d-f3f19b63d153:AuthToken

Endpoint

GET https://verify.somleng.org/v2/Services/:ServiceSid/Verifications/:Sid

GET https://verify.somleng.org/v2/Services/ed283952-8869-416b-8273-e347b3114ee3/Verifications/1141798b-6c9c-4047-8c92-7848d4687573

Parameters

Name Description
ServiceSid Path Parameter: The SID of the Verification Service to fetch the Verification from.
Sid Path Parameter: The SID of the Verification.

Response


200 OK
{
  "sid": "1141798b-6c9c-4047-8c92-7848d4687573",
  "account_sid": "bd22e5b9-b147-4c00-851d-f3f19b63d153",
  "date_created": "2024-05-30T07:53:14Z",
  "date_updated": "2024-05-30T07:53:14Z",
  "service_sid": "ed283952-8869-416b-8273-e347b3114ee3",
  "to": "+85512334667",
  "channel": "sms",
  "status": "pending",
  "url": "http://verify.lvh.me/v2/Services/ed283952-8869-416b-8273-e347b3114ee3/Verifications/1141798b-6c9c-4047-8c92-7848d4687573",
  "send_code_attempts": [

  ]
}

6. Update a Verification Status

Manually mark the verification as approved after your application had validated the verification code or mark the verification as canceled to start a new verification session with a different code before the previous code expires (10 minutes). Only recommended during testing or if you're using custom verification codes.

For most other use cases, Verify is able to manage the complete lifecycle of a verification with the Verification Check Resource.

Request

curl -X POST "https://verify.somleng.org/v2/Services/44578da8-d25c-4740-bc46-3f85818e5283/Verifications/0c888519-8923-4c61-aef2-a5e3349a9a87" \
    -u 11907725-89c7-47c3-ac45-e6864fe9b329:AuthToken \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "Status=approved"

Endpoint

POST https://verify.somleng.org/v2/Services/:ServiceSid/Verifications/:Sid

POST https://verify.somleng.org/v2/Services/44578da8-d25c-4740-bc46-3f85818e5283/Verifications/0c888519-8923-4c61-aef2-a5e3349a9a87

Parameters

{
  "Status": "approved"
}
Name Description
ServiceSid Path Parameter: The SID of the Verification Service to update the resource from.
Sid The SID of the Verification resource to update.
To required The phone number or email to verify. Phone numbers must be in E.164 format.
Status required The new status of the resource. Can be: canceled or approved.

Response


200 OK
{
  "sid": "0c888519-8923-4c61-aef2-a5e3349a9a87",
  "account_sid": "11907725-89c7-47c3-ac45-e6864fe9b329",
  "date_created": "2024-05-30T07:53:14Z",
  "date_updated": "2024-05-30T07:53:14Z",
  "service_sid": "44578da8-d25c-4740-bc46-3f85818e5283",
  "to": "+85512334667",
  "channel": "sms",
  "status": "approved",
  "url": "http://verify.lvh.me/v2/Services/44578da8-d25c-4740-bc46-3f85818e5283/Verifications/0c888519-8923-4c61-aef2-a5e3349a9a87",
  "send_code_attempts": [

  ]
}