Voice API
  • 10 Jan 2023
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Voice API

  • Dark
    Light
  • PDF

Article Summary

Generating a new Call

To create a new call we have to send a POST request to the /channels/voice endpoint.

The security mechanism for the Voice API is BASIC AUTH and tenants the request to a specific Account. You can obtain the credentials using the following fields under Account=>Settings in the console. ID being the Username and Client ID being the password. Please be aware that this may change in the future when the ability to create and revoke API credentials becomes available.

Be Warned!

Using BASIC AUTH is vunerable to MoM attacks when using insecure http as the user/pass is sent in clear text. ALWAYS use https when calling our APIs

image.png

An example of simple status update:

{
	"callerId": "+441234567890",
	"target": {
		"phoneNumber": {
			"number": "+447777777777"
		},
		"timeout": 15
	},
	"verbs": [
		{
			"say": {
				"text": [
					"Your pizza is ready!"
				],
				"voice": "en-GB-Standard-A",
				"loop": "1"
			}
		}
	]
}

This can be simplified further by using the account defaults:

{
	"target": {
		"phoneNumber": {
			"number": "+447777777777"
		}
	},
	"verbs": [
		{
			"say": {
				"text": [
					"Your pizza is ready!"
				]
			}
		}
	]
}

Advanced example

Here is an example payload for click to dial. The following will create an outbound call to extension 201, then on connect, will carry out the verb instructions, in this case it will announce that its "connecting you now" and then dial a phone number.

POST https://eu-west-2-api.control.callable.io/channels/voice
Authorization: Basic {{username}} {{password}}
Content-Type: application/json

{
	"callerId": "+441234567890",
	"target": {
		"extension": {
			"extension": "201"
		},
		"timeout": 15
	},
	"verbs": [
		{
			"say": {
				"text": [
					"Connecting you now"
				],
				"voice": "en-GB-Standard-A",
				"loop": "1"
			}
		},
		{
			"dial": {
				"callerId": "+441234567890",
				"timeLimit": 14400,
				"timeout": 180,
				"targets": [
					{
						"phoneNumber": {
							"number": "+447777777777"
						}
					}
				]
			}
		}
	]
}

For the above to work, you will need a SIP Extension built in the console which points to a valid SIP Gateway

image.png