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

# Update Contact

> Updates an existing contact. Use this unified endpoint to update standard profile fields, add/remove tags by modifying the `tagsId` array, and update user-defined custom field values inside the `customFields` array.

Use this endpoint to modify an existing contact's profile.

You must provide the unique 24-character contact `id` in the URL path. All body parameters are optional. You only need to send the specific fields you want to change.

This is a unified endpoint. You can update standard profile fields, assign or remove tags, and modify custom field values in a single request.

To update tags, you must provide the complete array of `tagsId` that the contact should have. To update custom fields, you only need to pass the specific fields you wish to update within the `customFields` array.


## OpenAPI

````yaml PUT /api/contacts/{id}
openapi: 3.1.0
info:
  title: Automate Chats API
  description: >-
    API for managing WhatsApp template messages, contacts, custom fields, tags,
    and external integrations.
  version: 1.0.0
servers:
  - url: https://api.automatechats.com
security:
  - apiKeyAuth: []
paths:
  /api/contacts/{id}:
    put:
      summary: Update Contact / Assign Tags & Custom Fields
      description: >-
        Updates an existing contact. Use this unified endpoint to update
        standard profile fields, add/remove tags by modifying the `tagsId`
        array, and update user-defined custom field values inside the
        `customFields` array.
      parameters:
        - name: id
          in: path
          description: The unique 24-character ID of the contact to update.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactUpdateInput'
            examples:
              updateStandardFields:
                summary: 1. Update Standard Fields
                description: Update name, email, or other standard profile details.
                value:
                  firstName: Jane
                  lastName: Smith
                  email: jane.smith@example.com
              addTagToContact:
                summary: 2. Add Tag to Contact
                description: >-
                  To add tag(s), pass the complete updated array of tag IDs
                  including the new tag ID(s).
                value:
                  tagsId:
                    - 65e0bc51c12e4d70834b070e
                    - 65e0bc51c12e4d70834b070f
                    - 65e0bc51c12e4d70834b070d
              removeTagFromContact:
                summary: 3. Remove Tag from Contact
                description: >-
                  To remove tag(s), send the array of tag IDs excluding the ID
                  of the tag to be removed.
                value:
                  tagsId:
                    - 65e0bc51c12e4d70834b070e
                    - 65e0bc51c12e4d70834b070f
              updateCustomFieldValues:
                summary: 4. Update Custom Field Values
                description: >-
                  To update contact's custom field values, pass their custom
                  field IDs and values in the `customFields` array.
                value:
                  customFields:
                    - fieldId: 65f12ab3c9e4f1a2b3c4d5e6
                      value: Enterprise Tier
                    - fieldId: 65f12ab3c9e4f1a2b3c4d5e8
                      value: Referred by Sales Agent
      responses:
        '200':
          description: Contact updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  code:
                    type: integer
                    example: 200
                  message:
                    type: string
                    example: Contact updated successfully
                  data:
                    type: object
                    properties:
                      contact:
                        $ref: '#/components/schemas/Contact'
                  timestamp:
                    type: string
                    format: date-time
        '400':
          description: Bad Request (e.g. invalid date or payload format)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          description: Contact not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflict (Phone number already in use by another contact)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ContactUpdateInput:
      type: object
      properties:
        firstName:
          type: string
          minLength: 2
          maxLength: 50
          description: Contact's first name
          example: John
        lastName:
          type: string
          maxLength: 50
          description: Contact's last name
          example: Doe
        chatName:
          type: string
          maxLength: 100
          description: Formatted name used in active chats
          example: John Doe
        email:
          type: string
          format: email
          description: Contact's email address
          example: john.doe@example.com
        phoneNumber:
          type: string
          description: Phone number without country code
          example: '9876543210'
        countryCode:
          type: string
          description: Country code including '+'
          example: '+91'
        source:
          type: string
          maxLength: 50
          description: Custom source identifier
          example: website
        subscribed:
          type: boolean
          description: WhatsApp subscription status
        tagsId:
          type: array
          description: Complete updated list of 24-character hexadecimal MongoDB Tag IDs.
          items:
            type: string
          example:
            - 65e0bc51c12e4d70834b070e
        customFields:
          type: array
          description: >-
            Complete list of custom fields to update/override. If a custom field
            is not supplied, its value is retained.
          items:
            $ref: '#/components/schemas/CustomFieldInput'
        dob:
          type: string
          format: date
          description: Date of Birth (YYYY-MM-DD)
          example: '1990-01-15'
        anniversary:
          type: string
          format: date
          description: Anniversary date (YYYY-MM-DD)
          example: '2020-06-20'
    Contact:
      type: object
      properties:
        id:
          type: string
          description: Unique MongoDB ID of the contact
          example: 65e0bc51c12e4d70834b070e
        firstName:
          type: string
          description: Contact's first name
          example: John
        lastName:
          type: string
          description: Contact's last name
          example: Doe
        chatName:
          type: string
          description: Formatted name used in active chats
          example: John Doe
        email:
          type: string
          format: email
          description: Contact's email address
          example: john.doe@example.com
        phoneNumber:
          type: string
          description: Contact's phone number without country code
          example: '9876543210'
        countryCode:
          type: string
          description: Contact's telephone country code
          example: '+91'
        source:
          type: string
          description: >-
            How the contact was entered into the system (e.g. `manual`,
            `import`, `widget`, `whatsapp`)
          example: manual
        subscribed:
          type: boolean
          description: WhatsApp subscription status
          example: true
        tagsId:
          type: array
          description: List of tag IDs assigned to this contact
          items:
            type: string
          example:
            - 65e0bc51c12e4d70834b070e
        tags:
          type: array
          description: Detailed metadata of tags assigned to this contact
          items:
            $ref: '#/components/schemas/ContactTag'
        customFields:
          type: array
          description: Detailed custom field values assigned to this contact
          items:
            type: object
            properties:
              id:
                type: string
                description: Custom field identifier
                example: 65f12ab3c9e4f1a2b3c4d5e6
              label:
                type: string
                description: Friendly name of the custom field
                example: Company Name
              value:
                description: Value associated with this custom field for this contact
                example: Google Deepmind
        dob:
          type: string
          format: date
          description: Date of Birth (ISO 8601 YYYY-MM-DD)
          example: '1990-01-15'
        anniversary:
          type: string
          format: date
          description: Anniversary date (ISO 8601 YYYY-MM-DD)
          example: '2020-06-20'
        workspaceId:
          type: integer
          description: Multi-tenant workspace ID ownership
          example: 246
        createdBy:
          type: string
          description: ID of the user who created this contact
          example: 6996aeeedf12574080a99d81
        createdAt:
          type: string
          format: date-time
          description: Timestamp when contact was created
          example: '2026-05-18T15:00:00.000Z'
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when contact was last updated
          example: '2026-05-18T15:05:00.000Z'
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: error
        code:
          type: integer
          example: 400
        message:
          type: string
          example: 'Invalid input: field first_name is required.'
        error:
          description: Optional validation error details or raw stack traces.
        timestamp:
          type: string
          format: date-time
          example: '2026-05-18T15:00:00.000Z'
    CustomFieldInput:
      type: object
      required:
        - fieldId
        - value
      properties:
        fieldId:
          type: string
          description: 24-character hex ID of the custom field defined in the workspace.
          example: 65f12ab3c9e4f1a2b3c4d5e6
        value:
          description: >-
            New value to assign. Supports strings, numbers, booleans, or dates
            based on the custom field definition.
          example: Enterprise
    ContactTag:
      type: object
      properties:
        tagId:
          type: string
          description: Unique ID of the tag
          example: 65e0bc51c12e4d70834b070e
        name:
          type: string
          description: Friendly tag name
          example: VIP
        text_color:
          type: string
          description: Hex text color code
          example: '#ffffff'
        background_color:
          type: string
          description: Hex background color code
          example: '#ef4444'
  responses:
    UnauthorizedError:
      description: Unauthorized (missing or invalid API key / JWT token)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            code: 401
            message: >-
              Unauthorized access: Invalid or missing authentication
              credentials.
            timestamp: '2026-05-18T15:00:00.000Z'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````