The new version of the API integration of Tracksale was created with the purpose of that information had to be certified to be accessed.
Among the differences between version 1.0 and 2.0:
- Now a TOKEN is generated through our platform, or a request.
In this way, we automate the whole process and also homologate access to information.
- The API 2.0 includes the 1.0 version of the functions of live and RESTful API into a single API with various methods.
- The new API works with RESTful model with JSON.
In this documentation you will also find examples of codes in the language of your choice, which can be changed at any time on the top right button.
This API uses the HTTPS protocol. Therefore, all calls must start with https://
.
Using the API requires the use of a key that we call TOKEN. It will be responsible for authenticating access to the system.
-
For this, do the login in Tracksale with an administrator account.
-
Access the menu Apps in the upper right corner next to the user name.
-
Click Install in app
"API V2".
-
Clicking on NEW TOKEN.
-
A new token will be generated.
-
A new TOKEN will be generated and added to the list. New additions do not disable previous ones.
All API communication is made from the base URL https://api.tracksale.co/v2
.
We will use TOKEN that we get in the header (without the need for conversion to base64), to authenticate access. As follows:
-
Key
Authorization
-
Value
bearer TOKEN
Where:
- Authorization is the word Authorization
- bearer is the word bearer and TOKEN is the TOKEN
acquired here.
Campaign List
To list the campaigns we will use the following configuration
-
The method used will be:
GET
-
The URL used will be:
https://api.tracksale.co/v2/campaign
This method is responsible for listing ALL the campaigns, their codes and some details, such as the questions used.
It is possible to return only a specific campaign, it is possible using
Where Campaign_code is the code from the campaign you want to get information about.
To get the code for a specific campaign, you should first list all campaigns and get the "code" attribute of the return.
Make sure to use start
and end
parameters on YYYY-MM-DD format to receive answer data like number of passives, promoters, detractors and so on.
Return exemple:
{
"name":"Customers_name",
"code" : Campaign_code,
"description" : Campaign_description,
"detractors" : Detractors_name,
"passives" : Neutrals_name,
"promoters" : Promoters_name,
"dispatches" : Dispatches_number,
"comments" : Comments,
"answers" : Answers,
"main_channel" : "Main_channel",
"create_time" : "Time_of_creation",
"questions" : [
{
"type" : "Question_type",
"title" : "Question_title",
"question" : "Question",
"secondary" : "Secondary_question"
}
]
}
It is also possible to add to query result the dispatch limitations. To do this, use the query parameter dispatch_limits
with value 1
.
If the campaign does not use this feature, the returned values will be null
.
Return example:
{
"name":"Customers_name",
"code" : Campaign_code,
"description" : Campaign_description,
"detractors" : Detractors_name,
"passives" : Neutrals_name,
"promoters" : Promoters_name,
"dispatches" : Dispatches_number,
"comments" : Comments,
"answers" : Answers,
"main_channel" : "Main_channel",
"create_time" : "Time_of_creation",
"questions" : [
{
"type" : "Question_type",
"title" : "Question_title",
"question" : "Question",
"secondary" : "Secondary_question"
}
],
"dispatch_limits": {
"daily": {
"limit": null,
"remaining": null
},
"weekly": {
"limit": null,
"remaining": null
},
"monthly": {
"limit": null,
"remaining": null
}
}
}
Code samples: Campaigns list
Type Http
GET /v2/campaign HTTP/1.1
Host: api.tracksale.co
Authorization: bearer TOKEN
Cache-Control: no-cache
Type C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/campaign");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
Type cURL
curl -X GET \
https://api.tracksale.co/v2/campaign \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache'
Type C#
var client = new RestClient("https://api.tracksale.co/v2/campaign");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
IRestResponse response = client.Execute(request);
Type Go
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/campaign"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Type Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/campaign")
.get()
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Type Java Unirest
HttpResponse<String> response = Unirest.get("https://api.tracksale.co/v2/campaign")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.asString();
Type JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/campaign",
"method": "GET",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Type JavaScript XHR
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.tracksale.co/v2/campaign");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Type NodeJS Native
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/campaign",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
Type NodeJS Request
var request = require("request");
var options = { method: 'GET',
url: 'https://api.tracksale.co/v2/campaign',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
console.log(body);
});
Type NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("GET", "https://api.tracksale.co/v2/campaign");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Type Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/campaign"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Type OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/campaign" in
let headers = Header.init ()
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Type PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/campaign');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Type PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.tracksale.co/v2/campaign');
$request->setRequestMethod('GET');
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Type PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/campaign",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Type Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("GET", "/v2/campaign", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Type Python requests
import requests
url = "https://api.tracksale.co/v2/campaign"
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
Type Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/campaign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
response = http.request(request)
puts response.read_body
Type Shell wget
wget --quiet \
--method GET \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--output-document \
- https://api.tracksale.co/v2/campaign
Type Shell Httpie
http GET https://api.tracksale.co/v2/campaign \
authorization:'bearer TOKEN' \
cache-control:no-cache
Type Shell cURL
curl --request GET \
--url https://api.tracksale.co/v2/campaign \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache'
Type Swift (NSURL)
import Foundation
let headers = [
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/campaign")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
It is possible to fetch for created widget such as the number of times it was opened, opening limits, its identifier and name.
-
The method used will be :
GET
-
The URL used will be :
https://api.tracksale.co/v2/widget/{key}
Where {key} is the key attribute that can be found when customizing a Widget.
Return exemple:
{
"id": 1,
"name": "Widget",
"views": {
"daily": 2,
"weekly": 0,
"monthly": 0,
},
"limits": {
"daily": 2,
"weekly": 0,
"monthly": 0,
"has_limit": false,
"limit_reached": "daily"
}
}
Check 90 days rule
It is possible to check if a customer is being impacted by the 90 days rule.
-
The method used will be :
POST
-
The URL used will be :
https://api.tracksale.co/v2/campaign/Campaign_code/can-impact
-
The JSON can use email, phone or an unique customer identification used by your organization:
{
"email": "Customer Email",
// or
"phone": "Customer Phone",
// or
"identification": "Customer Identification"
}
Where Campaign_code is the code from the campaign you want to get information about.
To get the code for a specific campaign, you should first list all campaigns and get the "code" attribute of the return.
Return exemple:
{
"can_impact": true
}
Survey links
It is possible to create survey links directly through the API respecting the limitation of 500 customers per request.
-
The method used will be :
POST
-
The URL used will be :
https://api.tracksale.co/v2/campaign/Campaign_code/survey-links
-
The JSON will be an array of customers as in the example below :
{
"customers": [
{
"name": "Customer Name",
"email": "Customer Email",
"phone": "Customer Phone",
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
]
}
]
}
Where Campaign_code is the code from the campaign you want to get information about.
To get the code for a specific campaign, you should first list all campaigns and get the "code" attribute of the return.
Return exemple:
{
"customers": [
{
"name": "Customer Name",
"email": "Customer Email",
"phone": "Customer Phone",
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
],
"survey_link": "https://tracksale.co/s/Survey_hash"
}
]
}
Where Survey_hash is the alphanumeric identifier for that link.
Sendings
The sendings can be performed in two different ways
Scheduled dispatch:
The existence of the variable schedule_time is optional.
So we have two options
-
Insert variable "schedule_time":
This way you can use "schedule_time" to define when that sending will be performed, being defined as a "Uinx Timestamp" format in seconds. The body will look like this
The following example shows the insertion with all variables, but there are cases where indentification, phone, and email variables can be omitted.
Ex: If the campaign is trough SMS, it is not necessary to send the email, but it can still be sent. In campaigns via email the phone variable does not need to be sent, but if necessary, it is possible to send it.
Sending both variables is indicated if you use campaign flow.
Sending identification is recommended if you want to identify the customer by the same parameter of your company / platform
Maximum limit of 500 customers per request.
{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"identification": null,
"phone": "Customers_phone",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_seconds
}
Application/json type
Do not insert the variable "schedule_time" :
This way should be used if your intention is to gather multiple sendings to a campaign,
to do them at once at a later time. In this way, a batch code will be returned batchs, this code should be used in theBatch sendings.
{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
}
Application/json type
All subsequent sedings in the same campaign will return the same sedings batch until you send that batch.
Parameters
Attributes |
Types |
Required |
Description |
name |
String |
No |
Client name |
email |
String |
Yes (for email sendings) |
Customer Email |
phone |
String |
Yes (for SMS sendings) |
Customer phone |
tags |
Array |
No |
Tag name |
finish_time |
Integer |
No |
The survey finish date, in the unix timestamp format |
tags |
Type |
Required |
Description |
name |
String |
Yes |
Tag name |
value |
String |
Yes |
Tag Value |
Return example:
Without schedule_time
{
"msg":"Customers have been successfully added!",
"dispatch_code":"Dispatch_code",
"status": {
"duplicated":Number_of_duplications,
"invalid":Number_of_invalids,
"inserted":Number_of_insertions
},
"campaign": {
"name":Campaign_name,
"cod":Campaign_code
}
}
With schedule_time
{
"msg":"Dispatch executed!",
"dispatch_code":"Dispatch_code",
"status": {
"duplicated":Number_of_duplications,
"invalid":Number_of_invalids,
"inserted":Number_of_insertions
},
"campaign": {
"name":Campaign_name,
"cod":Campaign_code
}
}
You can also return an array with customers that were not entered, either because they were duplicates or because they were invalid.
To do this, you must pass the parameter getNotInserted with the value 1. So we will return as follows.
{
"msg":"Dispatch executed!",
"dispatch_code":"Dispatch_code",
"status": {
"duplicated":Number_of_duplications,
"invalid":Number_of_invalids,
"inserted":Number_of_insertions
},
"campaign": {
"name":Campaign_name,
"cod":Campaign_code
}
"duplicated_customers": [
{
"name":"customer name",
"email":"email@email.com"
}
],
"invalid_customers": [
{
"name":"customer name",
"reason":"Invalid or empty main channel"
}
],
}
Type Http
POST /v2/campaign/campaign_code/dispatch HTTP/1.1
Host: api.tracksale
Content-Type: application/json
Authorization: bearer TOKEN
Cache-Control: no-cache
{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}
Type C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/campaign/campaign_code/dispatch");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
CURLcode ret = curl_easy_perform(hnd);
Type cURL
curl -X POST \
https://api.tracksale.co/v2/campaign/campaign_code/dispatch \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}'
Type C#
var client = new RestClient("https://api.tracksale.co/v2/campaign/campaign_code/dispatch");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Type Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/campaign/campaign_code/dispatch"
payload := strings.NewReader("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Type Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/campaign/campaign_code/dispatch")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Type Java Unirest
HttpResponse<Foundag> response = Unirest.get("https://api.tracksale.co/v2/campaign")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.asString();
Type JavaScript Jquery AJAX
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/campaign/campaign_code/dispatch")
.header("content-type", "application/json")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.body("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}")
.asString();
Type JavaScript XHR
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/campaign/campaign_code/dispatch",
"method": "POST",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
},
"data": "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Type NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/campaign/campaign_code/dispatch",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
req.end();
Type NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/campaign/campaign_code/dispatch',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN',
'content-type': 'application/json' },
body: '{\n "customers": [\n {\n "name":"Customers_name",\n "email":"Customers_email",\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n },\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ],\n "schedule_time": Timestamp_in_Seconds\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Type NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/campaign/campaign_code/dispatch");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN",
"content-type": "application/json"
});
req.send("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Type Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"application/json",
@"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/campaign/campaign_code/dispatch"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Type OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/campaign/campaign_code/dispatch" in
let headers = Header.init ()
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Type PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$request->setBody('{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Type PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}');
$request->setRequestUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Type PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/campaign/campaign_code/dispatch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Type Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/campaign/campaign_code/dispatch", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Type Python requests
import requests
url = "https://api.tracksale.co/v2/campaign/campaign_code/dispatch"
payload = "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Type Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/campaign/campaign_code/dispatch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
request.body = "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
response = http.request(request)
puts response.read_body
Type Shell wget
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--body-data '{\n "customers": [\n {\n "name":"Customers_name",\n "email":"Customers_email",\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n },\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ],\n "schedule_time": Timestamp_in_Seconds\n}' \
--output-document \
- https://api.tracksale.co/v2/campaign/campaign_code/dispatch
Type Shell Httpie
echo '{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}' | \
http POST https://api.tracksale.co/v2/campaign/campaign_code/dispatch \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Type Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/campaign/campaign_code/dispatch \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "customers": [\n {\n "name":"Customers_name",\n "email":"Customers_email",\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n },\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ],\n "schedule_time": Timestamp_in_Seconds\n}'
Type Swift (NSURL)
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/campaign/campaign_code/dispatch")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Sending batch:
This batch should be sent using the following client Email settings
The body must be filled with the time the submission should be done in seconds, in the timestamp format.
As in the example:
{
"time": Timestamp_in_seconds
}
Nome |
Type |
Required |
Description |
time |
Integer |
Yes |
Time the send will be made, in seconds in the format timestamp. Use 0 to make an instant send |
Return example:
{
"msg":"Dispatch executed!",
"customers":"Number_of_customers",
}
Code samples : Batch sendings:
Type Http
POST /v2/campaign/campaign_code/dispatch/Codigo_lote HTTP/1.1
Host: api.tracksale.co
Authorization: bearer TOKEN
Content-Type: application/json
Cache-Control: no-cache
{
"time": Timestamp_in_Seconds
}
Type C(libCurl)
curl -X POST \
https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"time": Timestamp_in_Seconds
}'
Type cURL
curl -X POST \
https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"time": Timestamp_in_Seconds
}'
Type C#
var client = new RestClient("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "bearer TOKEN");
request.AddParameter("application/json", "{\n \"time\": Timestamp_in_Seconds\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Type Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote"
payload := strings.NewReader("{\n \"time\": Timestamp_in_Seconds\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("content-type", "application/json")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Type Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"time\": Timestamp_in_Seconds\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")
.post(body)
.addHeader("authorization", "bearer TOKEN")
.addHeader("content-type", "application/json")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Type Java Unirest
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")
.header("authorization", "bearer TOKEN")
.header("content-type", "application/json")
.header("cache-control", "no-cache")
.body("{\n \"time\": Timestamp_in_Seconds\n}")
.asString();
Type JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote",
"method": "POST",
"headers": {
"authorization": "bearer TOKEN",
"content-type": "application/json",
"cache-control": "no-cache"
},
"data": "{\n \"time\": Timestamp_in_Seconds\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Type JavaScript XHR
var data = "{\n \"time\": Timestamp_in_Seconds\n}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Type NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/campaign/campaign_code/dispatch/Codigo_lote",
"headers": {
"authorization": "bearer TOKEN",
"content-type": "application/json",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"time\": Timestamp_in_Seconds\n}");
req.end();
Type NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote',
headers:
{ 'cache-control': 'no-cache',
'content-type': 'application/json',
'authorization': 'bearer TOKEN' },
body: '{\n "time": Timestamp_in_Seconds\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Type NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote");
req.headers({
"cache-control": "no-cache",
"content-type": "application/json",
"authorization": "bearer TOKEN"
});
req.send("{\n \"time\": Timestamp_in_Seconds\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Type Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"bearer TOKEN",
@"content-type": @"application/json",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"time": Timestamp_in_Seconds
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Type OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote" in
let headers = Header.init ()
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"time\": Timestamp_in_Seconds\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Type PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'authorization' => 'bearer TOKEN'
));
$request->setBody('{
"time": Timestamp_in_Seconds
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Type PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"time": Timestamp_in_Seconds
}');
$request->setRequestUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'authorization' => 'bearer TOKEN'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Type PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"time\": Timestamp_in_Seconds\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Type Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"time\": Timestamp_in_Seconds\n}"
headers = {
'authorization': "bearer TOKEN",
'content-type': "application/json",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/campaign/campaign_code/dispatch/Codigo_lote", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Type Python requests
import requests
url = "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote"
payload = "{\n \"time\": Timestamp_in_Seconds\n}"
headers = {
'authorization': "bearer TOKEN",
'content-type': "application/json",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Type Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'bearer TOKEN'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"time\": Timestamp_in_Seconds\n}"
response = http.request(request)
puts response.read_body
Type Shell wget
wget --quiet \
--method POST \
--header 'authorization: bearer TOKEN' \
--header 'content-type: application/json' \
--header 'cache-control: no-cache' \
--body-data '{\n "time": Timestamp_in_Seconds\n}' \
--output-document \
- https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote
Type Shell Httpie
echo '{
"time": Timestamp_in_Seconds
}' | \
http POST https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Type Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "time": Timestamp_in_Seconds\n}'
Type Swift (NSURL)
import Foundation
let headers = [
"authorization": "bearer TOKEN",
"content-type": "application/json",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"time": Timestamp_in_Seconds
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Insert Answers
We also provide a method of inserting responses. This method can be used with the following parameters.
- The method will be:
POST
- The URL to use should be:
https://api.tracksale.co/v2/answer
The body must be filled with the response batch using the following pattern
{
"campaign_code": "Campaign_code",
"answers":[
{
"name":"Customers_name",
"email":"Customers_email",
"score":Customer_score,
"justification":""Customers_comment"",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}
Parameters
Parameter |
Type |
Required |
Description |
campaign_code |
String |
Yes |
Target Campaign Key. Obtained by method List Campaign |
answers |
Array |
Yes |
List of answers |
answers |
Type |
Required |
Description |
name |
String |
Yes |
Costumer name |
email |
String |
Yes, if sending was done by email |
Customer Email |
phone |
String |
Yes, if sending was done by phone |
Client phone |
identification |
String |
No |
Unique customer identification used by your organization |
score |
Integer |
Yes |
Score of the customer (between 0 to 10) |
justification |
String |
No |
Customer review |
create_time |
Integer |
No |
Date/hour of the answer in timestamp format (in seconds) |
Return example:
{
"msg":"Number_of_answers Answer inserted"
"status": {
"invalid":Number_of_invalids,
"inserted":Number_of_insertions,
}
}
It is also possible to obtain an array with the customers that were inserted and the IDs of their respective answers when the request returns.
For this, you must pass the query parameter return_answer_id
with the value 1
.
So we return as follows:
{
"msg":"Number_of_answers Answer inserted"
"status": {
"invalid":Number_of_invalids,
"inserted":Number_of_insertions,
},
"answers": [
{
"answer_id": Answer_id,
"name": "Customers_name",
"email": "Customers_email",
"phone": Customers_phone,
"identification": "Customers_identification"
}
]
}
Code samples : Insert answers
Type Http
POST /v2/answer HTTP/1.1
Host: api.tracksale
Content-Type: application/json
Authorization: bearer TOKEN
Cache-Control: no-cache
{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}
Type C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/answer");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
CURLcode ret = curl_easy_perform(hnd);
Type cURL
curl -X POST \
https://api.tracksale.co/v2/answer \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}'
Type C#
var client = new RestClient("https://api.tracksale.co/v2/answer");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Type Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/answer"
payload := strings.NewReader("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Type Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/answer")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Type Java Unirest
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/answer")
.header("content-type", "application/json")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.body("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}")
.asString();
Type JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/answer",
"method": "POST",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
},
"data": "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Type JavaScript XHR
var data = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.tracksale.co/v2/answer");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Type NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/answer",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
req.end();
Type NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/answer',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN',
'content-type': 'application/json' },
body: '{\n "campaign_code": "campaign_code",\n "answers":[\n {\n "name":"customers_name",\n "email":"customers_Email",\n "score":Customer_score,\n "justification":"customers_comment",\n "create_time":Timestamp_in_seconds,\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ]\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Type NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/answer");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN",
"content-type": "application/json"
});
req.send("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Type Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"application/json",
@"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/answer"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Type OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/answer" in
let headers = Header.init ()
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Type PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/answer');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$request->setBody('{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Type PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}');
$request->setRequestUrl('https://api.tracksale.co/v2/answer');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Type PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/answer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Type Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/answer", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Type Python requests
import requests
url = "https://api.tracksale.co/v2/answer"
payload = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Type Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/answer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
request.body = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Type Shell wget
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--body-data '{\n "campaign_code": "campaign_code",\n "answers":[\n {\n "name":"customers_name",\n "email":"customers_Email",\n "score":Customer_score,\n "justification":"customers_comment",\n "create_time":Timestamp_in_seconds,\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ]\n}' \
--output-document \
- https://api.tracksale.co/v2/answer
Type Shell Httpie
echo '{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}' | \
http POST https://api.tracksale.co/v2/answer \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Type Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/answer \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "campaign_code": "campaign_code",\n "answers":[\n {\n "name":"customers_name",\n "email":"customers_Email",\n "score":Customer_score,\n "justification":"customers_comment",\n "create_time":Timestamp_in_seconds,\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ]\n}'
Type Swift (NSURL)
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/answer")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Insert Internal Notes
We also provide a method of inserting additional comments, like a internal notes. This method can be used with the following parameters.
- The method will be:
POST
- The URL to use should be:
https://api.tracksale.co/v2/note
The body must be filled with the response batch using the following pattern
{
"comment": "Comment_Text",
"answer_id": Answer_ID
}
Parameters
Parameter |
Type |
Required |
Description |
comment |
String |
Yes |
Comment that will be inserted as a note |
answer_id |
Integer |
No |
Answer Id, if it was not sent will must be used filter options below |
filter |
Array |
No |
If Answer Id was not sent, Filter options must be passed using the following pattern |
{
"comment": "Comment_Text",
"filter": {
"email":"Customer_Email",
"start_date":"Start_Date",
"end_date":"End_date"
}
}
Filters |
Type |
Required |
Description |
email |
String |
No, but at least one identification field is required to use filter options (e-mail or phone or identification) |
Customer Email |
phone |
String |
No, but at least one identification field is required to use filter options (e-mail or phone or identification) |
Customer Phone |
identification |
String |
No, but at least one identification field is required to use filter options (e-mail or phone or identification) |
Customer Identification |
start_date |
Date |
No, but input date fields is required to use filter options |
Date must be used in YYYY-MM-DD format. Example: 2017-01-31 |
end_date |
Date |
No, but input date fields is required to use filter options |
Date must be used in YYYY-MM-DD format. Example: 2017-01-31 |
campaign_code |
String |
No, is an optional filter |
Campaign Code |
Return example:
{
"msg":"Success",
"answer_id":123456
}
We provide a fill empty tags request method. This method can be used with the following parameters.
- The method will be:
POST
- The URL to be used must be:
https://api.tracksale.co/v2/fill-empty-tags
The body must be sent with the tags to be filled in the response, using the following pattern
Request limits:
1 customer per request.
Maximum of 50 tags per request.
{
"answer_id": Answer_ID,
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
]
}
Parameters
Parameters |
Type |
Required |
Description |
answer_id |
Integer |
No |
Answer Id, if it was not sent will must be used customer options below |
tags |
Array |
Yes |
Tag name |
customer |
Array |
No |
If Answer Id was not sent, customer options must be passed using the following pattern: |
Tags |
Type |
Required |
Description |
name |
String |
Yes |
Name Tag |
value |
String |
Yes |
Value Tag |
{
"campaign_code": "Campaign_code",
"customer": {
"email":"Customer_Email",
},
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
]
}
Customer |
Type |
Required |
Description |
email |
String |
No, but at least one identification field is required to use customer options (e-mail or phone or identification) |
Customer Email |
phone |
String |
No, but at least one identification field is required to use customer options (e-mail or phone or identification) |
Customer Phone |
identification |
String |
No, but at least one identification field is required to use customer options (e-mail or phone or identification) |
Customer Identification |
campaign_code |
String |
No |
Code da campanha |
Return example:
{
"answer_id":12345,
"msg":"Request received successfully!"
}
Search for draft lots
This method is responsible to get draft lots. This can be used with the following configuration
- The method will be:
GET
- The URL to use should be:
https://api.tracksale.co/v2/campaign/{code}/draft-lot
This method is responsible to get all draft lots of an specific campaign.
Where code is the campaign code that has the requested information.
Be sure that you are using parameter code
.
Return example:
{
"lot": [
{
"code": "Lot_code",
"create_time": "Create_Time",
"total_dispatches": "Total_dispatches",
}
]
}
Discard draft lots
To discard draft lots we must use the following configuration
- The method will be:
POST
- The URL to use should be:
https://api.tracksale.co/v2/campaign/{code}/discard-lot/{lot_code}
This method is responsible to discard the specified draft lot.
Where lot_code is the lot code that you want to discard.
Be sure that you are using parameter lot_code
.
Return example:
{
"success": true
}
Reports is our method for reporting, it's responsible for showing details of all your campaigns or a campaign.
All API communication is made from the base URL
https://api.tracksale.co/v2/report/DETAILS
.
Where DETAILS should be replaced by the details you wish to obtain through the requisition
The method to be used will be the GET
The header must be filled with the parameters where
-
Key
Authorization
-
Value
bearer TOKEN
Comments
The method to be used must be :GET
The URL to use should be :https://api.tracksale.co/v2/report/answer
Method responsible for returning customer comments.
Parameters
Parameter |
Type |
Default |
Required |
Description |
start |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
end |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
limit |
Integer |
By default it will show 10 comments per request. |
No |
Total comments to be returned. Use -1 to return all.
|
tags |
Boolean |
By default this is false, meaning no tags will be displayed. |
No |
Returns the tags related to the answers |
justifReturn |
String |
By default we will show the format "level" |
No |
Return format of justifications.
"array" - Returns all in a single array.
"level" - Returns JSON format with subfolders of grouped justifications.
|
codes |
String |
By default it will show comments for all campaigns |
No |
Used to show comments for a specific campaign, or comments for all campaigns. You can also show comments for more than one campaign at a time by using the comma as a separator
(Ex: codes=52,51,50 will show the comments of the campaigns whose Campaign_code is
50, 51 e 52) |
review |
Integer |
By default it is 0, that is, no comments are returned |
No |
Used to display notes and comments for Review questions. |
nps_secondary |
Integer |
By default it is 0, that is, no comments are returned |
No |
Used to display notes and comments for other NPS questions in addition to the mandatory NPS question in every campaign. |
open_question |
Integer |
By default it is 0, that is, no comments are returned |
No |
Used to display comments for Open Question questions. |
csat |
Integer |
By default it is 0, that is, no comments are returned |
No |
Used to display comments for CSAT questions. |
return_update_time |
Boolean |
By default is false |
No |
Returns the date of the last modification made to the opinion, such as changes in responsible party, status, or category. |
Return example:
[
{
"time": 1454340407,
"type": "Email",
"name": "Customers_name",
"email": "Customers_email",
"identification": null,
"phone": "Customers_phone",
"alternative_email": "Customers_email",
"alternative_phone": "Customers_phone",
"nps_answer": Score,
"last_nps_answer": Score,
"nps_comment": Comment,
"campaign_name": "Campaign_name",
"campaign_code": "Campaign_code",
"lot_code": "ABCDEFG123",
"id": 6805511,
"deadline": null,
"elapsed_time": 17,
"dispatch_time": null,
"reminder_time": null,
"status": "Status",
"priority": "None",
"assignee": "Assignee_name",
"picture": null,
"tags": [],
"categories": [],
"justifications": [],
"review": [],
"nps_secondary": [],
"open_question": [],
"csat": [],
"update_time": 1454340407
}
]
Dispatches
The method to be used must be :GET
The URL to use should be: https://api.tracksale.co/v2/report/dispatch
Method responsible for returning the batchs and their data, such as inserted customers, the time it was performed, its status and the clients that were inserted into it.
[
{
"campaign": {
"name": "Camapaign_name",
"code": "Campaign_code"
},
"dispatch_code": "Code_of_dispatch",
"status": Status_of_dispatch,
"create_time": "Campaign_creation_time",
"customers": [
{
"name": "Customers_name",
"identification": null,
"email": "Customers_email",
"phone": "Customers_phone",
"dispatch_time": "Code_of_dispatch",
"status": "Status_of_dispatch",
"has_answered": "Status_of_answer"
}
]
}
]
Parameters
Parameter |
Type |
Default |
Required |
Description |
start |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
end |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
codes |
String |
By default it will show comments for all campaigns |
No |
Used to show comments for a specific campaign, or comments for all campaigns. You can also show comments for more than one campaign at a time by using the comma as a separator.
(Ex: codes=52,51,50 will show the comments of the campaigns whose Campaign_code is
50, 51 e 52) |
NPS
The method to be used must be : GET
The URL to use should be:https://api.tracksale.co/v2/report/nps
Method responsible for returning the number of submissions, the numbers of detractors, promoters and neutrals and their respective percentages and also the value of nps.
Parameters
Parameter |
Type |
Default |
Required |
Description |
start |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Initial date in yyyy-mm-dd format |
end |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Final date in the format yyyy-mm-dd |
compare |
Boolean |
By default is false |
No |
Returns the NPS data for the previous date filter period.
|
codes |
String |
By default it will show comments for all campaigns |
No |
Used to show comments for a specific campaign, or comments for all campaigns. You can also show comments for more than one campaign at a time by using the comma as a separator
(Ex: codes=52,51,50 will show the comments of the campaigns whose Campaign_code is
50, 51 e 52) |
Return example:
{
"dispatches": Number_of_dispatches,
"promoters": Number_of_promoter,
"detractors": Number_of_detractors,
"passives": Number_of_neutrals,
"detractors_percentage": Percentage_of_detractors,
"passives_percentage": Percentage_of_neutrals,
"promoters_percentage": Percentage_of_promoters,
"nps": Period_NPS,
"compare": {
"dispatches": Number_of_dispatches,
"promoters": Number_of_promoter,
"detractors": Number_of_detractors,
"passives": Number_of_neutrals,
"detractors_percentage": Percentage_of_detractors,
"passives_percentage": Percentage_of_neutrals,
"promoters_percentage": Percentage_of_promoters,
"nps": Period_NPS,
}
}
Categories
The method to be used must be :GET
The URL to use should be: https://api.tracksale.co/v2/report/category
Method responsible for returning campaign categories according to NPS.
Parameters
Parameter |
Type |
Default |
Required |
Description |
start |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
end |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
codes |
String |
By default it will show comments for all campaigns |
No |
Used to show comments for a specific campaign, or comments for all campaigns. You can also show comments for more than one campaign at a time by using the comma as a separator.
(Ex: codes=52,51,50 will show the comments of the campaigns whose Campaign_code is
50, 51 e 52) |
Return example:
[
{
"id": 6805511,
"name": "Product",
"color": "#F8D347",
"total": 25,
"nps": Period_NPS,
"total": total,
}
]
Get campaign status
The method to be used must be :GET
The URL to use should be: https://api.tracksale.co/v2/report/status
Method responsible for returning campaign statuses.
Parameters
Parameter |
Type |
Default |
Required |
Description |
start |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
end |
Date |
By default we will show results 30 days prior to the date of the request (Ex: If you are sending this request on 01/31/2017 and do not include the initial and final interval you want to do your search, the returned period will be from 01/01/2017 to 01/31/2017) |
No |
Date can be used in YYYY-MM-DD format or by specifying the time in YYYY-MM-DDTHH:mm:ss. Example: 2017-01-31T12:00:00 |
codes |
String |
By default it will show comments for all campaigns |
No |
Used to show comments for a specific campaign, or comments for all campaigns. You can also show comments for more than one campaign at a time by using the comma as a separator.
(Ex: codes=52,51,50 will show the comments of the campaigns whose Campaign_code is
50, 51 e 52) |
Return exemple:
[
{
"id": 76,
"name": "Pendente Cliente",
"total": 25,
"color": "#F8D347"
}
]
Code samples : Reports /DETAILS
Type Http
GET /v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM HTTP/1.1
Host: api.tracksale
Authorization: bearer TOKEN
Cache-Control: no-cache
Type C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
Type cURL
curl -X GET \
'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM' \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache'
Type C#
var client = new RestClient("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
IRestResponse response = client.Execute(request);
Type Go
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Type Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")
.get()
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Type Java Unirest
HttpResponse<String> response = Unirest.get("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.asString();
Type JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM",
"method": "GET",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Type JavaScript XHR
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Type NodeJS Native
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
Type NodeJS Request
var request = require("request");
var options = { method: 'GET',
url: 'https://api.tracksale.co/v2/report/DETALHES',
qs: { start: 'DATA_INICIO', end: 'DATA_FIM' },
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Type NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("GET", "https://api.tracksale.co/v2/report/DETALHES");
req.query({
"start": "DATA_INICIO",
"end": "DATA_FIM"
});
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Type Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Type OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM" in
let headers = Header.init ()
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Type PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/report/DETALHES');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'start' => 'DATA_INICIO',
'end' => 'DATA_FIM'
));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Type PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.tracksale.co/v2/report/DETALHES');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
'start' => 'DATA_INICIO',
'end' => 'DATA_FIM'
)));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Type PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Type Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("GET", "/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Type Python requests
import requests
url = "https://api.tracksale.co/v2/report/DETALHES"
querystring = {"start":"DATA_INICIO","end":"DATA_FIM"}
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
Type Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
response = http.request(request)
puts response.read_body
Type Shell wget
wget --quiet \
--method GET \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--output-document \
- 'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM'
Type Shell Httpie
http GET 'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM' \
authorization:'bearer TOKEN' \
cache-control:no-cache
Type Shell cURL
curl --request GET \
--url 'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache'
Type Swift (NSURL)
import Foundation
let headers = [
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()