Add contacts
curl --request POST \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add \
--header 'Client-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "<string>",
"phone": "<string>"
}
'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add"
payload = {
"firstName": "<string>",
"phone": "<string>"
}
headers = {
"Client-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({firstName: '<string>', phone: '<string>'})
};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add', 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.z-api.io/instances/{instanceId}/token/{token}/contacts/add",
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([
'firstName' => '<string>',
'phone' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>",
"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.z-api.io/instances/{instanceId}/token/{token}/contacts/add"
payload := strings.NewReader("{\n \"firstName\": \"<string>\",\n \"phone\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-Token", "<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.z-api.io/instances/{instanceId}/token/{token}/contacts/add")
.header("Client-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"<string>\",\n \"phone\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"<string>\",\n \"phone\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyContacts
Add contacts
Save application contacts to the phone’s contact list
POST
/
instances
/
{instanceId}
/
token
/
{token}
/
contacts
/
add
Add contacts
curl --request POST \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add \
--header 'Client-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "<string>",
"phone": "<string>"
}
'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add"
payload = {
"firstName": "<string>",
"phone": "<string>"
}
headers = {
"Client-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({firstName: '<string>', phone: '<string>'})
};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add', 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.z-api.io/instances/{instanceId}/token/{token}/contacts/add",
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([
'firstName' => '<string>',
'phone' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>",
"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.z-api.io/instances/{instanceId}/token/{token}/contacts/add"
payload := strings.NewReader("{\n \"firstName\": \"<string>\",\n \"phone\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-Token", "<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.z-api.io/instances/{instanceId}/token/{token}/contacts/add")
.header("Client-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"<string>\",\n \"phone\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/contacts/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"<string>\",\n \"phone\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyOverview
This method is responsible for saving application contacts to your phone’s contact list.About this featureThe method for adding contacts to the application list will only work for accounts that have already received the necessary update. Make sure your application account has received the update before using this feature. Otherwise, the operation will not be completed successfully.Additionally, you need to allow the application to add contacts directly on your phone. To do this, go to your app’s privacy settings and adjust the permissions so that the application can access and modify your contacts.
Attributes
Header
Required
Optional
Request Body
[
{
"firstName": "Contact 1",
"lastName": "Last name 1",
"phone": "554499999999"
},
{
"firstName": "Contact 2",
"lastName": "Last name 2",
"phone": "554499998888"
}
]
Response
200
{
"success": true,
"errors": []
}