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);
?>
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",
    "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"
    },
    ...
    
}

Headers

X-Toky-Key
string
required
 
Suggest Edits

/cdrs by date

Retrieve the call history taking a date range as parameter

 
gethttps://api.toky.co/v1/cdrs
curl -G https://api.toky.co/v1/cdrs --data-urlencode "filter=(created_at >= 2017-06-01)" -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",
"results": [
  {
    "id": "12903",
    "callid": "3482582a-dc6e-1235-798c-0401336adf01",
    "from": "+5530483303",
    "to_number": null,
    "country": "US",
    "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"
    },
    ...
    
}

Path Params

filter
string
required

Headers

X-Toky-Key
string
required
 
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

 
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"
    }
  ]
}

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. Only if the recording is enabled 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

"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"
}]

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.

"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"
}]

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", "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", "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.

Headers

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

/sms

List Text Messages

 
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"
    },....
  
}