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/88e7ba92-bf66-4dc2-b1da-4ce772504541/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 88e7ba92-bf66-4dc2-b1da-4ce772504541:0h1tG0WKUEyZG63NT7N3ckG8AgBfPBehw0q8XRx9MRs

Endpoint

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

POST https://api.somleng.org/2010-04-01/Accounts/88e7ba92-bf66-4dc2-b1da-4ce772504541/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": "e0a22687-2149-402b-a163-fcd1f9a8949b",
  "account_sid": "88e7ba92-bf66-4dc2-b1da-4ce772504541",
  "date_created": "Fri, 17 Sep 2021 01:34:36 -0000",
  "date_updated": "Fri, 17 Sep 2021 01:34:36 -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/88e7ba92-bf66-4dc2-b1da-4ce772504541/Calls/e0a22687-2149-402b-a163-fcd1f9a8949b"
}

Fetch a call

Request

curl -g "https://api.somleng.org/2010-04-01/Accounts/e5b3d5e3-fc33-4e55-9a93-4177529fe704/Calls/5d9fd348-6de2-4a01-9e9b-2ed4e3104a81" -X GET \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u e5b3d5e3-fc33-4e55-9a93-4177529fe704:jzC7jl5LcRrDehfj53olarTbeKJs5bnWrZASXCpAEmA

Endpoint

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

GET https://api.somleng.org/2010-04-01/Accounts/e5b3d5e3-fc33-4e55-9a93-4177529fe704/Calls/5d9fd348-6de2-4a01-9e9b-2ed4e3104a81

Parameters

None known.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "5d9fd348-6de2-4a01-9e9b-2ed4e3104a81",
  "account_sid": "e5b3d5e3-fc33-4e55-9a93-4177529fe704",
  "date_created": "Fri, 17 Sep 2021 01:34:37 -0000",
  "date_updated": "Fri, 17 Sep 2021 01:34:37 -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/e5b3d5e3-fc33-4e55-9a93-4177529fe704/Calls/5d9fd348-6de2-4a01-9e9b-2ed4e3104a81"
}

Update a call

Request

curl "https://api.somleng.org/2010-04-01/Accounts/725c9890-de09-4841-a63f-56bebc515d41/Calls/7e0010e2-398b-4d3e-89e0-d5191d712cae" -d 'Status=completed' -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 725c9890-de09-4841-a63f-56bebc515d41:YU9cIWZSCu0tuRJw-U1ZazpoTE5bu-zCTG8Cmc3VzjE

Endpoint

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

POST https://api.somleng.org/2010-04-01/Accounts/725c9890-de09-4841-a63f-56bebc515d41/Calls/7e0010e2-398b-4d3e-89e0-d5191d712cae

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": "7e0010e2-398b-4d3e-89e0-d5191d712cae",
  "account_sid": "725c9890-de09-4841-a63f-56bebc515d41",
  "date_created": "Fri, 17 Sep 2021 01:34:37 -0000",
  "date_updated": "Fri, 17 Sep 2021 01:34:37 -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/725c9890-de09-4841-a63f-56bebc515d41/Calls/7e0010e2-398b-4d3e-89e0-d5191d712cae"
}