NAV Navigation
Javascript PHP

SnapCall Rest API

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

SnapCall's Rest API allows you to interact automatically with your SnapCall data on demand. With simple scripts, you can build your own analytics by retrieving calls informations and manage your SnapCall buttons list.

API key Authentication

Signing requests

API key authentication requires each request to be signed (enhanced security measure). You can create and activate new API keys in your account settings.

Making a request

All REST requests must contain the following header:

This field is constructed as follows :

  1. The username (SnapCall apiKey) and password (SnapCall apiSecret) are combined with a single colon :.
  2. The resulting string is encoded using a variant of Base64.
  3. The authorization method and a space (e.g. "Basic ") is then prepended to the encoded string.

All request bodies should have content type application/json and be valid JSON.

Buttons

Read all

[GET] /v2/buttons

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/buttons', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read all buttons

Query String

Parameter Type Required
page number false
limit number false
name string false
agent string false

Read

[GET] /v2/buttons/{bid}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/buttons/bid', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons/bid');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read a button

URI Components

Parameter Type Required
bid alternatives true

Info

[GET] /v2/buttons/{bid}/info

Code samples

fetch('https://api.snapcall.io/v2/buttons/bid/info')
  .then(res => res.json())
  .then(console.log);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons/bid/info');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);



$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Retrieve information about a specific button

URI Components

Parameter Type Required
bid alternatives true

Create

[POST] /v2/buttons

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    name,
    brand,
    call_id,
    schedule_template_id,
    timezone,
    caller_id,
    config,
    display_page,
    cart_value,
    active,
  }),
};

fetch('https://api.snapcall.io/v2/buttons', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, [
  'name' => string,
  'brand' => string,
  'call_id' => alternatives,
  'schedule_template_id' => number,
  'timezone' => string,
  'caller_id' => alternatives,
  'config' => object,
  'display_page' => string,
  'cart_value' => number,
  'active' => boolean,
]);
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Create a button

JSON Payload

Parameter Type Required
name string true
brand string false
call_id alternatives true
schedule_template_id number false
timezone string false
caller_id alternatives false
config object false
display_page string false
cart_value number false
active boolean false

Create batch

[POST] /v2/buttons/batch

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    buttons,
  }),
};

fetch('https://api.snapcall.io/v2/buttons/batch', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons/batch');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, [
  'buttons' => array,
]);
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Create multiple buttons

JSON Payload

Parameter Type Required
buttons array true

Update batch

[PUT] /v2/buttons/batch

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    buttons,
  }),
};

fetch('https://api.snapcall.io/v2/buttons/batch', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons/batch');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'buttons' => array,
]));
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Update multiple buttons

JSON Payload

Parameter Type Required
buttons array true

Update

[PUT] /v2/buttons/{bid}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    name,
    brand,
    call_id,
    schedule_template_id,
    timezone,
    caller_id,
    config,
    display_page,
    cart_value,
    active,
  }),
};

fetch('https://api.snapcall.io/v2/buttons/bid', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/buttons/bid');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'name' => string,
  'brand' => string,
  'call_id' => alternatives,
  'schedule_template_id' => number,
  'timezone' => string,
  'caller_id' => alternatives,
  'config' => object,
  'display_page' => string,
  'cart_value' => number,
  'active' => boolean,
]));
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Update a button

URI Components

Parameter Type Required
bid alternatives true

JSON Payload

Parameter Type Required
name string false
brand string false
call_id alternatives false
schedule_template_id number false
timezone string false
caller_id alternatives false
config object false
display_page string false
cart_value number false
active boolean false

Calls

ReadAll

[GET] /v2/calls

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/calls', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/calls');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read all calls

Query String

Parameter Type Required
page number false
limit number false
rate alternatives false
start date false
end date false
button alternatives false
status alternatives false
agent alternatives false
client alternatives false
ani number false
exporting boolean false

Read

[GET] /v2/calls/{id}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/calls/123', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/calls/123');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read a call, given an ID

URI Components

Parameter Type Required
id number true

Schedule-templates

Read all

[GET] /v2/schedule-templates

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/schedule-templates', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/schedule-templates');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read all schedule template

Query String

Parameter Type Required
page number false

Read

[GET] /v2/schedule-templates/{id}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/schedule-templates/123', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/schedule-templates/123');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read a schedule template

URI Components

Parameter Type Required
id number true

Create

[POST] /v2/schedule-templates

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    name,
    schedule,
  }),
};

fetch('https://api.snapcall.io/v2/schedule-templates', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/schedule-templates');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, [
  'name' => string,
  'schedule' => array,
]);
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Create a schedule template

JSON Payload

Parameter Type Required
name string true
schedule array true

Update

[PUT] /v2/schedule-templates/{id}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    name,
    schedule,
  }),
};

fetch('https://api.snapcall.io/v2/schedule-templates/123', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/schedule-templates/123');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'name' => string,
  'schedule' => array,
]));
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Update a schedule template

URI Components

Parameter Type Required
id number true

JSON Payload

Parameter Type Required
name string false
schedule array false

Agents

Read

[GET] /v2/agents/{email}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/agents/hello', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/agents/hello');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read an agent

URI Components

Parameter Type Required
email string true

Update

[PUT] /v2/agents/{email}

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    wrap_up_time,
    last_bridge_end,
  }),
};

fetch('https://api.snapcall.io/v2/agents/hello', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/agents/hello');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'wrap_up_time' => number,
  'last_bridge_end' => number,
]));
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Update an agent

URI Components

Parameter Type Required
email string true

JSON Payload

Parameter Type Required
wrap_up_time number false
last_bridge_end number false

Status

[PUT] /v2/agents/{email}/status

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${auth}`,
  },
  body: JSON.stringify({
    status,
  }),
};

fetch('https://api.snapcall.io/v2/agents/hello/status', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/agents/hello/status');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'status' => string,
]));
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Update the status of an agent, status can be "online" or "onbreak"

URI Components

Parameter Type Required
email string true

JSON Payload

Parameter Type Required
status string true

Users

Me

[GET] /v2/users/me

Code samples

const apiKey = 'abc';
const apiSecret = '123';
const auth = window.btoa(`${apiKey}:${apiSecret}`);

const options = {
  headers: {
    Authorization: `Basic ${auth}`,
  },
};

fetch('https://api.snapcall.io/v2/users/me', options)
  .then(res => res.json())
  .then(console.log);
$api_key = 'abc';
$api_secret = '123';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/users/me');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
  'Authorization: Basic '.base64_encode($api_key.':'.$api_secret),
]);


$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Read the authenticated user

Button

[POST] /v2/users/{id}/button

Code samples

const options = {
  method: 'POST',
  body: JSON.stringify({
    referer,
    cart_value,
  }),
};

fetch('https://api.snapcall.io/v2/users/123/button', options)
  .then(res => res.json())
  .then(console.log);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.snapcall.io/v2/users/123/button');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, [
  'referer' => string,
  'cart_value' => number,
]);
$response = curl_exec($curl);
curl_close($curl);

var_dump($response);

Return a button passing every display filters

URI Components

Parameter Type Required
id number true

JSON Payload

Parameter Type Required
referer string true
cart_value number false