Contacts
Bulk create contacts
POST /dn/contacts/bulk adds up to 100 contacts to your address book in one request.
POST
/
dn
/
contacts
/
bulk
Bulk create contacts
curl --request POST \
--url https://app.detrack.com/api/v2/dn/contacts/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"data": [
{
"deliver_to_collect_from": "James Li",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"phone_number": "65432178"
},
{
"company_name": "Kaki Bukit Hardware",
"address": "10 Ubi Crescent, Singapore 408564"
}
]
}
'import requests
url = "https://app.detrack.com/api/v2/dn/contacts/bulk"
payload = { "data": [
{
"deliver_to_collect_from": "James Li",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"phone_number": "65432178"
},
{
"company_name": "Kaki Bukit Hardware",
"address": "10 Ubi Crescent, Singapore 408564"
}
] }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
deliver_to_collect_from: 'James Li',
address: '61 Kaki Bukit Ave 1, Singapore 417943',
phone_number: '65432178'
},
{
company_name: 'Kaki Bukit Hardware',
address: '10 Ubi Crescent, Singapore 408564'
}
]
})
};
fetch('https://app.detrack.com/api/v2/dn/contacts/bulk', 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://app.detrack.com/api/v2/dn/contacts/bulk",
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([
'data' => [
[
'deliver_to_collect_from' => 'James Li',
'address' => '61 Kaki Bukit Ave 1, Singapore 417943',
'phone_number' => '65432178'
],
[
'company_name' => 'Kaki Bukit Hardware',
'address' => '10 Ubi Crescent, Singapore 408564'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://app.detrack.com/api/v2/dn/contacts/bulk"
payload := strings.NewReader("{\n \"data\": [\n {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n },\n {\n \"company_name\": \"Kaki Bukit Hardware\",\n \"address\": \"10 Ubi Crescent, Singapore 408564\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<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://app.detrack.com/api/v2/dn/contacts/bulk")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n },\n {\n \"company_name\": \"Kaki Bukit Hardware\",\n \"address\": \"10 Ubi Crescent, Singapore 408564\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.detrack.com/api/v2/dn/contacts/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n },\n {\n \"company_name\": \"Kaki Bukit Hardware\",\n \"address\": \"10 Ubi Crescent, Singapore 408564\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "65263b0c29e804cae4fedd76",
"deliver_to_collect_from": "James Li",
"last_name": "<string>",
"job_time": "<string>",
"customer": "<string>",
"company_name": "Detrack",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"postal_code": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"address_3": "<string>",
"city": "<string>",
"state": "<string>",
"country": "<string>",
"address_lat": 123,
"address_lng": 123,
"phone_number": "65432178",
"fax_number": "<string>",
"notify_email": "test@example.com",
"zone": "<string>",
"instructions": "<string>",
"boxes": "<string>",
"cubic_meters": 123,
"cartons": 123,
"pieces": 123,
"envelopes": 123,
"pallets": 123,
"remarks": "<string>",
"account_number": "<string>",
"sales_person": "<string>",
"pick_up_from": "<string>",
"pick_up_time": "<string>",
"pick_up_address": "<string>",
"pick_up_address_1": "<string>",
"pick_up_address_2": "<string>",
"pick_up_address_3": "<string>",
"pick_up_city": "<string>",
"pick_up_state": "<string>",
"pick_up_country": "<string>",
"pick_up_postal_code": "<string>",
"pick_up_zone": "<string>",
"pick_up_lat": 123,
"pick_up_lng": 123,
"sender_phone_number": "<string>",
"groups": [
{
"id": "5e8b2f1a29e804cae4fe0a11",
"name": "North"
}
],
"items": [
{
"id": "6526409e29e804cae4fedd81",
"sku": "12345678",
"description": "iPad",
"quantity": 2,
"unit_price": 123,
"fixed_price": 123,
"minimum_quantity": 123,
"position": 0
}
]
}
]
}{
"code": "invalid_json_format"
}{
"code": "invalid_key",
"message": "Invalid key"
}{
"code": "forbidden"
}{
"code": "validation_failed",
"message": "Validation failed",
"errors": [
{
"index": 1,
"errors": [
{
"field": "address",
"codes": [
"cannot be blank"
]
}
]
}
],
"data": [
{
"id": "65263b0c29e804cae4fedd76",
"deliver_to_collect_from": "James Li",
"last_name": "<string>",
"job_time": "<string>",
"customer": "<string>",
"company_name": "Detrack",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"postal_code": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"address_3": "<string>",
"city": "<string>",
"state": "<string>",
"country": "<string>",
"address_lat": 123,
"address_lng": 123,
"phone_number": "65432178",
"fax_number": "<string>",
"notify_email": "test@example.com",
"zone": "<string>",
"instructions": "<string>",
"boxes": "<string>",
"cubic_meters": 123,
"cartons": 123,
"pieces": 123,
"envelopes": 123,
"pallets": 123,
"remarks": "<string>",
"account_number": "<string>",
"sales_person": "<string>",
"pick_up_from": "<string>",
"pick_up_time": "<string>",
"pick_up_address": "<string>",
"pick_up_address_1": "<string>",
"pick_up_address_2": "<string>",
"pick_up_address_3": "<string>",
"pick_up_city": "<string>",
"pick_up_state": "<string>",
"pick_up_country": "<string>",
"pick_up_postal_code": "<string>",
"pick_up_zone": "<string>",
"pick_up_lat": 123,
"pick_up_lng": 123,
"sender_phone_number": "<string>",
"groups": [
{
"id": "5e8b2f1a29e804cae4fe0a11",
"name": "North"
}
],
"items": [
{
"id": "6526409e29e804cae4fedd81",
"sku": "12345678",
"description": "iPad",
"quantity": 2,
"unit_price": 123,
"fixed_price": 123,
"minimum_quantity": 123,
"position": 0
}
]
}
]
}Add up to 100 contacts in one request by sending them as a list in
data. Each contact is checked and saved the same way as Create a contact, so each needs deliver_to_collect_from or company_name, and an address unless you send address_1, address_2, or address_3.
When every contact is valid, the API returns 201 with the new contacts in the order you sent them. When some aren’t, the valid ones are still saved, and the API returns 422 with the code validation_failed. Its errors names each rejected contact by its index in your list, counting from 0, and its data lists the contacts that were created. Resend only the rejected contacts, or the others are saved twice.
Nothing is saved, and the API returns 422, if data:
- isn’t a list, is empty, or has an entry that isn’t an object (
invalid_data) - has more than 100 contacts (
too_many_contacts). The extra contacts aren’t skipped, as they are by Bulk create jobs, so split a longer list into several requests.
groups or items can’t be read, for example groups is a string instead of a list, that contact is rejected with "field": null and the code “groups or items can’t be read”, and the others are still saved.
Detrack doesn’t check for duplicates, so a contact you send twice is saved twice.Authorizations
Your Detrack API key, from Integrations > API Key in the dashboard.
Body
application/json
1 to 100 contacts. Send more than 100 and nothing is saved.
Required array length:
1 - 100 elementsShow child attributes
Show child attributes
Response
Every contact was created. They're listed in the order you sent them.
Show child attributes
Show child attributes
Bulk create contacts
curl --request POST \
--url https://app.detrack.com/api/v2/dn/contacts/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"data": [
{
"deliver_to_collect_from": "James Li",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"phone_number": "65432178"
},
{
"company_name": "Kaki Bukit Hardware",
"address": "10 Ubi Crescent, Singapore 408564"
}
]
}
'import requests
url = "https://app.detrack.com/api/v2/dn/contacts/bulk"
payload = { "data": [
{
"deliver_to_collect_from": "James Li",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"phone_number": "65432178"
},
{
"company_name": "Kaki Bukit Hardware",
"address": "10 Ubi Crescent, Singapore 408564"
}
] }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
deliver_to_collect_from: 'James Li',
address: '61 Kaki Bukit Ave 1, Singapore 417943',
phone_number: '65432178'
},
{
company_name: 'Kaki Bukit Hardware',
address: '10 Ubi Crescent, Singapore 408564'
}
]
})
};
fetch('https://app.detrack.com/api/v2/dn/contacts/bulk', 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://app.detrack.com/api/v2/dn/contacts/bulk",
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([
'data' => [
[
'deliver_to_collect_from' => 'James Li',
'address' => '61 Kaki Bukit Ave 1, Singapore 417943',
'phone_number' => '65432178'
],
[
'company_name' => 'Kaki Bukit Hardware',
'address' => '10 Ubi Crescent, Singapore 408564'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://app.detrack.com/api/v2/dn/contacts/bulk"
payload := strings.NewReader("{\n \"data\": [\n {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n },\n {\n \"company_name\": \"Kaki Bukit Hardware\",\n \"address\": \"10 Ubi Crescent, Singapore 408564\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<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://app.detrack.com/api/v2/dn/contacts/bulk")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n },\n {\n \"company_name\": \"Kaki Bukit Hardware\",\n \"address\": \"10 Ubi Crescent, Singapore 408564\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.detrack.com/api/v2/dn/contacts/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n },\n {\n \"company_name\": \"Kaki Bukit Hardware\",\n \"address\": \"10 Ubi Crescent, Singapore 408564\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "65263b0c29e804cae4fedd76",
"deliver_to_collect_from": "James Li",
"last_name": "<string>",
"job_time": "<string>",
"customer": "<string>",
"company_name": "Detrack",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"postal_code": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"address_3": "<string>",
"city": "<string>",
"state": "<string>",
"country": "<string>",
"address_lat": 123,
"address_lng": 123,
"phone_number": "65432178",
"fax_number": "<string>",
"notify_email": "test@example.com",
"zone": "<string>",
"instructions": "<string>",
"boxes": "<string>",
"cubic_meters": 123,
"cartons": 123,
"pieces": 123,
"envelopes": 123,
"pallets": 123,
"remarks": "<string>",
"account_number": "<string>",
"sales_person": "<string>",
"pick_up_from": "<string>",
"pick_up_time": "<string>",
"pick_up_address": "<string>",
"pick_up_address_1": "<string>",
"pick_up_address_2": "<string>",
"pick_up_address_3": "<string>",
"pick_up_city": "<string>",
"pick_up_state": "<string>",
"pick_up_country": "<string>",
"pick_up_postal_code": "<string>",
"pick_up_zone": "<string>",
"pick_up_lat": 123,
"pick_up_lng": 123,
"sender_phone_number": "<string>",
"groups": [
{
"id": "5e8b2f1a29e804cae4fe0a11",
"name": "North"
}
],
"items": [
{
"id": "6526409e29e804cae4fedd81",
"sku": "12345678",
"description": "iPad",
"quantity": 2,
"unit_price": 123,
"fixed_price": 123,
"minimum_quantity": 123,
"position": 0
}
]
}
]
}{
"code": "invalid_json_format"
}{
"code": "invalid_key",
"message": "Invalid key"
}{
"code": "forbidden"
}{
"code": "validation_failed",
"message": "Validation failed",
"errors": [
{
"index": 1,
"errors": [
{
"field": "address",
"codes": [
"cannot be blank"
]
}
]
}
],
"data": [
{
"id": "65263b0c29e804cae4fedd76",
"deliver_to_collect_from": "James Li",
"last_name": "<string>",
"job_time": "<string>",
"customer": "<string>",
"company_name": "Detrack",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"postal_code": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"address_3": "<string>",
"city": "<string>",
"state": "<string>",
"country": "<string>",
"address_lat": 123,
"address_lng": 123,
"phone_number": "65432178",
"fax_number": "<string>",
"notify_email": "test@example.com",
"zone": "<string>",
"instructions": "<string>",
"boxes": "<string>",
"cubic_meters": 123,
"cartons": 123,
"pieces": 123,
"envelopes": 123,
"pallets": 123,
"remarks": "<string>",
"account_number": "<string>",
"sales_person": "<string>",
"pick_up_from": "<string>",
"pick_up_time": "<string>",
"pick_up_address": "<string>",
"pick_up_address_1": "<string>",
"pick_up_address_2": "<string>",
"pick_up_address_3": "<string>",
"pick_up_city": "<string>",
"pick_up_state": "<string>",
"pick_up_country": "<string>",
"pick_up_postal_code": "<string>",
"pick_up_zone": "<string>",
"pick_up_lat": 123,
"pick_up_lng": 123,
"sender_phone_number": "<string>",
"groups": [
{
"id": "5e8b2f1a29e804cae4fe0a11",
"name": "North"
}
],
"items": [
{
"id": "6526409e29e804cae4fedd81",
"sku": "12345678",
"description": "iPad",
"quantity": 2,
"unit_price": 123,
"fixed_price": 123,
"minimum_quantity": 123,
"position": 0
}
]
}
]
}