curl --request POST \
--url https://api.tranthor.com/api/public/apps/batch \
--header 'Content-Type: application/json' \
--header 'PublicWriteKey: <api-key>' \
--header 'authorization: <authorization>' \
--data '
{
"batch": [
{
"type": "track",
"event": "Signed Up",
"userId": "1043",
"properties": {
"plan": "Enterprise"
},
"messageId": "1ff51c9c-4929-45de-8914-3bb878be8c4a"
},
{
"type": "identify",
"userId": "532",
"traits": {
"email": "john@email.com"
},
"messageId": "6f5f436d-8534-4070-8023-d18f8b78ed39"
}
]
}
'import requests
url = "https://api.tranthor.com/api/public/apps/batch"
payload = { "batch": [
{
"type": "track",
"event": "Signed Up",
"userId": "1043",
"properties": { "plan": "Enterprise" },
"messageId": "1ff51c9c-4929-45de-8914-3bb878be8c4a"
},
{
"type": "identify",
"userId": "532",
"traits": { "email": "john@email.com" },
"messageId": "6f5f436d-8534-4070-8023-d18f8b78ed39"
}
] }
headers = {
"authorization": "<authorization>",
"PublicWriteKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
authorization: '<authorization>',
PublicWriteKey: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
batch: [
{
type: 'track',
event: 'Signed Up',
userId: '1043',
properties: {plan: 'Enterprise'},
messageId: '1ff51c9c-4929-45de-8914-3bb878be8c4a'
},
{
type: 'identify',
userId: '532',
traits: {email: 'john@email.com'},
messageId: '6f5f436d-8534-4070-8023-d18f8b78ed39'
}
]
})
};
fetch('https://api.tranthor.com/api/public/apps/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tranthor.com/api/public/apps/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'batch' => [
[
'type' => 'track',
'event' => 'Signed Up',
'userId' => '1043',
'properties' => [
'plan' => 'Enterprise'
],
'messageId' => '1ff51c9c-4929-45de-8914-3bb878be8c4a'
],
[
'type' => 'identify',
'userId' => '532',
'traits' => [
'email' => 'john@email.com'
],
'messageId' => '6f5f436d-8534-4070-8023-d18f8b78ed39'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"PublicWriteKey: <api-key>",
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tranthor.com/api/public/apps/batch"
payload := strings.NewReader("{\n \"batch\": [\n {\n \"type\": \"track\",\n \"event\": \"Signed Up\",\n \"userId\": \"1043\",\n \"properties\": {\n \"plan\": \"Enterprise\"\n },\n \"messageId\": \"1ff51c9c-4929-45de-8914-3bb878be8c4a\"\n },\n {\n \"type\": \"identify\",\n \"userId\": \"532\",\n \"traits\": {\n \"email\": \"john@email.com\"\n },\n \"messageId\": \"6f5f436d-8534-4070-8023-d18f8b78ed39\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("PublicWriteKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tranthor.com/api/public/apps/batch")
.header("authorization", "<authorization>")
.header("PublicWriteKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"batch\": [\n {\n \"type\": \"track\",\n \"event\": \"Signed Up\",\n \"userId\": \"1043\",\n \"properties\": {\n \"plan\": \"Enterprise\"\n },\n \"messageId\": \"1ff51c9c-4929-45de-8914-3bb878be8c4a\"\n },\n {\n \"type\": \"identify\",\n \"userId\": \"532\",\n \"traits\": {\n \"email\": \"john@email.com\"\n },\n \"messageId\": \"6f5f436d-8534-4070-8023-d18f8b78ed39\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tranthor.com/api/public/apps/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["PublicWriteKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"batch\": [\n {\n \"type\": \"track\",\n \"event\": \"Signed Up\",\n \"userId\": \"1043\",\n \"properties\": {\n \"plan\": \"Enterprise\"\n },\n \"messageId\": \"1ff51c9c-4929-45de-8914-3bb878be8c4a\"\n },\n {\n \"type\": \"identify\",\n \"userId\": \"532\",\n \"traits\": {\n \"email\": \"john@email.com\"\n },\n \"messageId\": \"6f5f436d-8534-4070-8023-d18f8b78ed39\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body"<string>"{
"message": "<string>"
}{
"message": "<string>"
}Batch
The batch method lets you send a series of identify, group, track, page and screen requests in a single batch, saving on outbound requests. A batch holds at most 2500 items. Events larger than 64 KB are dropped and the rest of the batch is accepted. An event whose messageId was already received for the same user is not stored again; the response header x-tranthor-deduplicated-events counts those. Mark replayed history with backfill: true so it is stored without starting journeys. The body may be sent with Content-Encoding: gzip.
curl --request POST \
--url https://api.tranthor.com/api/public/apps/batch \
--header 'Content-Type: application/json' \
--header 'PublicWriteKey: <api-key>' \
--header 'authorization: <authorization>' \
--data '
{
"batch": [
{
"type": "track",
"event": "Signed Up",
"userId": "1043",
"properties": {
"plan": "Enterprise"
},
"messageId": "1ff51c9c-4929-45de-8914-3bb878be8c4a"
},
{
"type": "identify",
"userId": "532",
"traits": {
"email": "john@email.com"
},
"messageId": "6f5f436d-8534-4070-8023-d18f8b78ed39"
}
]
}
'import requests
url = "https://api.tranthor.com/api/public/apps/batch"
payload = { "batch": [
{
"type": "track",
"event": "Signed Up",
"userId": "1043",
"properties": { "plan": "Enterprise" },
"messageId": "1ff51c9c-4929-45de-8914-3bb878be8c4a"
},
{
"type": "identify",
"userId": "532",
"traits": { "email": "john@email.com" },
"messageId": "6f5f436d-8534-4070-8023-d18f8b78ed39"
}
] }
headers = {
"authorization": "<authorization>",
"PublicWriteKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
authorization: '<authorization>',
PublicWriteKey: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
batch: [
{
type: 'track',
event: 'Signed Up',
userId: '1043',
properties: {plan: 'Enterprise'},
messageId: '1ff51c9c-4929-45de-8914-3bb878be8c4a'
},
{
type: 'identify',
userId: '532',
traits: {email: 'john@email.com'},
messageId: '6f5f436d-8534-4070-8023-d18f8b78ed39'
}
]
})
};
fetch('https://api.tranthor.com/api/public/apps/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tranthor.com/api/public/apps/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'batch' => [
[
'type' => 'track',
'event' => 'Signed Up',
'userId' => '1043',
'properties' => [
'plan' => 'Enterprise'
],
'messageId' => '1ff51c9c-4929-45de-8914-3bb878be8c4a'
],
[
'type' => 'identify',
'userId' => '532',
'traits' => [
'email' => 'john@email.com'
],
'messageId' => '6f5f436d-8534-4070-8023-d18f8b78ed39'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"PublicWriteKey: <api-key>",
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tranthor.com/api/public/apps/batch"
payload := strings.NewReader("{\n \"batch\": [\n {\n \"type\": \"track\",\n \"event\": \"Signed Up\",\n \"userId\": \"1043\",\n \"properties\": {\n \"plan\": \"Enterprise\"\n },\n \"messageId\": \"1ff51c9c-4929-45de-8914-3bb878be8c4a\"\n },\n {\n \"type\": \"identify\",\n \"userId\": \"532\",\n \"traits\": {\n \"email\": \"john@email.com\"\n },\n \"messageId\": \"6f5f436d-8534-4070-8023-d18f8b78ed39\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("PublicWriteKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tranthor.com/api/public/apps/batch")
.header("authorization", "<authorization>")
.header("PublicWriteKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"batch\": [\n {\n \"type\": \"track\",\n \"event\": \"Signed Up\",\n \"userId\": \"1043\",\n \"properties\": {\n \"plan\": \"Enterprise\"\n },\n \"messageId\": \"1ff51c9c-4929-45de-8914-3bb878be8c4a\"\n },\n {\n \"type\": \"identify\",\n \"userId\": \"532\",\n \"traits\": {\n \"email\": \"john@email.com\"\n },\n \"messageId\": \"6f5f436d-8534-4070-8023-d18f8b78ed39\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tranthor.com/api/public/apps/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["PublicWriteKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"batch\": [\n {\n \"type\": \"track\",\n \"event\": \"Signed Up\",\n \"userId\": \"1043\",\n \"properties\": {\n \"plan\": \"Enterprise\"\n },\n \"messageId\": \"1ff51c9c-4929-45de-8914-3bb878be8c4a\"\n },\n {\n \"type\": \"identify\",\n \"userId\": \"532\",\n \"traits\": {\n \"email\": \"john@email.com\"\n },\n \"messageId\": \"6f5f436d-8534-4070-8023-d18f8b78ed39\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body"<string>"{
"message": "<string>"
}{
"message": "<string>"
}{
"batch": [
{
"type": "track",
"event": "Signed Up",
"userId": "1043",
"properties": {
"plan": "Enterprise"
},
"messageId": "1ff51c9c-4929-45de-8914-3bb878be8c4a"
},
{
"type": "identify",
"userId": "532",
"traits": {
"email": "john@email.com"
},
"messageId": "6f5f436d-8534-4070-8023-d18f8b78ed39"
}
]
}
Authorizations
Authorization header for the request, in the format Basic <base64(secretId:secret)>. Copy the full value, including Basic, from https://app.tranthor.com/dashboard/settings#write-key.
Headers
Authorization header for the request, in the format Basic <base64(secretId:secret)>. Copy the full value, including Basic, from https://app.tranthor.com/dashboard/settings#write-key.
Body
Response
An empty String
An empty String

