Skip to main content
POST
/
whatsapp
/
subscriber
/
chat
/
assign-custom-fields
Assign Custom Fields
curl --request POST \
  --url https://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data apiToken=API-KEY \
  --data phone_number_id=PHONE-NUMBER-ID \
  --data phone_number=PHONE-NUMBER \
  --data 'custom_fields={"custom_field_name1":"value1"}'
import requests

url = "https://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields"

payload = {
"apiToken": "API-KEY",
"phone_number_id": "PHONE-NUMBER-ID",
"phone_number": "PHONE-NUMBER",
"custom_fields": "{\"custom_field_name1\":\"value1\"}"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, data=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
apiToken: 'API-KEY',
phone_number_id: 'PHONE-NUMBER-ID',
phone_number: 'PHONE-NUMBER',
custom_fields: '{"custom_field_name1":"value1"}'
})
};

fetch('https://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields', 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://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "apiToken=API-KEY&phone_number_id=PHONE-NUMBER-ID&phone_number=PHONE-NUMBER&custom_fields=%7B%22custom_field_name1%22%3A%22value1%22%7D",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);

$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://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields"

payload := strings.NewReader("apiToken=API-KEY&phone_number_id=PHONE-NUMBER-ID&phone_number=PHONE-NUMBER&custom_fields=%7B%22custom_field_name1%22%3A%22value1%22%7D")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("apiToken=API-KEY&phone_number_id=PHONE-NUMBER-ID&phone_number=PHONE-NUMBER&custom_fields=%7B%22custom_field_name1%22%3A%22value1%22%7D")
.asString();
require 'uri'
require 'net/http'

url = URI("https://platform.chatsyncs.com/api/v1/whatsapp/subscriber/chat/assign-custom-fields")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "apiToken=API-KEY&phone_number_id=PHONE-NUMBER-ID&phone_number=PHONE-NUMBER&custom_fields=%7B%22custom_field_name1%22%3A%22value1%22%7D"

response = http.request(request)
puts response.read_body
{
  "status": "1",
  "message": "Success."
}
Sets custom field values on a subscriber. See Subscriber Manager’s Custom Fields for what a custom field is and the available types (Text, Number, Date, Email, Phone).

The custom_fields JSON format

custom_fields is a single JSON object — each key is an existing custom field’s name, and each value is what you want to set it to, matching that field’s type:
{
  "city": "Bangalore",
  "plan_type": "Premium",
  "age": 28,
  "date_of_birth": "1998-05-20",
  "email": "rahul@example.com",
  "phone": "919999999999"
}
Field typeExample keyExample value
Text"city""Bangalore"
Number"age"28 (no quotes)
Date"date_of_birth""1998-05-20" (as text, YYYY-MM-DD)
Email"email""rahul@example.com"
Phone"phone""919999999999" (as text, digits only)
The field must already exist — check Custom Fields List for valid names, or create one first in Subscriber Manager → Manage → Manage Custom Fields. You only need to include the fields you’re updating — any field you leave out is unaffected.

Body

application/x-www-form-urlencoded
apiToken
string
required

Your ChatSyncs API key (not a WhatsApp/Meta access token). Where to find it.

Example:

"API-KEY"

phone_number_id
string
required

The WhatsApp account's phone number ID. Where to find it.

Example:

"PHONE-NUMBER-ID"

phone_number
string
required

The subscriber's phone number, with country code, digits only.

Example:

"PHONE-NUMBER"

custom_fields
string
required

A JSON object of custom field names and values.

Example:

"{\"custom_field_name1\":\"value1\"}"

Response

200 - application/json

Standard ChatSyncs response. status is "1" on success and "0" on failure.

status
string

"1" = success, "0" = failure.

message
string

Human-readable result message.