Contacts
Create a contact
POST /dn/contacts adds one contact to your address book. Send a name or company and an address.
POST
/
dn
/
contacts
Create a contact
curl --request POST \
--url https://app.detrack.com/api/v2/dn/contacts \
--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"
}
}
'import requests
url = "https://app.detrack.com/api/v2/dn/contacts"
payload = { "data": {
"deliver_to_collect_from": "James Li",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"phone_number": "65432178"
} }
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'
}
})
};
fetch('https://app.detrack.com/api/v2/dn/contacts', 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",
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'
]
]),
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"
payload := strings.NewReader("{\n \"data\": {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\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")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.detrack.com/api/v2/dn/contacts")
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 \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\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": [
{
"field": "deliver_to_collect_from",
"codes": [
"or company can't be blank"
]
},
{
"field": "company_name",
"codes": [
"or name can't be blank"
]
}
]
}Add one contact to your Detrack address book. A contact needs
deliver_to_collect_from or company_name, and an address unless you send address_1, address_2, or address_3. The response is the new contact with its id, and the Location header has its URL.
Detrack doesn’t check for duplicates, so creating the same contact twice saves it twice. To change a contact you’ve already saved, use Update a contact. To add up to 100 contacts in one request, use Bulk create contacts.
See Contacts for how addresses and groups work.Authorizations
Your Detrack API key, from Integrations > API Key in the dashboard.
Body
application/json
Contact fields you can send. On update, send only the fields you want to change. A contact needs deliver_to_collect_from or company_name.
Show child attributes
Show child attributes
Response
The created contact. The Location header has its URL.
A saved recipient. Empty fields are null. The pick-up fields (pick_up_*) are returned only if your account uses point-to-point jobs.
Show child attributes
Show child attributes
Create a contact
curl --request POST \
--url https://app.detrack.com/api/v2/dn/contacts \
--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"
}
}
'import requests
url = "https://app.detrack.com/api/v2/dn/contacts"
payload = { "data": {
"deliver_to_collect_from": "James Li",
"address": "61 Kaki Bukit Ave 1, Singapore 417943",
"phone_number": "65432178"
} }
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'
}
})
};
fetch('https://app.detrack.com/api/v2/dn/contacts', 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",
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'
]
]),
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"
payload := strings.NewReader("{\n \"data\": {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\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")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.detrack.com/api/v2/dn/contacts")
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 \"deliver_to_collect_from\": \"James Li\",\n \"address\": \"61 Kaki Bukit Ave 1, Singapore 417943\",\n \"phone_number\": \"65432178\"\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": [
{
"field": "deliver_to_collect_from",
"codes": [
"or company can't be blank"
]
},
{
"field": "company_name",
"codes": [
"or name can't be blank"
]
}
]
}