Create a contact
Create a contact with one or more channels. An identifier another contact already holds on the same channel is refused (400 duplicate_identifier, with details.conflicts[{channel, identifier, contactId}]); update the existing contact with PATCH /v2/contacts/{contactId} instead.
curl --request POST \
--url https://api.zavu.dev/v2/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"channels": [
{
"identifier": "+14155551234",
"countryCode": "US",
"label": "work",
"isPrimary": false
}
],
"displayName": "John Doe",
"metadata": {}
}
'import requests
url = "https://api.zavu.dev/v2/contacts"
payload = {
"channels": [
{
"identifier": "+14155551234",
"countryCode": "US",
"label": "work",
"isPrimary": False
}
],
"displayName": "John Doe",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
channels: [
{identifier: '+14155551234', countryCode: 'US', label: 'work', isPrimary: false}
],
displayName: 'John Doe',
metadata: {}
})
};
fetch('https://api.zavu.dev/v2/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://api.zavu.dev/v2/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([
'channels' => [
[
'identifier' => '+14155551234',
'countryCode' => 'US',
'label' => 'work',
'isPrimary' => false
]
],
'displayName' => 'John Doe',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.zavu.dev/v2/contacts"
payload := strings.NewReader("{\n \"channels\": [\n {\n \"identifier\": \"+14155551234\",\n \"countryCode\": \"US\",\n \"label\": \"work\",\n \"isPrimary\": false\n }\n ],\n \"displayName\": \"John Doe\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.zavu.dev/v2/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"channels\": [\n {\n \"identifier\": \"+14155551234\",\n \"countryCode\": \"US\",\n \"label\": \"work\",\n \"isPrimary\": false\n }\n ],\n \"displayName\": \"John Doe\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v2/contacts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"channels\": [\n {\n \"identifier\": \"+14155551234\",\n \"countryCode\": \"US\",\n \"label\": \"work\",\n \"isPrimary\": false\n }\n ],\n \"displayName\": \"John Doe\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"availableChannels": [
"<string>"
],
"verified": true,
"metadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"displayName": "John Doe",
"phoneNumber": "+56912345678",
"primaryPhone": "+56912345678",
"primaryEmail": "john@example.com",
"countryCode": "CL",
"profileName": "John Doe",
"defaultChannel": "sms",
"channels": [
{
"id": "<string>",
"channel": "sms",
"identifier": "+14155551234",
"isPrimary": true,
"verified": true,
"createdAt": "2023-11-07T05:31:56Z",
"countryCode": "US",
"label": "work",
"metrics": {
"successCount": 123,
"failureCount": 123,
"totalAttempts": 123,
"avgDeliveryTimeMs": 123,
"lastSuccessAt": "2023-11-07T05:31:56Z"
},
"lastInboundAt": "2023-11-07T05:31:56Z",
"metadata": {},
"updatedAt": "2023-11-07T05:31:56Z"
}
],
"updatedAt": "2023-11-07T05:31:56Z"
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Request body to create a contact with channels.
Response
Created.
List of available messaging channels for this contact.
Whether this contact has been verified.
Show child attributes
Show child attributes
Display name for the contact.
"John Doe"
DEPRECATED: Use primaryPhone instead. Primary phone number in E.164 format.
"+56912345678"
Primary phone number in E.164 format.
"+56912345678"
Primary email address.
"john@example.com"
"CL"
Contact's WhatsApp profile name. Only available for WhatsApp contacts.
"John Doe"
Preferred channel for this contact.
sms, whatsapp, telegram, email, instagram, messenger, voice All communication channels for this contact.
Show child attributes
Show child attributes
curl --request POST \
--url https://api.zavu.dev/v2/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"channels": [
{
"identifier": "+14155551234",
"countryCode": "US",
"label": "work",
"isPrimary": false
}
],
"displayName": "John Doe",
"metadata": {}
}
'import requests
url = "https://api.zavu.dev/v2/contacts"
payload = {
"channels": [
{
"identifier": "+14155551234",
"countryCode": "US",
"label": "work",
"isPrimary": False
}
],
"displayName": "John Doe",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
channels: [
{identifier: '+14155551234', countryCode: 'US', label: 'work', isPrimary: false}
],
displayName: 'John Doe',
metadata: {}
})
};
fetch('https://api.zavu.dev/v2/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://api.zavu.dev/v2/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([
'channels' => [
[
'identifier' => '+14155551234',
'countryCode' => 'US',
'label' => 'work',
'isPrimary' => false
]
],
'displayName' => 'John Doe',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.zavu.dev/v2/contacts"
payload := strings.NewReader("{\n \"channels\": [\n {\n \"identifier\": \"+14155551234\",\n \"countryCode\": \"US\",\n \"label\": \"work\",\n \"isPrimary\": false\n }\n ],\n \"displayName\": \"John Doe\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.zavu.dev/v2/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"channels\": [\n {\n \"identifier\": \"+14155551234\",\n \"countryCode\": \"US\",\n \"label\": \"work\",\n \"isPrimary\": false\n }\n ],\n \"displayName\": \"John Doe\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v2/contacts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"channels\": [\n {\n \"identifier\": \"+14155551234\",\n \"countryCode\": \"US\",\n \"label\": \"work\",\n \"isPrimary\": false\n }\n ],\n \"displayName\": \"John Doe\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"availableChannels": [
"<string>"
],
"verified": true,
"metadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"displayName": "John Doe",
"phoneNumber": "+56912345678",
"primaryPhone": "+56912345678",
"primaryEmail": "john@example.com",
"countryCode": "CL",
"profileName": "John Doe",
"defaultChannel": "sms",
"channels": [
{
"id": "<string>",
"channel": "sms",
"identifier": "+14155551234",
"isPrimary": true,
"verified": true,
"createdAt": "2023-11-07T05:31:56Z",
"countryCode": "US",
"label": "work",
"metrics": {
"successCount": 123,
"failureCount": 123,
"totalAttempts": 123,
"avgDeliveryTimeMs": 123,
"lastSuccessAt": "2023-11-07T05:31:56Z"
},
"lastInboundAt": "2023-11-07T05:31:56Z",
"metadata": {},
"updatedAt": "2023-11-07T05:31:56Z"
}
],
"updatedAt": "2023-11-07T05:31:56Z"
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}