Contacts
Update a contact
PUT /dn/contacts/ changes the fields you send on one contact and returns the updated contact.
PUT
/
dn
/
contacts
/
{id}
Update a contact
curl --request PUT \
--url https://app.detrack.com/api/v2/dn/contacts/{id} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"data": {
"phone_number": "65432179"
}
}
'import requests
url = "https://app.detrack.com/api/v2/dn/contacts/{id}"
payload = { "data": { "phone_number": "65432179" } }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {phone_number: '65432179'}})
};
fetch('https://app.detrack.com/api/v2/dn/contacts/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'phone_number' => '65432179'
]
]),
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/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"phone_number\": \"65432179\"\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://app.detrack.com/api/v2/dn/contacts/{id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"phone_number\": \"65432179\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.detrack.com/api/v2/dn/contacts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"phone_number\": \"65432179\"\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": "not_found",
"message": "Contact not found"
}{
"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"
]
}
]
}Change one contact by its
id. Send only the fields you want to change. Fields you leave out keep their values.
Items work differently from jobs: the items you send don’t replace the contact’s list. An item with an id changes that item, an item without one is added, and an item with its id and "_destroy": true is removed.
See also Retrieve a contact and Delete a contact.Authorizations
Your Detrack API key, from Integrations > API Key in the dashboard.
Path Parameters
The contact's id, from List contacts or Create a contact.
Example:
"65263b0c29e804cae4fedd76"
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 updated contact.
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
Update a contact
curl --request PUT \
--url https://app.detrack.com/api/v2/dn/contacts/{id} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"data": {
"phone_number": "65432179"
}
}
'import requests
url = "https://app.detrack.com/api/v2/dn/contacts/{id}"
payload = { "data": { "phone_number": "65432179" } }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {phone_number: '65432179'}})
};
fetch('https://app.detrack.com/api/v2/dn/contacts/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'phone_number' => '65432179'
]
]),
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/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"phone_number\": \"65432179\"\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://app.detrack.com/api/v2/dn/contacts/{id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"phone_number\": \"65432179\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.detrack.com/api/v2/dn/contacts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"phone_number\": \"65432179\"\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": "not_found",
"message": "Contact not found"
}{
"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"
]
}
]
}