NAV
cURL

Introduction

Somleng Twilreapi is 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.

Make an HTTP Request to Somleng Twilreapi

There are a lot of ways you can make an HTTP request to Somleng Twilreapi. 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 Twilreapi by overriding the URL parameter from api.twilio.com to twilreapi.somleng.org or your own host.

OpenAPI Specification

You can download the OpenAPI specification and import it into your favourite HTTP Client such as Postman.

Credentials

All requests to Somleng Twilreapi need to be authenticated. Twilreapi 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://twilreapi.somleng.org/2010-04-01/Accounts/f7b694dd-af2f-45fe-9a9d-27f110b07952/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 f7b694dd-af2f-45fe-9a9d-27f110b07952:1klpe4W4wMBd9mYq8XPGNJrY_rRmdedceEm_UnJMJZs

Endpoint

POST /2010-04-01/Accounts/:account_sid/Calls

POST /2010-04-01/Accounts/f7b694dd-af2f-45fe-9a9d-27f110b07952/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": "ebfbd903-eccd-4e64-94e2-211afa7a802d",
  "account_sid": "f7b694dd-af2f-45fe-9a9d-27f110b07952",
  "date_created": "Wed, 21 Jul 2021 10:30:29 -0000",
  "date_updated": "Wed, 21 Jul 2021 10:30:29 -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://twilreapi.somleng.org/2010-04-01/Accounts/f7b694dd-af2f-45fe-9a9d-27f110b07952/Calls/ebfbd903-eccd-4e64-94e2-211afa7a802d"
}

Fetch a call

Request

curl -g "https://twilreapi.somleng.org/2010-04-01/Accounts/5cff35da-c62b-485d-b5da-31e0aa987220/Calls/8ae0c233-97aa-4994-8861-df89428d5b36" -X GET \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 5cff35da-c62b-485d-b5da-31e0aa987220:KH5A8Eh3rRpF0kQf1iD2Q8fucXzO65zRE32pRSmqdGk

Endpoint

GET /2010-04-01/Accounts/:account_sid/Calls/:sid

GET /2010-04-01/Accounts/5cff35da-c62b-485d-b5da-31e0aa987220/Calls/8ae0c233-97aa-4994-8861-df89428d5b36

Parameters

None known.

Response


200 OK
{
  "api_version": "2010-04-01",
  "sid": "8ae0c233-97aa-4994-8861-df89428d5b36",
  "account_sid": "5cff35da-c62b-485d-b5da-31e0aa987220",
  "date_created": "Wed, 21 Jul 2021 10:30:29 -0000",
  "date_updated": "Wed, 21 Jul 2021 10:30:29 -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://twilreapi.somleng.org/2010-04-01/Accounts/5cff35da-c62b-485d-b5da-31e0aa987220/Calls/8ae0c233-97aa-4994-8861-df89428d5b36"
}

Update a call

Request

curl "https://twilreapi.somleng.org/2010-04-01/Accounts/9d79b306-01a8-4288-ace4-6a5b2de767b3/Calls/a7583a9f-33dc-4060-b30e-0347b375984e" -d 'Status=completed' -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u 9d79b306-01a8-4288-ace4-6a5b2de767b3:WJdC6WwbRukg4Hve4PRTAPSY6IqFNhd3Rus36okdgXo

Endpoint

POST /2010-04-01/Accounts/:account_sid/Calls/:sid

POST /2010-04-01/Accounts/9d79b306-01a8-4288-ace4-6a5b2de767b3/Calls/a7583a9f-33dc-4060-b30e-0347b375984e

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": "a7583a9f-33dc-4060-b30e-0347b375984e",
  "account_sid": "9d79b306-01a8-4288-ace4-6a5b2de767b3",
  "date_created": "Wed, 21 Jul 2021 10:30:29 -0000",
  "date_updated": "Wed, 21 Jul 2021 10:30:29 -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://twilreapi.somleng.org/2010-04-01/Accounts/9d79b306-01a8-4288-ace4-6a5b2de767b3/Calls/a7583a9f-33dc-4060-b30e-0347b375984e"
}