> ## Documentation Index
> Fetch the complete documentation index at: https://developer.chatsyncs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscriber Assign Custom Fields

> Set one or more custom field values on a subscriber via the ChatSyncs API, using a JSON object of field name/value pairs. Use when a developer asks how to sync CRM data into a subscriber's custom fields.

Sets custom field values on a subscriber. See
[Subscriber Manager's Custom Fields](https://help.chatsyncs.com/docs/custom-fields-labels-lists#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:

```json theme={null}
{
  "city": "Bangalore",
  "plan_type": "Premium",
  "age": 28,
  "date_of_birth": "1998-05-20",
  "email": "rahul@example.com",
  "phone": "919999999999"
}
```

| Field type | Example key | Example 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) |

<Note>
  Use the names from [Custom Fields List](/developer-api/subscriber/list-custom-fields), 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 (verified).
</Note>

<Warning>
  **The API doesn't check what you send.** A field name that doesn't exist is still accepted and stored on the contact
  as if it were one, so a typo silently creates a stray value. Types aren't enforced either: an `Email` or `Phone` field
  accepts any text. An empty string `""` clears a field. Only invalid JSON is rejected, with
  `Invalid JSON:Syntax error`.
</Warning>


## OpenAPI

````yaml POST /whatsapp/subscriber/chat/assign-custom-fields
openapi: 3.1.0
info:
  title: ChatSyncs Developer API
  version: 1.0.0
  description: >-
    REST API for sending WhatsApp messages and managing subscribers through
    ChatSyncs.


    **Authentication.** Send your key as the `apiToken` parameter, or as
    `Authorization: Bearer <key>` — both work on every endpoint **except Custom
    Fields List**, which only accepts the `apiToken` parameter (a Bearer header
    alone is answered with *The api token field is required.*). A wrong key
    returns HTTP 401 `{"status":"0","message":"Unauthenticated."}`; no key at
    all redirects to the login page.


    **Methods.** Every endpoint accepts both GET and POST with the same
    parameters, except Upload Media, which is POST-only. Use POST for anything
    that changes data.


    **Errors.** Failures usually come back as HTTP 200 with `"status":"0"` and
    the reason in `message`, so always check `status`. `status` is the string
    `"1"` or `"0"` on most endpoints and a boolean on a few.


    **Lists.** Endpoints that return rows put them in `message` as a list; there
    is no `data` field (Custom Fields List is the exception and uses `data`).
servers:
  - url: https://platform.chatsyncs.com/api/v1
security: []
paths:
  /whatsapp/subscriber/chat/assign-custom-fields:
    post:
      tags:
        - Subscriber API
      summary: Assign Custom Fields
      description: >-
        `custom_fields` is a JSON **object**. Each call changes only the fields
        you name; the rest are kept (verified). The API does not check that a
        field exists, nor its type: an unknown name is stored on the contact as
        if it were one, and `Email` or `Phone` fields accept any text. An empty
        string clears a field. Use Custom Fields List for the real names.
      operationId: assignCustomFields
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                apiToken:
                  type: string
                  description: >-
                    Your ChatSyncs API key (not a WhatsApp/Meta access token).
                    [Where to find
                    it](/developer-api/finding-ids#api-token-apitoken).
                  example: API-KEY
                phone_number_id:
                  type: string
                  description: >-
                    The WhatsApp account's phone number ID. [Where to find
                    it](/developer-api/finding-ids#phone-number-id-phone_number_id).
                  example: PHONE-NUMBER-ID
                phone_number:
                  type: string
                  description: >-
                    The subscriber's phone number, with country code, digits
                    only.
                  example: PHONE-NUMBER
                custom_fields:
                  type: string
                  description: A JSON object of custom field names and values.
                  example: '{"custom_field_name1":"value1"}'
              required:
                - apiToken
                - phone_number_id
                - phone_number
                - custom_fields
      responses:
        '200':
          description: >-
            Standard ChatSyncs response. `status` is `"1"` on success and `"0"`
            on failure.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: '`"1"` = success, `"0"` = failure.'
                  message:
                    type: string
                    description: Human-readable result message.
              examples:
                success:
                  summary: Success
                  value:
                    status: '1'
                    message: Subscriber changes have been saved successfully.
                error:
                  summary: A required field is missing
                  value:
                    status: '0'
                    message: >-
                      The phone number id field is required., The phone number
                      field is required., The custom fields field is required.
                badJson:
                  summary: custom_fields is not valid JSON
                  value:
                    status: '0'
                    message: Invalid JSON:Syntax error
        '401':
          description: >-
            `apiToken` is wrong. (With no token at all the API redirects to the
            login page with HTTP 302 instead of returning JSON.)
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
              examples:
                unauthenticated:
                  summary: Wrong apiToken
                  value:
                    status: '0'
                    message: Unauthenticated.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.