Add contacts to a segment
curl --request POST \
--url https://api.watx.in/v1/segments/{id}/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contact_ids": [
"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e",
"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
]
}
'import requests
url = "https://api.watx.in/v1/segments/{id}/contacts"
payload = { "contact_ids": ["7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"] }
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({
contact_ids: ['7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e', '1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d']
})
};
fetch('https://api.watx.in/v1/segments/{id}/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.watx.in/v1/segments/{id}/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([
'contact_ids' => [
'7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e',
'1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d'
]
]),
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.watx.in/v1/segments/{id}/contacts"
payload := strings.NewReader("{\n \"contact_ids\": [\n \"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e\",\n \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n ]\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.watx.in/v1/segments/{id}/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contact_ids\": [\n \"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e\",\n \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.watx.in/v1/segments/{id}/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 \"contact_ids\": [\n \"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e\",\n \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"segment_id": "8c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f",
"requested": 2,
"added": 1
}
}{
"error": {
"code": "bad_request",
"message": "Cannot add contacts to a dynamic segment; its membership comes from its filter"
}
}{
"error": {
"code": "unauthorized",
"message": "Missing or invalid API key"
}
}{
"error": {
"code": "forbidden",
"message": "This API key is missing the 'messages:send' scope"
}
}{
"error": {
"code": "not_found",
"message": "Contact not found"
}
}{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded for this API key"
}
}Segments
Add contacts to a segment
Adds contacts to a static segment. A dynamic segment answers 400 —
its membership comes from its filter.
Up to 1000 contact ids per request. added counts the rows actually
created, so ids that were already members and ids belonging to another
workspace both count as zero — compare it with requested.
Requires the contacts:write scope.
POST
/
segments
/
{id}
/
contacts
Add contacts to a segment
curl --request POST \
--url https://api.watx.in/v1/segments/{id}/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contact_ids": [
"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e",
"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
]
}
'import requests
url = "https://api.watx.in/v1/segments/{id}/contacts"
payload = { "contact_ids": ["7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"] }
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({
contact_ids: ['7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e', '1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d']
})
};
fetch('https://api.watx.in/v1/segments/{id}/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.watx.in/v1/segments/{id}/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([
'contact_ids' => [
'7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e',
'1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d'
]
]),
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.watx.in/v1/segments/{id}/contacts"
payload := strings.NewReader("{\n \"contact_ids\": [\n \"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e\",\n \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n ]\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.watx.in/v1/segments/{id}/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contact_ids\": [\n \"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e\",\n \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.watx.in/v1/segments/{id}/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 \"contact_ids\": [\n \"7e2d9c01-55b4-4a3d-9c8e-0f1a2b3c4d5e\",\n \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"segment_id": "8c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f",
"requested": 2,
"added": 1
}
}{
"error": {
"code": "bad_request",
"message": "Cannot add contacts to a dynamic segment; its membership comes from its filter"
}
}{
"error": {
"code": "unauthorized",
"message": "Missing or invalid API key"
}
}{
"error": {
"code": "forbidden",
"message": "This API key is missing the 'messages:send' scope"
}
}{
"error": {
"code": "not_found",
"message": "Contact not found"
}
}{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded for this API key"
}
}Authorizations
Your workspace API key, created in Settings → API keys, sent as
Authorization: Bearer <key>. New keys start with watx_live_; keys
issued before the rename start with converse360_live_ and still work.
Path Parameters
The segment id.
Body
application/json
Required array length:
1 - 1000 elementsResponse
How many of the requested contacts were added.
Show child attributes
Show child attributes