Toky API

The Toky Developer Hub

Welcome to the Toky developer hub. You'll find comprehensive guides and documentation to help you start working with Toky as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    
Suggest Edits

/agents

Retrieve all agents from a Toky Account

 
gethttps://api.toky.co/v1/agents
curl -G https://api.toky.co/v1/agents -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/agents");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 11,
"next": null,
"results": [
  {
  "email": "agent@mail.com",
  "fullname": "Angent Name",
  "created_at": "2017-06-27 19:24:10",
  "last_update": "2017-06-27 19:26:52",
  "last_connection": null,
  "is_admin": "false",
  "phone_number": "+15553456789",
  "phone_country": "ES"
  },
	...
}

Headers

X-Toky-Key
string
required
 
Suggest Edits

/cdrs

Retrieve the call history

 
gethttps://api.toky.co/v1/cdrs
curl -G https://api.toky.co/v1/cdrs -H "X-Toky-Key: {api_key}"
<?php
		//example with one date filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/cdrs");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "CDRs as Array:"; var_export($decoded);
?>
curl -G https://api.toky.co/v1/cdrs -H "X-Toky-Key: {api_key}" -data-urlencode "offset=0 limit=20 order=ASC"
<?php
		//example
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    $path_params=url_enconde("offset=0 limit=20 order=DESC")
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/cdrs?".$path_params);
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "CDRs as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 20,
"next": "https://api.toky.co/v1/cdrs?offset=20&limit=20",
"results": [
  {
    "id": "12903",
    "callid": "3482582a-dc6e-1235-798c-0401336adf01",
    "from": "+551234567",
    "to_number": null,
    "country": "US",
    "caller_id_used": "+12018155555",
    "init_dt": "2017-07-05 21:46:44",
    "start_time": "2017-07-05 21:46:22",
    "end_time": "2017-07-05 21:46:44",
    "duration": "22",
    "agent_id": "carlos__myagent.com",
    "direction": "inbound",
    "web_call": "no"
    },
    ...
    
}

Path Params

offset
int32
required

The offset of the CDR to request, starts with 0.

limit
int32
required

The maximum limit of CDR rows that will come from the request Max value 500.

order
string
required

The order of the returned data, order by init_dt. DESC: descendent, ASC: ascendent.

Headers

X-Toky-Key
string
required
 
Suggest Edits

/cdrs by date

Retrieve the call history taking a date range as parameter. NOTE: The "try it" button for this endpoint won't work as expected because of enconding problems with readme.io. Please use the curl example in your machine to test it.

 
gethttps://api.toky.co/v1/cdrs?filter=filter
curl -G https://api.toky.co/v1/cdrs --data-urlencode "filter=created_at >= 2017-06-02" -H "X-Toky-Key: {api_key}"
curl -G https://api.toky.co/v1/cdrs --data-urlencode "filter=(created_at >= 2017-06-01) AND (created_at <= 2017-06-02)" -H "X-Toky-Key: {api_key}"

<?php
		//example with one date filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    //filter format created_at >= 2017-06-01
 		$filter_enc = urlencode("created_at >= 2017-06-01");
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/cdrs?filter=$filter_enc");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
<?php
		//example with two dates filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    //filter format (created_at >= 2017-06-01) AND (created_at <= 2017-06-02)
 		$filter_enc = urlencode("(created_at >= 2017-06-01) AND (created_at <= 2017-06-02)");
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/cdrs?filter=$filter_enc");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 20,
"next": "https://api.toky.co/v1/cdrs?offset=20&limit=20&order=DESC&filter=%28created_at+%3E%3D+2017-06-01%29+AND+%28created_at+%3C%3D+2017-06-02%29",
"results": [
  {
    "id": "12903",
    "callid": "3482582a-dc6e-1235-798c-0401336adf01",
    "from": "+5530483303",
    "to_number": null,
    "country": "US",
    "caller_id_used": "+12018155555",
    "init_dt": "2017-07-05 21:46:44",
    "start_time": "2017-07-05 21:46:22",
    "end_time": "2017-07-05 21:46:44",
    "duration": "22",
    "agent_id": "carlos__myagent.com",
    "direction": "inbound",
    "web_call": "no"
    },
    ...
    
}

Path Params

filter
string
required

Date or Dates range to query for CDR.

limit
int32
required

The maximum limit of CDR rows that will come from the request Max value 500.

order
string
required

The order of the returned data, order by init_dt. DESC: descendent, ASC: ascendent.

offset
int32
required

The offset of the CDR to request, starts with 0.

Headers

X-Toky-Key
string
required
 
Result field
Description

id

ID of the CDR

callid

unique identifier of the CDR

from

inbound number, agent id or web caller id

to_number

outbound number called, for outbound calls

country

For inbound call: 1) country from inbound number or 2) for web caller, the country detected of the caller.
For outbound call: country location of the agent making the outbound call.

caller_id_used

For outbound call, this is the PSTN number caller ID used to make the call.
For web to web call, this value is null.

init_dt

Creation of the call transaction.

start_time

Start time of the call.

end_time

End time of the call.

duration

Duration of the call.

agent_id

For inbound: the agent that received the call.
For outbound: the agent that makes the call.

direction

If the call is inbound or outbound.

web_call

If the call is web only. E.g.: A call from agent A to agent B. No pstn call involved.

Suggest Edits

/contacts

Retrieve all contacts from the phone directory

 
gethttps://api.toky.co/v1/contacts
curl -G https://api.toky.co/v1/contacts -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/contacts/");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 20,
"next": "https://api.toky.co/v1/contacts?offset=20&limit=20",
"results": [
  {
  "id": "7103",
  "contact_name": "My contact name",
  "phone": "+15513804333",
  "country_code": "US",
  "city": "Miami",
  "email": "client@company.com",
  "company_name": "The Company"
  },
...
}

Headers

X-Toky-Key
string
required
 
Suggest Edits

/contacts by date

Retrieve contacts from the Phone Directory taking a date range as parameter. The "try it" button for this endpoint won't work as expected because of enconding problems with readme.io. Please use the curl example in your machine to test it.

 
gethttps://api.toky.co/v1/contacts
curl -G https://api.toky.co/v1/contacts --data-urlencode "filter=created_at >= 2017-06-01" -H "X-Toky-Key: {api_key}"
curl -G https://api.toky.co/v1/contacts --data-urlencode "filter=(created_at >= 2017-06-01) AND (created_at <= 2017-06-02)" -H "X-Toky-Key: {api_key}"

<?php
		//example with one date filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    //filter format created_at >= 2017-06-01
 		$filter_enc = urlencode("created_at >= 2017-06-01");
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/contacts?filter=$filter_enc");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
<?php
		//example with two dates filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    //filter format (created_at >= 2017-06-01) AND (created_at <= 2017-06-02)
 		$filter_enc = urlencode("(created_at >= 2017-06-01) AND (created_at <= 2017-06-02)");
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/contacts?filter=$filter_enc");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 26,
"next": null,
"results": [
    {
    "id": "7103",
    "contact_name": "My company",
    "phone": "+15513804333",
    "country_code": "US",
    "city": "Miami",
    "email": "client@company.com",
    "company_name": "The Company"
	},
  ...
}

Path Params

filter
string
required

Headers

X-Toky-Key
string
required
 
Suggest Edits

/contacts/:number

Search a contact by phone number

 
gethttps://api.toky.co/v1/contacts/number
curl -G https://api.toky.co/v1/contacts/150412345678 -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/contacts/150412345678");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"results": [
    {
    "type": "phone_directory",
    "name": "john doe",
    "email": "company@mail.com",
    "phone": "+150412345678",
    "id": "9148",
    "company": "the company"
    }
  ]
}

Path Params

number
string
required

Number of the contact to get.

Headers

X-Toky-Key
string
 
Suggest Edits

/contacts

Create a new contact in the Phone Directory

 
posthttps://api.toky.co/v1/contacts
curl -d '{"phone":"+19165814898", "created_by": "agent@your-company.com", "last_name": " doe", "first_name":"john", "email":"contact@company.com"}' -H "Content-Type: application/json" -H "X-Toky-Key: {api_key}" -X POST https://api.toky.co/v1/contacts
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";

		$data = array("number" => "+19165814898", 
              "created_by"=> "agent@your-company.com",
              "first_name" => "john",
              "last_name" => "doe",  
              "email" => "contact@company.com");

		$json_data = json_encode($data);   
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/contacts/");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch,CURLOPT_POSTFIELDS, $json_data);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"id": "9147",
"contact_name": "john doe",
"phone": "+19165813333",
"country_code": null,
"city": null,
"email": "contact@company.com",
"company_name": null
}

Body Params

phone
string
required
created_by
string
required
last_name
string
required
first_name
string
required
email
string
required

Headers

X-Toky-Key
string
required
 
Suggest Edits

/contacts/:id

Update a contact by its ID

 
puthttps://api.toky.co/v1/contacts/id
curl -d '{"phone":"+19165814898", "first_name":"john", "last_name": "maxwell", "email":"contact2@company.com"}' -H "Content-Type: application/json" -H "X-Toky-Key: {api_key}" -X PUT https://api.toky.co/v1/contacts/123
A binary file was returned

You couldn't be authenticated

{
"id": "123",
"contact_name": "john maxwell",
"phone": "+19165814833",
"email": "contact2@company.com",
"company_name": "the company name"
}

Body Params

first_name
string
last_name
string
phone
string
email
string
company_name
string
 
Suggest Edits

/contacts/number/:number

Update a contact by phone number

 
puthttps://api.toky.co/v1/contacts/number/number
curl -d '{"phone":"+19165814898", "first_name":"john", "last_name": "maxwell", "email":"contact2@company.com"}' -H "Content-Type: application/json" -H "X-Toky-Key: {api_key}" -X PUT https://api.toky.co/v1/contacts/123
A binary file was returned

You couldn't be authenticated

{
"id": "123",
"contact_name": "john maxwell",
"phone": "+19165814833",
"email": "contact2@company.com",
"company_name": "the company name"
}

Body Params

first_name
string
last_name
string
phone
string
email
string
company_name
string
 
Suggest Edits

/webhooks

List all the webhooks

 
gethttps://api.toky.co/v1/webhooks
curl -G https://api.toky.co/v1/webhooks -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/webhooks/");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 2,
"next": null,
"results": [
  {
  "id": "11",
  "created_at": "2017-06-27 19:24:10",
  "event": "new_call",
  "hook_url": "https://your.hook.url/for_toky_events"
  },
	...
}

Headers

X-Toky-Key
string
required
 
Suggest Edits

/webhooks

Create a new webhook

 
posthttps://api.toky.co/v1/webhooks
curl -d '{"hook_url": "https://your.webhook.url/events", "event": "new_call"}' -H "Content-Type: application/json" -H "X-Toky-Key: {api_key}" -X POST https://api.toky.co/v1/webhooks
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
  //{"hook_url": "https://your.webhook.url/events", "event": "new_call"}
		$data = array("hook_url" => "https://your.webhook.url/events", 
                   "event": "new_call");

		$json_data = json_encode($data);   
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/webhooks");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch,CURLOPT_POSTFIELDS, $json_data);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Response:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
  "id": "12",
  "created_at": "2017-06-27 19:24:10",
  "event": "new_call",
  "hook_url": "https://your.hook.url/for_toky_events"
}

Body Params

hook_url
string
required

The url that you want to register to receive Toky events

event
string
required

The type of event you want to register to receive notifications. Values = (new_call | new_voicemail | new_sms)

Headers

X-Toky-Key
string
required
Content-Type
string
 

Types of events supported: "new_call", "new_voicemail", "new_sms"

Event new_call sent data description

Name
Description

direction

Direction of the call [inbound, outbound].

web_call

If the call was web or no [yes, no].

agent

The email address of the agent registered in Toky.

duration

Duration of the call in seconds.

state

State of the call [completed, unsuccessful, missed].

  • completed -> inbound/outbound successfully connected.
  • unsuccessful -> outbound call not connected.
  • missed-> inbound call not answered.

from_number

Inbound, the caller id of the incoming call. Outbound: the Toky number you made the call from.

to_number

Inbound, the Toky number where the call was received. Outbound, the number the agent dialed.

date

The date and time the call was made.

record_url

Contains the url of the recording of the call in Toky web. This field will be empty if the recording of calls is disabled in Toky.

record_url_raw

Contains the url to the recording of the call file. You can use this url if you want to access the file directly. This field will be empty if the recording of calls is disabled in Toky.

caller_name

The name of the caller when using the Toky widget. This value comes from a form in Toky widget, not all calls contains this data.

caller_email

The email of the caller when using the Toky widget. This value comes from a form in Toky widget, not all calls contains this data.

caller_country

The country of the caller when using the Toky widget. This value comes from a form in Toky widget, not all calls contains this data.

caller_phone_number

The phone number of the caller when using the Toky widget. This value comes from a form in Toky widget, not all calls contains this data.

contact_name

The name of the contact in Toky Phonebook

contact_email

The email of the contact in Toky Phonebook

contact_id

The id of the contact in Toky Phonebook

ivr_option_pressed

Contains the IVR option pressed by the caller

reply_code

Possibles values:
200 -> OK
400-499 -> Client error
500-699 -> Server Error

error_message

Error message values:

'486' => 'Busy',
'487' => 'Cancelled',
'402' => 'Payment Required',
'404' => 'Not Found',
'408' => 'Request Timeout',
'480' => 'Temporarily Unavailable',
'500 - 699' => 'Connection Error',
'default' => '' (empty)

answered_time

Time between incoming call and answered call in seconds.

"new_call" event json example
[{
"direction":"inbound",
"web_call":"no",
"agent":"your.toky@agent",
"duration":0,
"state":"missed",
"from_number":"+13013372465",
"to_number":"+12018442465",
"date":"2017-08-21T16:02:21-05:00",
"record_url":"",
"caller_name":"",
"caller_email":"",
"caller_country":"",
"caller_phone_number":"",
"contact_name" : "john doe office",
"contact_email" : "john@email.com",
"contact_id": 12
"ivr_option_pressed": 1,
'reply_code' : '487',
"error_message' : "Cancelled",
"answered_time": 0
}]

Event new_voicemail sent data description

Name
Description

status

The status of the voicemail (abandoned | completed).

web_call

If the voicemail was generated from a web call (yes | no).

date

The date the voicemail was created.

from

The caller id of the voicemail. Could be a number or an email address.

to_number

The toky number that received the voicemail.

duration

Duration in seconds of the voicemail.

record_url

The record url of a completed voicemail.

ivr_option_pressed

Contains the IVR option pressed by the caller

"new_voicemail" event json format example
[{
"status":"completed",
"web_call":"yes",
"date":"2017-08-21T09:00:22-04:00",
"from":"caller-email@mail.com",
"to_number": "+123455667",
"duration":"46",
"record_url":"https:\/\/app.toky.co\/business\/voicemail\/xxx-yyyy-zzzz",
"ivr_option_pressed": 1
}]

Event new_sms sent data description

Name
Description

to_number

The number you sent or received the SMS. Depends if inbound or outbound.

from_number

The number you sent or received the SMS. Depends if inbound or outbound.

direction

The direction of the SMS (inbound | outbound).

date

The date the SMS was received or sent.

body

The text of the SMS.

"new_sms" event json format example
[{
"to_number":"+59598123456",
"from_number":"+16282333444",
"direction":"outbound",
"date":"2017-07-25T10:58:42-04:00",
"body":"test text message"
}]

Suggest Edits

/webhooks

Delete a webhook by ID

 
deletehttps://api.toky.co/v1/webhooks/id
curl -X DELETE https://api.toky.co/v1/webhooks/{id} -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 		$id = 3;
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/webhooks/{$id}");
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Contacts as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"id": "3",
"created_at": "2017-07-11 19:24:33",
"hook_url": "https://your.webhook.url/events",
"event": "new_call",
"status": "deleted"
}

Path Params

id
string
required

ID of the webhook to delete

Headers

X-Toky-Key
string
required
 
Suggest Edits

/sms/numbers

List all SMS-enabled numbers

 
gethttps://api.toky.co/v1/sms/numbers
curl -G https://api.toky.co/v1/sms/numbers -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/sms/numbers");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Numbers:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

[
 {"id":"+12018172222","description":"NJ's Office"},  			 {"id":"+19165814111","description":"SF Office"}
]

Headers

X-Toky-Key
string
required
 
Suggest Edits

/sms/send

Send a Text Message

 
posthttps://api.toky.co/v1/sms/send
curl -d '{"from":"+16282275444", "email": "your-agent@company.com", "to": "+16282275222", "text": "Hello from Toky"}' -H "Content-Type: application/json" -X POST https://api.toky.co/v1/sms/send
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
  //{"from":"+16282275444", "to": "+16282275222", "text": "Hello from Toky"}
		$data = array("from" => "+16282275444", "email" => "your-agent@company.com",
                   "to" => "+16282275222", 
                   "text" => "Hello from Toky");

		$json_data = json_encode($data);   
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/sms/send");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch,CURLOPT_POSTFIELDS, $json_data);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "Response:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
  "success" : "true"
}

Body Params

from
string
required

The Toky number that will send the SMS. Must be an SMS enabled number.

to
string
required

The number you want to send SMS.

text
string
required

The text of the SMS.

email
string

The email of the Toky agent sending the sms.

Headers

X-Toky-Key
string
Content-Type
string
 
Suggest Edits

/sms

List Text Messages history, sent and received. The result is ordered by descending date.

 
gethttps://api.toky.co/v1/sms
curl -G https://api.toky.co/v1/sms -H "X-Toky-Key: {api_key}"
<?php
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
 
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/sms");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "SMS List:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 20,
"next": "https://api.toky.co/v1/sms?offset=20&limit=20",
"results": [
      {
    "date": "2017-07-25 21:58:21",
    "from": "+12018172555",
    "to": "+595981222333",
    "text": "hello",
    "direction": "outbound"
    },
      {
    "date": "2017-07-25 21:53:56",
    "from": "+12018172555",
    "to": "+5959811222333",
    "text": "Hi!",
    "direction": "inbound"
    },....
  
}

Path Params

limit
string
required

The maximum limit of SMS rows that will come from the request Max value 500.

offset
string
required

The offset of the SMS to request, starts with 0.

Headers

X-Toky-Key
string

Toky API key

 
Suggest Edits

/sms by date

List Text Messages history, sent and received filtered by date. The result is ordered by descending date.

 
gethttps://api.toky.co/v1/sms
curl -G https://api.toky.co/v1/sms --data-urlencode "filter=created_at >= 2018-10-02" -H "X-Toky-Key: {api_key}"
<?php
		//example with one date filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    //filter format created_at >= 2017-06-01
 		$filter_enc = urlencode("created_at >= 2017-06-01");
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/sms?filter=$filter_enc");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "SMS as Array:"; var_export($decoded);
?>
curl -G https://api.toky.co/v1/sms --data-urlencode "filter=(created_at >= 2017-10-01) AND (created_at <= 2017-10-02)" -H "X-Toky-Key: {api_key}"
<?php
		//example with two dates filter
    // create a new cURL resource
    $ch = curl_init();
		$api_key = 'insert_you_api_key';
    $headers = array();
    $headers[] = "X-Toky-Key: {$api_key}";
    //filter format (created_at >= 2017-06-01) AND (created_at <= 2017-06-02)
 		$filter_enc = urlencode("(created_at >= 2017-06-01) AND (created_at <= 2017-06-02)");
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/sms?filter=$filter_enc");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    
    $curl_response = curl_exec($ch); // Send request
  	curl_close($ch); // close cURL resource 
    
		$decoded = json_decode($curl_response,true);
    print "SMS as Array:"; var_export($decoded);
?>
A binary file was returned

You couldn't be authenticated

{
"count": 20,
"next": "https://api.toky.co/v1/sms?offset=20&limit=20&filter=created_at+%3E%3D+2017-10-10",
"results": [
      {
    "date": "2017-10-01 21:58:21",
    "from": "+12018172555",
    "to": "+595981222333",
    "text": "hello",
    "direction": "outbound"
    },
      {
    "date": "2017-10-01 21:53:56",
    "from": "+12018172555",
    "to": "+5959811222333",
    "text": "Hi!",
    "direction": "inbound"
    },....
  
}

Path Params

limit
string
required

The maximum limit of SMS rows that will come from the request Max value 500.

offset
string
required

The offset of the SMS to request, starts with 0.

filter
string
required

Date or Dates range to query for SMS.

Headers

X-Toky-Key
string

Toky API key

 
Suggest Edits

/voicemails

List Voicemail history. The result is ordered by descending created date.

 
gethttps://api.toky.co/v1/voicemails
curl -G https://api.toky.co/v1/voicemails -H "X-Toky-Key: {api_key}"
A binary file was returned

You couldn't be authenticated

{
  "count": 20,
  "next": "https://api.toky.co/v1/voicemails?offset=20&limit=20",
  "results": [
    {
  "id": "e97e1084-2c0b-11e8-a2de-65b3c0049491",
  "created_at": "2017-03-20 06:57:44",
  "from": "+19725456944444",
  "duration": "18"
  },
    {
  "id": "ac78f30e-2b96-11e8-a459-5f65810cf8cb",
  "created_at": "2017-03-19 16:58:17",
  "from": "+197254666666",
  "duration": "5"
	}, ...
  
}

Path Params

limit
string
required

The maximum limit of Voicemail rows that will come from the request Max value 500.

offset
string
required

The offset of the Voicemail to request, starts with 0.

Headers

X-Toky-Key
string

The Toky API Key.

 
Suggest Edits

/voicemails/recordings/:id

Retrieve voicemail recording URL with ID of the voicemail.

 
gethttps://api.toky.co/v1/voicemails/recordings/id
curl -G https://api.toky.co/v1/voicemails/recordings/97e1084-2c0b-11e8-a2de-65b3c0049491 -H "X-Toky-Key: {api_key}"
A binary file was returned

You couldn't be authenticated

{
"id": "1ebf1654-229c-11e8-85a6-7999000253c2",
"record_url": "https://tokystorage.s3.amazonaws.com/voicemail/445b6949ed886dfbgf175e8c89464ba85/1ebf1654-229c-11e8-85a6-795464600253c2",
"duration": "4"
}
  

Path Params

id
string
required

The id of the voicemail.

Headers

X-Toky-Key
string

The Toky API Key.