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

# Update the tags of a contact

> Links and unlinks tags of a contact. Each tag is referenced by `id` or by `name`.

Unlike the `tags` field of `PATCH /contacts/{contactId}`, a tag referenced by `name` is created when it does not exist yet, and referencing an `id` that does not exist in the workspace returns `404`.

When `set` is provided it replaces all tags of the contact and `add`/`remove` are ignored. At most 10 tags per field.



## OpenAPI

````yaml PATCH /contacts/{contactId}/tags
openapi: 3.1.0
info:
  title: Cogfy Messenger Public API
  version: 1.0.0
  description: API for interacting with the Cogfy Messenger platform
servers:
  - url: https://messenger-public-api.cogfy.com
    description: Production server
  - url: http://localhost:3100
    description: Local server
security:
  - ApiKeyAuth: []
paths:
  /contacts/{contactId}/tags:
    patch:
      tags:
        - Contacts
      summary: Update the tags of a contact
      description: >-
        Links and unlinks tags of a contact. Each tag is referenced by `id` or
        by `name`.


        Unlike the `tags` field of `PATCH /contacts/{contactId}`, a tag
        referenced by `name` is created when it does not exist yet, and
        referencing an `id` that does not exist in the workspace returns `404`.


        When `set` is provided it replaces all tags of the contact and
        `add`/`remove` are ignored. At most 10 tags per field.
      parameters:
        - in: path
          name: contactId
          schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                add:
                  description: Tags to link to the contact, keeping the current ones
                  maxItems: 10
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        description: Id of an existing tag
                        type: string
                        format: uuid
                        pattern: >-
                          ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                      name:
                        description: >-
                          Name of the tag. The tag is created when it does not
                          exist yet
                        type: string
                        minLength: 1
                remove:
                  description: Tags to unlink from the contact
                  maxItems: 10
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        description: Id of an existing tag
                        type: string
                        format: uuid
                        pattern: >-
                          ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                      name:
                        description: >-
                          Name of the tag. The tag is created when it does not
                          exist yet
                        type: string
                        minLength: 1
                set:
                  description: >-
                    Replaces all tags of the contact. When provided, `add` and
                    `remove` are ignored
                  maxItems: 10
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        description: Id of an existing tag
                        type: string
                        format: uuid
                        pattern: >-
                          ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                      name:
                        description: >-
                          Name of the tag. The tag is created when it does not
                          exist yet
                        type: string
                        minLength: 1
            examples:
              addAndRemove:
                summary: Add and remove tags
                value:
                  add:
                    - name: customers
                  remove:
                    - id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
              set:
                summary: Replace all tags
                value:
                  set:
                    - name: customers
                    - name: vip
      responses:
        '204':
          description: Tags updated successfully
        '400':
          description: Bad request, invalid input data
        '401':
          description: Unauthorized
        '404':
          description: Contact or tag not found
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

````