NAV
cURL

Introduction

Somleng is an Open Source Cloud Communications Platform as a Service (CPaaS). It contains an open source implementation of Twilio's REST API. Currently it only supports a tiny subset of Twilio's REST API. More features may be added in the future.

This API documentation is intended for users of the REST API.

Make an HTTP Request to Somleng

There are a lot of ways you can make an HTTP request to Somleng. You can make a raw HTTP request in your code (for example, using a module like got in NodeJS) or by using a tool like Postman. You might find it easier to use the Twilio Helper Library or SDK for your preferred programming language. These libraries can be usually be used with Somleng by overriding the URL parameter from api.twilio.com to api.somleng.org or that of your own host.

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

Phone Calls

Create a call

Request

curl "https://api.somleng.org/2010-04-01/Accounts/2d64fe6a-3ae7-4ed4-84c3-2779ceb7585f/Calls" -d 'To=%2B299221234&From=1234&Url=https%3A%2F%2Fdemo.twilio.com%2Fdocs%2Fvoice.xml' -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 2d64fe6a-3ae7-4ed4-84c3-2779ceb7585f:KLKxZDAxsDPq1WTY9b3QGXVaSwoSH2We7SK-UvxBWCc

Endpoint

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

POST https://api.somleng.org/2010-04-01/Accounts/2d64fe6a-3ae7-4ed4-84c3-2779ceb7585f/Calls

Parameters

To=%2B299221234&From=1234&Url=https%3A%2F%2Fdemo.twilio.com%2Fdocs%2Fvoice.xml
Name Description
To required The phone number to call.
From required The phone number to use as the caller id
Url 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 TwiML instructions for the call Somleng will use without fetching Twiml from Url parameter. If both Twiml and Url are provided then Twiml parameter will be ignored.
StatusCallback 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 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": "7d57419e-3d0a-4708-ad45-ea3f5494ce71",
  "account_sid": "2d64fe6a-3ae7-4ed4-84c3-2779ceb7585f",
  "date_created": "Thu, 14 Oct 2021 07:13:34 -0000",
  "date_updated": "Thu, 14 Oct 2021 07:13:34 -0000",
  "annotation": null,
  "answered_by": null,
  "caller_name": null,
  "direction": "outbound-api",
  "duration": null,
  "end_time": null,
  "forwarded_from": null,
  "from": "1234",
  "from_formatted": "1234",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": null,
  "price": null,
  "price_unit": null,
  "start_time": null,
  "status": "queued",
  "subresource_uris": {
  },
  "to": "+299221234",
  "to_formatted": "+299 22 1234",
  "uri": "https://api.somleng.org/2010-04-01/Accounts/2d64fe6a-3ae7-4ed4-84c3-2779ceb7585f/Calls/7d57419e-3d0a-4708-ad45-ea3f5494ce71"
}

Fetch a call

Request

curl -g "https://api.somleng.org/2010-04-01/Accounts/1a61d17f-4571-4218-875d-6b90e6d9621f/Calls/d6e814c7-eba7-48af-868e-6d08b6458a1c" -X GET \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 1a61d17f-4571-4218-875d-6b90e6d9621f:6duHYnQpovIbWl0LuOoWdeoS9ic2M8XxMH-zZ7XPG-E

Endpoint

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

GET https://api.somleng.org/2010-04-01/Accounts/1a61d17f-4571-4218-875d-6b90e6d9621f/Calls/d6e814c7-eba7-48af-868e-6d08b6458a1c

Parameters

None known.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "d6e814c7-eba7-48af-868e-6d08b6458a1c",
  "account_sid": "1a61d17f-4571-4218-875d-6b90e6d9621f",
  "date_created": "Thu, 14 Oct 2021 07:13:34 -0000",
  "date_updated": "Thu, 14 Oct 2021 07:13:34 -0000",
  "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": "https://api.somleng.org/2010-04-01/Accounts/1a61d17f-4571-4218-875d-6b90e6d9621f/Calls/d6e814c7-eba7-48af-868e-6d08b6458a1c"
}

Update a call

Request

curl "https://api.somleng.org/2010-04-01/Accounts/1e63f101-db6c-41b0-af23-f7656c8e07f1/Calls/b9afc786-9519-41e8-aa4c-d375ffb8797e" -d 'Status=completed' -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 1e63f101-db6c-41b0-af23-f7656c8e07f1:p2pY9llNlo5Ca7SB6J70YfQRInZ3XFvuGFuXv3FifQ8

Endpoint

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

POST https://api.somleng.org/2010-04-01/Accounts/1e63f101-db6c-41b0-af23-f7656c8e07f1/Calls/b9afc786-9519-41e8-aa4c-d375ffb8797e

Parameters

Status=completed
Name Description
Status 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": "b9afc786-9519-41e8-aa4c-d375ffb8797e",
  "account_sid": "1e63f101-db6c-41b0-af23-f7656c8e07f1",
  "date_created": "Thu, 14 Oct 2021 07:13:34 -0000",
  "date_updated": "Thu, 14 Oct 2021 07:13:34 -0000",
  "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": "https://api.somleng.org/2010-04-01/Accounts/1e63f101-db6c-41b0-af23-f7656c8e07f1/Calls/b9afc786-9519-41e8-aa4c-d375ffb8797e"
}