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
01. Fetch an account
Returns a representation of an account, including the properties above.
Request
curl "https://api.somleng.org/2010-04-01/Accounts/bac59636-c103-4824-ba6f-e9f5b48fe820" \
-u bac59636-c103-4824-ba6f-e9f5b48fe820:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:Sid
GET https://api.somleng.org/2010-04-01/Accounts/bac59636-c103-4824-ba6f-e9f5b48fe820
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": "bac59636-c103-4824-ba6f-e9f5b48fe820",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"auth_token": "mOc2wgAaFrCsXlFh_vGgYk4b8OkDSKlWsz8BH2GGwWI",
"friendly_name": "Rocket Rides",
"owner_account_sid": "bac59636-c103-4824-ba6f-e9f5b48fe820",
"status": "active",
"type": "Full",
"uri": "/2010-04-01/Accounts/bac59636-c103-4824-ba6f-e9f5b48fe820",
"subresource_uris": {
"calls": "/2010-04-01/Accounts/bac59636-c103-4824-ba6f-e9f5b48fe820/Calls",
"messages": "/2010-04-01/Accounts/bac59636-c103-4824-ba6f-e9f5b48fe820/Messages",
"recordings": "/2010-04-01/Accounts/bac59636-c103-4824-ba6f-e9f5b48fe820/Recordings"
}
}
Available Phone Numbers
01. 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/05581896-afec-47ee-b578-52a3e0736b82/AvailablePhoneNumbers/CA/Local" \
-u 05581896-afec-47ee-b578-52a3e0736b82:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/05581896-afec-47ee-b578-52a3e0736b82/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/05581896-afec-47ee-b578-52a3e0736b82/AvailablePhoneNumbers/CA/Local",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/05581896-afec-47ee-b578-52a3e0736b82/AvailablePhoneNumbers/CA/Local?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/05581896-afec-47ee-b578-52a3e0736b82/AvailablePhoneNumbers/CA/Local?Page=0&PageToken=PB2667dfc9-0cb6-4355-8738-b511d3f98aa2",
"next_page_uri": null
}
02. 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/2b3d392c-f5e1-4ab6-8792-ce45be119d04/AvailablePhoneNumbers/CA/Local?AreaCode=201" \
-u 2b3d392c-f5e1-4ab6-8792-ce45be119d04:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/2b3d392c-f5e1-4ab6-8792-ce45be119d04/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/2b3d392c-f5e1-4ab6-8792-ce45be119d04/AvailablePhoneNumbers/CA/Local?AreaCode=201",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/2b3d392c-f5e1-4ab6-8792-ce45be119d04/AvailablePhoneNumbers/CA/Local?AreaCode=201&Page=0",
"previous_page_uri": "/2010-04-01/Accounts/2b3d392c-f5e1-4ab6-8792-ce45be119d04/AvailablePhoneNumbers/CA/Local?AreaCode=201&Page=0&PageToken=PBb601e1af-2080-49a6-842f-acef811d0715",
"next_page_uri": null
}
03. Find available local phone numbers by region
Find available Local
phone numbers in Ontario
.
Request
curl "https://api.somleng.org/2010-04-01/Accounts/700facf5-e907-4d6b-812c-6c3d7f150987/AvailablePhoneNumbers/CA/Local?InRegion=ON" \
-u 700facf5-e907-4d6b-812c-6c3d7f150987:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/700facf5-e907-4d6b-812c-6c3d7f150987/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/700facf5-e907-4d6b-812c-6c3d7f150987/AvailablePhoneNumbers/CA/Local?InRegion=ON",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/700facf5-e907-4d6b-812c-6c3d7f150987/AvailablePhoneNumbers/CA/Local?InRegion=ON&Page=0",
"previous_page_uri": "/2010-04-01/Accounts/700facf5-e907-4d6b-812c-6c3d7f150987/AvailablePhoneNumbers/CA/Local?InRegion=ON&Page=0&PageToken=PB5a97462a-0aec-4fda-9f29-230709a9de4b",
"next_page_uri": null
}
04. Find available local phone numbers by locality
Find available Local
phone numbers in Toronto
.
Request
curl "https://api.somleng.org/2010-04-01/Accounts/2a08899d-7d92-4b24-8c5f-7a90a9dad2d4/AvailablePhoneNumbers/CA/Local?InLocality=Toronto" \
-u 2a08899d-7d92-4b24-8c5f-7a90a9dad2d4:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/2a08899d-7d92-4b24-8c5f-7a90a9dad2d4/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/2a08899d-7d92-4b24-8c5f-7a90a9dad2d4/AvailablePhoneNumbers/CA/Local?InLocality=Toronto",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/2a08899d-7d92-4b24-8c5f-7a90a9dad2d4/AvailablePhoneNumbers/CA/Local?InLocality=Toronto&Page=0",
"previous_page_uri": "/2010-04-01/Accounts/2a08899d-7d92-4b24-8c5f-7a90a9dad2d4/AvailablePhoneNumbers/CA/Local?InLocality=Toronto&Page=0&PageToken=PBff9d4d32-18ba-4a5f-a06e-bbbb067ad70b",
"next_page_uri": null
}
05. Find available local phone numbers by LATA and Rate center
Find available Local
phone numbers in LATA 888
and Rate Center NEWTORONTO
.
Request
curl "https://api.somleng.org/2010-04-01/Accounts/7ddf911f-1b9b-429a-aa18-938a2f293d9a/AvailablePhoneNumbers/CA/Local?InLata=888&InRateCenter=NEWTORONTO" \
-u 7ddf911f-1b9b-429a-aa18-938a2f293d9a:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/7ddf911f-1b9b-429a-aa18-938a2f293d9a/AvailablePhoneNumbers/CA/Local?InLata=888&InRateCenter=NEWTORONTO
Parameters
{
"InLata": "888",
"InRateCenter": "NEWTORONTO"
}
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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
Response
200 OK
{
"available_phone_numbers": [
{
"friendly_name": "+1 (647) 309-5500",
"phone_number": "+16473095500",
"lata": "888",
"rate_center": "NEWTORONTO",
"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/7ddf911f-1b9b-429a-aa18-938a2f293d9a/AvailablePhoneNumbers/CA/Local?InLata=888&InRateCenter=NEWTORONTO",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/7ddf911f-1b9b-429a-aa18-938a2f293d9a/AvailablePhoneNumbers/CA/Local?InLata=888&InRateCenter=NEWTORONTO&Page=0",
"previous_page_uri": "/2010-04-01/Accounts/7ddf911f-1b9b-429a-aa18-938a2f293d9a/AvailablePhoneNumbers/CA/Local?InLata=888&InRateCenter=NEWTORONTO&Page=0&PageToken=PB5894797f-10db-4d44-b3ea-619a8f626227",
"next_page_uri": null
}
06. 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/bb32d341-a1d1-4d9b-991b-1d47247bdbfa/AvailablePhoneNumbers/CA/Mobile" \
-u bb32d341-a1d1-4d9b-991b-1d47247bdbfa:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/bb32d341-a1d1-4d9b-991b-1d47247bdbfa/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/bb32d341-a1d1-4d9b-991b-1d47247bdbfa/AvailablePhoneNumbers/CA/Mobile",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/bb32d341-a1d1-4d9b-991b-1d47247bdbfa/AvailablePhoneNumbers/CA/Mobile?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/bb32d341-a1d1-4d9b-991b-1d47247bdbfa/AvailablePhoneNumbers/CA/Mobile?Page=0&PageToken=PBdcafba6a-fa2d-44eb-b5ce-77df4d1a6106",
"next_page_uri": null
}
07. 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/2af68af4-2e2d-42af-8383-7c3e25ace52b/AvailablePhoneNumbers/CA/TollFree" \
-u 2af68af4-2e2d-42af-8383-7c3e25ace52b:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/2af68af4-2e2d-42af-8383-7c3e25ace52b/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/2af68af4-2e2d-42af-8383-7c3e25ace52b/AvailablePhoneNumbers/CA/TollFree",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/2af68af4-2e2d-42af-8383-7c3e25ace52b/AvailablePhoneNumbers/CA/TollFree?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/2af68af4-2e2d-42af-8383-7c3e25ace52b/AvailablePhoneNumbers/CA/TollFree?Page=0&PageToken=PBe99c611c-7167-48d8-9d21-46fbdd320a81",
"next_page_uri": null
}
08. 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/f94fc905-c148-48c2-bc71-6ff0cf174b22/AvailablePhoneNumbers/CA/ShortCode" \
-u f94fc905-c148-48c2-bc71-6ff0cf174b22:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode/:Type
GET https://api.somleng.org/2010-04-01/Accounts/f94fc905-c148-48c2-bc71-6ff0cf174b22/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. |
InLata | Query Parameter: Limit results to a specific local access and transport area (LATA). Applies to only phone numbers in the US and Canada. |
InRateCenter | Query Parameter: Limit results to a specific rate center. Requires InLata to be set as well. Applies to only phone numbers in the US and Canada. |
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/f94fc905-c148-48c2-bc71-6ff0cf174b22/AvailablePhoneNumbers/CA/ShortCode",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/f94fc905-c148-48c2-bc71-6ff0cf174b22/AvailablePhoneNumbers/CA/ShortCode?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/f94fc905-c148-48c2-bc71-6ff0cf174b22/AvailablePhoneNumbers/CA/ShortCode?Page=0&PageToken=PBe3d76353-2302-4974-8380-c28dc3437389",
"next_page_uri": null
}
09. 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/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers" \
-u 01f8f2dc-09ee-4643-9d7c-3ae615f5b87f:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers
GET https://api.somleng.org/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/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/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/CA",
"beta": false,
"subresource_uris": {
"short_code": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/CA/ShortCode",
"local": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/CA/Local",
"mobile": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/CA/Mobile",
"toll_free": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/CA/TollFree"
}
},
{
"country_code": "KH",
"country": "Cambodia",
"uri": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/KH",
"beta": false,
"subresource_uris": {
"short_code": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/KH/ShortCode",
"local": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/KH/Local",
"mobile": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/KH/Mobile",
"toll_free": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers/KH/TollFree"
}
}
],
"uri": "/2010-04-01/Accounts/01f8f2dc-09ee-4643-9d7c-3ae615f5b87f/AvailablePhoneNumbers"
}
10. 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/f3398597-56e4-46ab-8581-bd3e207b509d/AvailablePhoneNumbers/CA" \
-u f3398597-56e4-46ab-8581-bd3e207b509d:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/AvailablePhoneNumbers/:CountryCode
GET https://api.somleng.org/2010-04-01/Accounts/f3398597-56e4-46ab-8581-bd3e207b509d/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/f3398597-56e4-46ab-8581-bd3e207b509d/AvailablePhoneNumbers/CA",
"beta": false,
"subresource_uris": {
"short_code": "/2010-04-01/Accounts/f3398597-56e4-46ab-8581-bd3e207b509d/AvailablePhoneNumbers/CA/ShortCode",
"local": "/2010-04-01/Accounts/f3398597-56e4-46ab-8581-bd3e207b509d/AvailablePhoneNumbers/CA/Local",
"mobile": "/2010-04-01/Accounts/f3398597-56e4-46ab-8581-bd3e207b509d/AvailablePhoneNumbers/CA/Mobile",
"toll_free": "/2010-04-01/Accounts/f3398597-56e4-46ab-8581-bd3e207b509d/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.
01. 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/a358cdcc-b4d6-48be-af70-39b2b2ede5e1/IncomingPhoneNumbers" \
-u a358cdcc-b4d6-48be-af70-39b2b2ede5e1: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/a358cdcc-b4d6-48be-af70-39b2b2ede5e1/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": "e13eb58e-d69d-4663-bae6-5620ef8746c6",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"account_sid": "a358cdcc-b4d6-48be-af70-39b2b2ede5e1",
"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/a358cdcc-b4d6-48be-af70-39b2b2ede5e1/IncomingPhoneNumbers/e13eb58e-d69d-4663-bae6-5620ef8746c6",
"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"
}
02. 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/10e85de6-87e5-4f10-bfcc-9bbca5ac91bf/IncomingPhoneNumbers" \
-u 10e85de6-87e5-4f10-bfcc-9bbca5ac91bf: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/10e85de6-87e5-4f10-bfcc-9bbca5ac91bf/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": "eadf2d36-3eef-4825-9940-a2d5c9786c7e",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"account_sid": "10e85de6-87e5-4f10-bfcc-9bbca5ac91bf",
"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/10e85de6-87e5-4f10-bfcc-9bbca5ac91bf/IncomingPhoneNumbers/eadf2d36-3eef-4825-9940-a2d5c9786c7e",
"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"
}
03. 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/cc409603-3bc1-4389-a476-cecb5360a086/IncomingPhoneNumbers" \
-u cc409603-3bc1-4389-a476-cecb5360a086: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/cc409603-3bc1-4389-a476-cecb5360a086/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": "81a2825c-0ea5-4a27-a353-44af7a015322",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"account_sid": "cc409603-3bc1-4389-a476-cecb5360a086",
"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/cc409603-3bc1-4389-a476-cecb5360a086/IncomingPhoneNumbers/81a2825c-0ea5-4a27-a353-44af7a015322",
"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"
}
04. Fetch an IncomingPhoneNumber resource
Fetch an IncomingPhoneNumber
Request
curl "https://api.somleng.org/2010-04-01/Accounts/22f372f4-044d-4e9e-a08a-1350872f0a49/IncomingPhoneNumbers/a56640c3-78db-4691-98d1-1cf4412723a1" \
-u 22f372f4-044d-4e9e-a08a-1350872f0a49:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers/:Sid
GET https://api.somleng.org/2010-04-01/Accounts/22f372f4-044d-4e9e-a08a-1350872f0a49/IncomingPhoneNumbers/a56640c3-78db-4691-98d1-1cf4412723a1
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": "a56640c3-78db-4691-98d1-1cf4412723a1",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"account_sid": "22f372f4-044d-4e9e-a08a-1350872f0a49",
"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/22f372f4-044d-4e9e-a08a-1350872f0a49/IncomingPhoneNumbers/a56640c3-78db-4691-98d1-1cf4412723a1",
"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"
}
05. Read a list of Incoming Phone Numbers
List all IncomingPhoneNumber resources for your account.
Request
curl "https://api.somleng.org/2010-04-01/Accounts/9be12c3b-80d6-463b-abaf-53efa33a0e25/IncomingPhoneNumbers?PhoneNumber=%2B12513095500" \
-u 9be12c3b-80d6-463b-abaf-53efa33a0e25:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/IncomingPhoneNumbers
GET https://api.somleng.org/2010-04-01/Accounts/9be12c3b-80d6-463b-abaf-53efa33a0e25/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": "253920a6-3c9c-48ff-b38e-dfe7b48e49f6",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"account_sid": "9be12c3b-80d6-463b-abaf-53efa33a0e25",
"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/9be12c3b-80d6-463b-abaf-53efa33a0e25/IncomingPhoneNumbers/253920a6-3c9c-48ff-b38e-dfe7b48e49f6",
"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/9be12c3b-80d6-463b-abaf-53efa33a0e25/IncomingPhoneNumbers?PhoneNumber=%2B12513095500",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/9be12c3b-80d6-463b-abaf-53efa33a0e25/IncomingPhoneNumbers?Page=0&PhoneNumber=%2B12513095500",
"previous_page_uri": "/2010-04-01/Accounts/9be12c3b-80d6-463b-abaf-53efa33a0e25/IncomingPhoneNumbers?Page=0&PageToken=PB253920a6-3c9c-48ff-b38e-dfe7b48e49f6&PhoneNumber=%2B12513095500",
"next_page_uri": null
}
06. 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/0c20b23c-f294-42e5-9ab6-793ab0b90274/IncomingPhoneNumbers/50b43f25-caf3-4770-9232-6250da45dea3" \
-u 0c20b23c-f294-42e5-9ab6-793ab0b90274: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/0c20b23c-f294-42e5-9ab6-793ab0b90274/IncomingPhoneNumbers/50b43f25-caf3-4770-9232-6250da45dea3
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": "50b43f25-caf3-4770-9232-6250da45dea3",
"date_created": "Thu, 31 Oct 2024 13:59:49 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:49 -0000",
"account_sid": "0c20b23c-f294-42e5-9ab6-793ab0b90274",
"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 5847",
"identity_sid": null,
"origin": "hosted",
"phone_number": "+855972345847",
"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/0c20b23c-f294-42e5-9ab6-793ab0b90274/IncomingPhoneNumbers/50b43f25-caf3-4770-9232-6250da45dea3",
"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"
}
07. 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/c79b19aa-edee-4acd-a902-602bc44bd623/IncomingPhoneNumbers/ce026079-7d24-400a-a402-b5c50267fca8" -d '' -X DELETE \
-u c79b19aa-edee-4acd-a902-602bc44bd623: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/c79b19aa-edee-4acd-a902-602bc44bd623/IncomingPhoneNumbers/ce026079-7d24-400a-a402-b5c50267fca8
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
01. 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/76612001-b721-4456-a1ea-153f3802d3a1/Messages" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 76612001-b721-4456-a1ea-153f3802d3a1: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/76612001-b721-4456-a1ea-153f3802d3a1/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": "8ebb0a6d-f1b3-4e83-be92-651f3d87f6bb",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "76612001-b721-4456-a1ea-153f3802d3a1",
"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/76612001-b721-4456-a1ea-153f3802d3a1/Messages/8ebb0a6d-f1b3-4e83-be92-651f3d87f6bb"
}
02. 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/f2041754-00f6-40f1-8256-5715d16bcce4/Messages" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u f2041754-00f6-40f1-8256-5715d16bcce4:AuthToken \
--data-urlencode "To=+855716788123" \
--data-urlencode "MessagingServiceSid=65f3992b-2ab3-47d1-a7fe-87a442b8c4e7" \
--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/f2041754-00f6-40f1-8256-5715d16bcce4/Messages
Parameters
{
"To": "+855716788123",
"MessagingServiceSid": "65f3992b-2ab3-47d1-a7fe-87a442b8c4e7",
"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": "337e15f4-ec96-4f37-9f0e-f16cf76662cb",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "f2041754-00f6-40f1-8256-5715d16bcce4",
"body": "Hello World",
"date_sent": null,
"direction": "outbound-api",
"error_code": null,
"error_message": null,
"from": null,
"messaging_service_sid": "65f3992b-2ab3-47d1-a7fe-87a442b8c4e7",
"num_media": "0",
"num_segments": "1",
"price": null,
"price_unit": null,
"status": "accepted",
"subresource_uris": {
},
"tags": {
},
"to": "+855716788123",
"uri": "/2010-04-01/Accounts/f2041754-00f6-40f1-8256-5715d16bcce4/Messages/337e15f4-ec96-4f37-9f0e-f16cf76662cb"
}
03. 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/66f738bc-c32b-4192-ae8a-8b01b0300ab8/Messages" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 66f738bc-c32b-4192-ae8a-8b01b0300ab8:AuthToken \
--data-urlencode "To=+855716788123" \
--data-urlencode "Body=Hello World" \
--data-urlencode "SendAt=2024-11-05T13:59:27Z" \
--data-urlencode "ScheduleType=fixed" \
--data-urlencode "MessagingServiceSid=9aff0cfe-7ca0-49a5-ab74-716068229dcf"
Endpoint
POST https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages
POST https://api.somleng.org/2010-04-01/Accounts/66f738bc-c32b-4192-ae8a-8b01b0300ab8/Messages
Parameters
{
"To": "+855716788123",
"Body": "Hello World",
"SendAt": "2024-11-05T13:59:27Z",
"ScheduleType": "fixed",
"MessagingServiceSid": "9aff0cfe-7ca0-49a5-ab74-716068229dcf"
}
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": "d5fb2851-d668-4e31-bb39-87cc6e724af8",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "66f738bc-c32b-4192-ae8a-8b01b0300ab8",
"body": "Hello World",
"date_sent": null,
"direction": "outbound-api",
"error_code": null,
"error_message": null,
"from": null,
"messaging_service_sid": "9aff0cfe-7ca0-49a5-ab74-716068229dcf",
"num_media": "0",
"num_segments": "1",
"price": null,
"price_unit": null,
"status": "scheduled",
"subresource_uris": {
},
"tags": {
},
"to": "+855716788123",
"uri": "/2010-04-01/Accounts/66f738bc-c32b-4192-ae8a-8b01b0300ab8/Messages/d5fb2851-d668-4e31-bb39-87cc6e724af8"
}
04. Fetch a Message
Returns a single Message resource specified by the provided Message SID
.
Request
curl "https://api.somleng.org/2010-04-01/Accounts/533d0fcd-5214-4c5e-80ec-564c7b3176b7/Messages/1091eae1-50ad-459f-a4bb-33a0bb103a3f" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 533d0fcd-5214-4c5e-80ec-564c7b3176b7:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages/:Sid
GET https://api.somleng.org/2010-04-01/Accounts/533d0fcd-5214-4c5e-80ec-564c7b3176b7/Messages/1091eae1-50ad-459f-a4bb-33a0bb103a3f
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": "1091eae1-50ad-459f-a4bb-33a0bb103a3f",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "533d0fcd-5214-4c5e-80ec-564c7b3176b7",
"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/533d0fcd-5214-4c5e-80ec-564c7b3176b7/Messages/1091eae1-50ad-459f-a4bb-33a0bb103a3f"
}
05. List all messages
Returns a list of all Message resources associated with your Account
Request
curl "https://api.somleng.org/2010-04-01/Accounts/a7991a2c-8707-44b7-9dd4-810003978149/Messages" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u a7991a2c-8707-44b7-9dd4-810003978149:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages
GET https://api.somleng.org/2010-04-01/Accounts/a7991a2c-8707-44b7-9dd4-810003978149/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": "c540603d-b4b3-438a-aa10-366f4e6a704f",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "a7991a2c-8707-44b7-9dd4-810003978149",
"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/a7991a2c-8707-44b7-9dd4-810003978149/Messages/c540603d-b4b3-438a-aa10-366f4e6a704f"
}
],
"uri": "/2010-04-01/Accounts/a7991a2c-8707-44b7-9dd4-810003978149/Messages",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/a7991a2c-8707-44b7-9dd4-810003978149/Messages?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/a7991a2c-8707-44b7-9dd4-810003978149/Messages?Page=0&PageToken=PBc540603d-b4b3-438a-aa10-366f4e6a704f",
"next_page_uri": null
}
06. 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/06e34ba9-2cd0-44fe-9499-bf6f77049ba6/Messages/a408a108-8e79-424c-84a1-673b9a9f1ae6" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 06e34ba9-2cd0-44fe-9499-bf6f77049ba6: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/06e34ba9-2cd0-44fe-9499-bf6f77049ba6/Messages/a408a108-8e79-424c-84a1-673b9a9f1ae6
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": "a408a108-8e79-424c-84a1-673b9a9f1ae6",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "06e34ba9-2cd0-44fe-9499-bf6f77049ba6",
"body": "",
"date_sent": "Thu, 31 Oct 2024 13:59:27 -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/06e34ba9-2cd0-44fe-9499-bf6f77049ba6/Messages/a408a108-8e79-424c-84a1-673b9a9f1ae6"
}
07. Cancel a scheduled message
Before you use this functionality:
- Ensure the status value of canceled is spelled with one "l", (canceled) and not two (cancelled).
- Ensure that you store the
MessageSid
of the messages you schedule. You need to reference theMessageSid
for each message cancelation request. - 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
. - There is a new status callback event for
Canceled
. You can continue to receive existing callback events by including the optionalStatusCallBack
parameter in the message request.
Request
curl -X POST "https://api.somleng.org/2010-04-01/Accounts/103ff837-567d-44d8-8b53-fa608394947f/Messages/45768f98-d526-40cc-a728-320e49e056bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 103ff837-567d-44d8-8b53-fa608394947f: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/103ff837-567d-44d8-8b53-fa608394947f/Messages/45768f98-d526-40cc-a728-320e49e056bb
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": "45768f98-d526-40cc-a728-320e49e056bb",
"date_created": "Thu, 31 Oct 2024 13:59:27 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:27 -0000",
"account_sid": "103ff837-567d-44d8-8b53-fa608394947f",
"body": "Hello World",
"date_sent": null,
"direction": "outbound-api",
"error_code": null,
"error_message": null,
"from": null,
"messaging_service_sid": "a047a4cc-367b-450b-9874-9cb4a59b8b7c",
"num_media": "0",
"num_segments": "1",
"price": null,
"price_unit": null,
"status": "canceled",
"subresource_uris": {
},
"tags": {
},
"to": "+85512334667",
"uri": "/2010-04-01/Accounts/103ff837-567d-44d8-8b53-fa608394947f/Messages/45768f98-d526-40cc-a728-320e49e056bb"
}
08. 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/60b3eedc-7998-477c-9482-bc0847654d74/Messages/bb116717-7d9f-4f01-a1a1-e42d415a69b1" -d '' -X DELETE \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 60b3eedc-7998-477c-9482-bc0847654d74:AuthToken
Endpoint
DELETE https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Messages/:Sid
DELETE https://api.somleng.org/2010-04-01/Accounts/60b3eedc-7998-477c-9482-bc0847654d74/Messages/bb116717-7d9f-4f01-a1a1-e42d415a69b1
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.
01. 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/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls?PageSize=2" \
-u 9e0ec447-2f37-4aa2-a1c2-094be0f00a87:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls
GET https://api.somleng.org/2010-04-01/Accounts/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/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": "a1d90c70-dc3a-47ce-bbdd-5e9f63481853",
"date_created": "Thu, 31 Oct 2024 13:59:34 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:34 -0000",
"account_sid": "9e0ec447-2f37-4aa2-a1c2-094be0f00a87",
"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/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls/a1d90c70-dc3a-47ce-bbdd-5e9f63481853"
},
{
"api_version": "2010-04-01",
"sid": "b3ea5fb8-93c0-47ed-be2c-2f579be78d2d",
"date_created": "Thu, 31 Oct 2024 13:59:34 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:34 -0000",
"account_sid": "9e0ec447-2f37-4aa2-a1c2-094be0f00a87",
"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/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls/b3ea5fb8-93c0-47ed-be2c-2f579be78d2d"
}
],
"uri": "/2010-04-01/Accounts/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls?PageSize=2",
"page": 0,
"page_size": 2,
"first_page_uri": "/2010-04-01/Accounts/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls?Page=0&PageSize=2",
"previous_page_uri": "/2010-04-01/Accounts/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls?Page=0&PageSize=2&PageToken=PBa1d90c70-dc3a-47ce-bbdd-5e9f63481853",
"next_page_uri": "/2010-04-01/Accounts/9e0ec447-2f37-4aa2-a1c2-094be0f00a87/Calls?Page=1&PageSize=2&PageToken=PAb3ea5fb8-93c0-47ed-be2c-2f579be78d2d"
}
Phone Calls
01. 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/ae5babf7-4fb4-4d14-8930-74900f6d4e1e/Calls" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u ae5babf7-4fb4-4d14-8930-74900f6d4e1e: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/ae5babf7-4fb4-4d14-8930-74900f6d4e1e/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": "2fef4f1b-1d9d-4dbb-8928-ec068e0c304c",
"date_created": "Thu, 31 Oct 2024 13:59:11 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:11 -0000",
"account_sid": "ae5babf7-4fb4-4d14-8930-74900f6d4e1e",
"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": "b51664d6-19ba-46ce-b968-4197ff724e50",
"price": null,
"price_unit": null,
"start_time": null,
"status": "queued",
"subresource_uris": {
},
"to": "+299221234",
"to_formatted": "+299 22 1234",
"uri": "/2010-04-01/Accounts/ae5babf7-4fb4-4d14-8930-74900f6d4e1e/Calls/2fef4f1b-1d9d-4dbb-8928-ec068e0c304c"
}
02. 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/cbf2bf14-81f0-41d9-aeaa-5416ee88f462/Calls/716701b0-a5a1-4ef8-9a89-f6dd1e87f20b" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u cbf2bf14-81f0-41d9-aeaa-5416ee88f462:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:Sid
GET https://api.somleng.org/2010-04-01/Accounts/cbf2bf14-81f0-41d9-aeaa-5416ee88f462/Calls/716701b0-a5a1-4ef8-9a89-f6dd1e87f20b
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": "716701b0-a5a1-4ef8-9a89-f6dd1e87f20b",
"date_created": "Thu, 31 Oct 2024 13:59:11 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:11 -0000",
"account_sid": "cbf2bf14-81f0-41d9-aeaa-5416ee88f462",
"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/cbf2bf14-81f0-41d9-aeaa-5416ee88f462/Calls/716701b0-a5a1-4ef8-9a89-f6dd1e87f20b"
}
03. 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/66bd1b7b-1f8b-4b8a-b561-98069e3831f9/Calls" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 66bd1b7b-1f8b-4b8a-b561-98069e3831f9:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls
GET https://api.somleng.org/2010-04-01/Accounts/66bd1b7b-1f8b-4b8a-b561-98069e3831f9/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": "455b04b5-b217-41a4-b737-516e5052274b",
"date_created": "Thu, 31 Oct 2024 13:59:11 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:11 -0000",
"account_sid": "66bd1b7b-1f8b-4b8a-b561-98069e3831f9",
"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/66bd1b7b-1f8b-4b8a-b561-98069e3831f9/Calls/455b04b5-b217-41a4-b737-516e5052274b"
}
],
"uri": "/2010-04-01/Accounts/66bd1b7b-1f8b-4b8a-b561-98069e3831f9/Calls",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/66bd1b7b-1f8b-4b8a-b561-98069e3831f9/Calls?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/66bd1b7b-1f8b-4b8a-b561-98069e3831f9/Calls?Page=0&PageToken=PB455b04b5-b217-41a4-b737-516e5052274b",
"next_page_uri": null
}
04. 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/0195771e-2704-49ca-872b-6c3435fee55e/Calls/37123133-6692-45b6-ab25-d8e7fc194d12" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 0195771e-2704-49ca-872b-6c3435fee55e: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/0195771e-2704-49ca-872b-6c3435fee55e/Calls/37123133-6692-45b6-ab25-d8e7fc194d12
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": "37123133-6692-45b6-ab25-d8e7fc194d12",
"date_created": "Thu, 31 Oct 2024 13:59:11 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:11 -0000",
"account_sid": "0195771e-2704-49ca-872b-6c3435fee55e",
"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/0195771e-2704-49ca-872b-6c3435fee55e/Calls/37123133-6692-45b6-ab25-d8e7fc194d12"
}
05. 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/5d813cf2-3151-49c3-86cb-908f790a6d49/Calls/c2d5122b-249a-4713-824f-68b77d10f15c" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 5d813cf2-3151-49c3-86cb-908f790a6d49: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/5d813cf2-3151-49c3-86cb-908f790a6d49/Calls/c2d5122b-249a-4713-824f-68b77d10f15c
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": "c2d5122b-249a-4713-824f-68b77d10f15c",
"date_created": "Thu, 31 Oct 2024 13:59:11 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:11 -0000",
"account_sid": "5d813cf2-3151-49c3-86cb-908f790a6d49",
"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/5d813cf2-3151-49c3-86cb-908f790a6d49/Calls/c2d5122b-249a-4713-824f-68b77d10f15c"
}
06. 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/2df2ac37-c121-4243-b3c9-088848b81604/Calls/cef09f36-f35f-4804-a2da-72f99bedd5d3" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u 2df2ac37-c121-4243-b3c9-088848b81604: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/2df2ac37-c121-4243-b3c9-088848b81604/Calls/cef09f36-f35f-4804-a2da-72f99bedd5d3
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": "cef09f36-f35f-4804-a2da-72f99bedd5d3",
"date_created": "Thu, 31 Oct 2024 13:59:11 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:11 -0000",
"account_sid": "2df2ac37-c121-4243-b3c9-088848b81604",
"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/2df2ac37-c121-4243-b3c9-088848b81604/Calls/cef09f36-f35f-4804-a2da-72f99bedd5d3"
}
Recordings
01. 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/722d78cb-22b6-41c3-98ac-2362802a9895/Recordings/c82ac79a-b29d-424a-96a5-1d964f677c9a"
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings/:Sid
GET https://api.somleng.org/2010-04-01/Accounts/722d78cb-22b6-41c3-98ac-2362802a9895/Recordings/c82ac79a-b29d-424a-96a5-1d964f677c9a
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
02. 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/94fde203-ee93-450e-9cb2-af2bda93fee2/Recordings/b1064a6c-dcb5-4951-b925-1a477c2980a7.mp3"
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings/:Sid.mp3
GET https://api.somleng.org/2010-04-01/Accounts/94fde203-ee93-450e-9cb2-af2bda93fee2/Recordings/b1064a6c-dcb5-4951-b925-1a477c2980a7.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
03. 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/e737ad6c-d7a2-42b1-b1b4-f479141f52bb/Recordings/4f20aecf-fa1c-4465-8121-cacad9756813.json"
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings/:Sid.json
GET https://api.somleng.org/2010-04-01/Accounts/e737ad6c-d7a2-42b1-b1b4-f479141f52bb/Recordings/4f20aecf-fa1c-4465-8121-cacad9756813.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": "4f20aecf-fa1c-4465-8121-cacad9756813",
"date_created": "Thu, 31 Oct 2024 13:59:37 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:37 -0000",
"account_sid": "e737ad6c-d7a2-42b1-b1b4-f479141f52bb",
"call_sid": "42e1fb12-fbdc-44c7-a60f-401a2f0335c9",
"conference_sid": null,
"channels": 1,
"start_time": "2024-10-31T13:59:37.429Z",
"duration": null,
"price": null,
"price_unit": null,
"source": "RecordVerb",
"status": "processing",
"error_code": null,
"encryption_details": null,
"track": "both",
"uri": "/2010-04-01/Accounts/e737ad6c-d7a2-42b1-b1b4-f479141f52bb/Calls/42e1fb12-fbdc-44c7-a60f-401a2f0335c9/Recordings/4f20aecf-fa1c-4465-8121-cacad9756813.json"
}
04. Get all recordings for a given call
Request
curl "https://api.somleng.org/2010-04-01/Accounts/456e99b8-a9a1-4c46-9c6c-74771d23649a/Calls/7d34899c-f605-41bb-8ca8-ff28a4537cf8/Recordings" \
-u 456e99b8-a9a1-4c46-9c6c-74771d23649a:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Calls/:CallSid/Recordings
GET https://api.somleng.org/2010-04-01/Accounts/456e99b8-a9a1-4c46-9c6c-74771d23649a/Calls/7d34899c-f605-41bb-8ca8-ff28a4537cf8/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": "065c0f91-86a1-4e9c-a3dc-97e26a100c9c",
"date_created": "Thu, 31 Oct 2024 13:59:36 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:36 -0000",
"account_sid": "456e99b8-a9a1-4c46-9c6c-74771d23649a",
"call_sid": "7d34899c-f605-41bb-8ca8-ff28a4537cf8",
"conference_sid": null,
"channels": 1,
"start_time": "2024-10-31T13:59:36.336Z",
"duration": "0",
"price": null,
"price_unit": null,
"source": "RecordVerb",
"status": "completed",
"error_code": null,
"encryption_details": null,
"track": "both",
"uri": "/2010-04-01/Accounts/456e99b8-a9a1-4c46-9c6c-74771d23649a/Calls/7d34899c-f605-41bb-8ca8-ff28a4537cf8/Recordings/065c0f91-86a1-4e9c-a3dc-97e26a100c9c.json"
}
],
"uri": "/2010-04-01/Accounts/456e99b8-a9a1-4c46-9c6c-74771d23649a/Calls/7d34899c-f605-41bb-8ca8-ff28a4537cf8/Recordings",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/456e99b8-a9a1-4c46-9c6c-74771d23649a/Calls/7d34899c-f605-41bb-8ca8-ff28a4537cf8/Recordings?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/456e99b8-a9a1-4c46-9c6c-74771d23649a/Calls/7d34899c-f605-41bb-8ca8-ff28a4537cf8/Recordings?Page=0&PageToken=PB065c0f91-86a1-4e9c-a3dc-97e26a100c9c",
"next_page_uri": null
}
05. List recordings by account
Request
curl "https://api.somleng.org/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/Recordings" \
-u 3c97797f-06b7-4690-9c6d-1816d676b387:AuthToken
Endpoint
GET https://api.somleng.org/2010-04-01/Accounts/:AccountSid/Recordings
GET https://api.somleng.org/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/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": "73f5635e-5ad1-4827-bfeb-c341edf1e6fa",
"date_created": "Thu, 31 Oct 2024 13:59:37 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:37 -0000",
"account_sid": "3c97797f-06b7-4690-9c6d-1816d676b387",
"call_sid": "b0bdc91c-38c7-4946-b6c0-61c05d22b072",
"conference_sid": null,
"channels": 1,
"start_time": "2024-10-31T13:59:37.350Z",
"duration": null,
"price": null,
"price_unit": null,
"source": "RecordVerb",
"status": "processing",
"error_code": null,
"encryption_details": null,
"track": "both",
"uri": "/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/Calls/b0bdc91c-38c7-4946-b6c0-61c05d22b072/Recordings/73f5635e-5ad1-4827-bfeb-c341edf1e6fa.json"
},
{
"api_version": "2010-04-01",
"sid": "19d96243-8d31-4745-a1c0-f111d774be10",
"date_created": "Thu, 31 Oct 2024 13:59:37 -0000",
"date_updated": "Thu, 31 Oct 2024 13:59:37 -0000",
"account_sid": "3c97797f-06b7-4690-9c6d-1816d676b387",
"call_sid": "319a9744-fc2c-43e1-998b-4dbb3c68890b",
"conference_sid": null,
"channels": 1,
"start_time": "2024-10-31T13:59:37.322Z",
"duration": null,
"price": null,
"price_unit": null,
"source": "RecordVerb",
"status": "processing",
"error_code": null,
"encryption_details": null,
"track": "both",
"uri": "/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/Calls/319a9744-fc2c-43e1-998b-4dbb3c68890b/Recordings/19d96243-8d31-4745-a1c0-f111d774be10.json"
}
],
"uri": "/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/Recordings",
"page": 0,
"page_size": 50,
"first_page_uri": "/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/Recordings?Page=0",
"previous_page_uri": "/2010-04-01/Accounts/3c97797f-06b7-4690-9c6d-1816d676b387/Recordings?Page=0&PageToken=PB73f5635e-5ad1-4827-bfeb-c341edf1e6fa",
"next_page_uri": null
}
Verification Services
01. 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 b2e0eb9e-c4b9-48e1-b0a1-1bcf12f5e7a7: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": "fc808223-139d-41a9-8c35-f6280559984a",
"account_sid": "b2e0eb9e-c4b9-48e1-b0a1-1bcf12f5e7a7",
"date_created": "2024-10-31T13:59:19Z",
"date_updated": "2024-10-31T13:59:19Z",
"friendly_name": "My Verification Service",
"url": "http://verify.lvh.me/v2/Services/fc808223-139d-41a9-8c35-f6280559984a",
"code_length": 6
}
02. Fetch a Service
Request
curl "https://verify.somleng.org/v2/Services/1c763659-6b13-4822-9b27-14bc72569ca4" \
-u e59a78c1-cef4-4dbf-832f-04c5fba14731:AuthToken
Endpoint
GET https://verify.somleng.org/v2/Services/:Sid
GET https://verify.somleng.org/v2/Services/1c763659-6b13-4822-9b27-14bc72569ca4
Parameters
Name | Description |
---|---|
Sid | Path Parameter: The SID of the Verification Service to fetch. |
Response
200 OK
{
"sid": "1c763659-6b13-4822-9b27-14bc72569ca4",
"account_sid": "e59a78c1-cef4-4dbf-832f-04c5fba14731",
"date_created": "2024-10-31T13:59:19Z",
"date_updated": "2024-10-31T13:59:19Z",
"friendly_name": "My Verification Service",
"url": "http://verify.lvh.me/v2/Services/1c763659-6b13-4822-9b27-14bc72569ca4",
"code_length": 4
}
03. List all Services
Request
curl "https://verify.somleng.org/v2/Services" \
-u 57740246-0a4a-4c99-a632-bc5c7712ea50:AuthToken
Endpoint
GET https://verify.somleng.org/v2/Services
GET https://verify.somleng.org/v2/Services
Parameters
None known.
Response
200 OK
{
"services": [
{
"sid": "86080fe0-612f-425e-8216-9b78b56d3442",
"account_sid": "57740246-0a4a-4c99-a632-bc5c7712ea50",
"date_created": "2024-10-31T13:59:19Z",
"date_updated": "2024-10-31T13:59:19Z",
"friendly_name": "My Verification Service",
"url": "http://verify.lvh.me/v2/Services/86080fe0-612f-425e-8216-9b78b56d3442",
"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=PB86080fe0-612f-425e-8216-9b78b56d3442",
"next_page_url": null,
"key": "services"
}
}
04. Update a Service
This example updates the FriendlyName
and CodeLength
of a Verification Service.
Request
curl -X POST "https://verify.somleng.org/v2/Services/c70f2808-6d6d-49e8-bcbc-612438320056" \
-u 67766c02-2939-446d-b086-6850f5fca96b: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/c70f2808-6d6d-49e8-bcbc-612438320056
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": "c70f2808-6d6d-49e8-bcbc-612438320056",
"account_sid": "67766c02-2939-446d-b086-6850f5fca96b",
"date_created": "2024-10-31T13:59:19Z",
"date_updated": "2024-10-31T13:59:19Z",
"friendly_name": "Rocket Ride Service",
"url": "http://verify.lvh.me/v2/Services/c70f2808-6d6d-49e8-bcbc-612438320056",
"code_length": 6
}
05. Delete a Service
Request
curl "https://verify.somleng.org/v2/Services/fc34fa0b-cd3f-470c-b03f-f94c37ed89ae" -d '' -X DELETE \
-u 8d3e784d-48d3-4224-be55-38d0af59799f: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/fc34fa0b-cd3f-470c-b03f-f94c37ed89ae
Parameters
{
}
Name | Description |
---|---|
Sid | Path Parameter: The SID of the Verification Service to delete. |
Response
204 No Content
Verifications
01. 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/fd5464da-7874-48a1-a799-875d970656b9/Verifications" \
-u 21fc2e05-657b-4dad-a191-d568d2ee831d: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/fd5464da-7874-48a1-a799-875d970656b9/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 , de , es , fr , it , ja , nl , pt , ar , ca , da , fi , id , ko , pl , 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": "d4e5f686-b499-4436-bf73-d9d4eff17ed5",
"account_sid": "21fc2e05-657b-4dad-a191-d568d2ee831d",
"date_created": "2024-10-31T13:59:42Z",
"date_updated": "2024-10-31T13:59:42Z",
"service_sid": "fd5464da-7874-48a1-a799-875d970656b9",
"to": "+85512334667",
"channel": "sms",
"status": "pending",
"url": "http://verify.lvh.me/v2/Services/fd5464da-7874-48a1-a799-875d970656b9/Verifications/d4e5f686-b499-4436-bf73-d9d4eff17ed5",
"send_code_attempts": [
{
"attempt_sid": "295cfb02-3b6c-4860-8b22-705f770217e8",
"channel": "sms",
"time": "2024-10-31T13:59:42Z"
}
]
}
02. Start a Verification with Voice
Request
curl -X POST "https://verify.somleng.org/v2/Services/71d99d2d-a1de-479d-809b-412c3c16a988/Verifications" \
-u 319475e8-ef23-4dda-9d92-622485a39a1a: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/71d99d2d-a1de-479d-809b-412c3c16a988/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 , de , es , fr , it , ja , nl , pt , ar , ca , da , fi , id , ko , pl , 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": "2680f815-d6da-42b4-8956-a48a44899f97",
"account_sid": "319475e8-ef23-4dda-9d92-622485a39a1a",
"date_created": "2024-10-31T13:59:42Z",
"date_updated": "2024-10-31T13:59:42Z",
"service_sid": "71d99d2d-a1de-479d-809b-412c3c16a988",
"to": "+85512334667",
"channel": "call",
"status": "pending",
"url": "http://verify.lvh.me/v2/Services/71d99d2d-a1de-479d-809b-412c3c16a988/Verifications/2680f815-d6da-42b4-8956-a48a44899f97",
"send_code_attempts": [
{
"attempt_sid": "fbc631bd-8e30-479d-80b2-9561b33467f2",
"channel": "call",
"time": "2024-10-31T13:59:42Z"
}
]
}
03. 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:
- expired (10 minutes)
- approved or canceled
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/07b9d426-1c14-4974-9eca-1fcacb648d42/VerificationCheck" \
-u 525f8174-a9e9-4542-bf5f-606a3fe7d22f: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/07b9d426-1c14-4974-9eca-1fcacb648d42/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": "31dff2c2-c1f4-4dae-acef-9f579c09b855",
"account_sid": "525f8174-a9e9-4542-bf5f-606a3fe7d22f",
"date_created": "2024-10-31T13:59:41Z",
"date_updated": "2024-10-31T13:59:41Z",
"service_sid": "07b9d426-1c14-4974-9eca-1fcacb648d42",
"to": "+85512334667",
"channel": "sms",
"status": "approved"
}
04. Check a Verification with a SID
Request
curl -X POST "https://verify.somleng.org/v2/Services/06ef34f0-d35e-41b9-9de0-08a4ec6a1470/VerificationCheck" \
-u e9eed302-9ff8-44d7-a49d-7d42be96a744:AuthToken \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "VerificationSid=49c6389c-5d1c-419f-9229-1359ee2c0bfa" \
--data-urlencode "Code=1234"
Endpoint
POST https://verify.somleng.org/v2/Services/:ServiceSid/VerificationCheck
POST https://verify.somleng.org/v2/Services/06ef34f0-d35e-41b9-9de0-08a4ec6a1470/VerificationCheck
Parameters
{
"VerificationSid": "49c6389c-5d1c-419f-9229-1359ee2c0bfa",
"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": "49c6389c-5d1c-419f-9229-1359ee2c0bfa",
"account_sid": "e9eed302-9ff8-44d7-a49d-7d42be96a744",
"date_created": "2024-10-31T13:59:42Z",
"date_updated": "2024-10-31T13:59:42Z",
"service_sid": "06ef34f0-d35e-41b9-9de0-08a4ec6a1470",
"to": "+85512334667",
"channel": "sms",
"status": "approved"
}
05. Fetch a Verification
Request
curl "https://verify.somleng.org/v2/Services/4595aa36-2834-40f0-be21-658bc508a9e0/Verifications/17c65a89-e434-45a4-b5fa-c139a703a4ba" \
-u 04e0fa72-06e3-46b6-961e-e2acdf0f05a2:AuthToken
Endpoint
GET https://verify.somleng.org/v2/Services/:ServiceSid/Verifications/:Sid
GET https://verify.somleng.org/v2/Services/4595aa36-2834-40f0-be21-658bc508a9e0/Verifications/17c65a89-e434-45a4-b5fa-c139a703a4ba
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": "17c65a89-e434-45a4-b5fa-c139a703a4ba",
"account_sid": "04e0fa72-06e3-46b6-961e-e2acdf0f05a2",
"date_created": "2024-10-31T13:59:42Z",
"date_updated": "2024-10-31T13:59:42Z",
"service_sid": "4595aa36-2834-40f0-be21-658bc508a9e0",
"to": "+85512334667",
"channel": "sms",
"status": "pending",
"url": "http://verify.lvh.me/v2/Services/4595aa36-2834-40f0-be21-658bc508a9e0/Verifications/17c65a89-e434-45a4-b5fa-c139a703a4ba",
"send_code_attempts": [
]
}
06. 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/beb699e4-3bdd-4ba8-90c2-1634522d4447/Verifications/5b985e6a-18a6-420a-9462-d04ec569f656" \
-u 8356631b-d74d-467d-9aed-e644f702305a: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/beb699e4-3bdd-4ba8-90c2-1634522d4447/Verifications/5b985e6a-18a6-420a-9462-d04ec569f656
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": "5b985e6a-18a6-420a-9462-d04ec569f656",
"account_sid": "8356631b-d74d-467d-9aed-e644f702305a",
"date_created": "2024-10-31T13:59:42Z",
"date_updated": "2024-10-31T13:59:42Z",
"service_sid": "beb699e4-3bdd-4ba8-90c2-1634522d4447",
"to": "+85512334667",
"channel": "sms",
"status": "approved",
"url": "http://verify.lvh.me/v2/Services/beb699e4-3bdd-4ba8-90c2-1634522d4447/Verifications/5b985e6a-18a6-420a-9462-d04ec569f656",
"send_code_attempts": [
]
}