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

# Toggle Contact Tag

> Attach or detach a tag from a contact. If the tag is already attached, it will be detached, and vice versa.

### JSON Example

```json theme={null}
{
  "tag_id": 3
}
```

***

### 📝 Field Requirements

| Field    | Type    | Required | Notes                                             |
| -------- | ------- | -------- | ------------------------------------------------- |
| `tag_id` | integer | Yes      | ID of the tag to toggle (must exist in workspace) |

***

### 🔄 Behavior

This endpoint toggles a tag on a contact:

* If the tag is **not** currently assigned to the contact, it will be **added**
* If the tag is **already** assigned to the contact, it will be **removed**

### ✅ Success Response

```json theme={null}
{
  "status": 200,
  "message": "Contact tag toggled successfully",
  "data": null
}
```


## OpenAPI

````yaml POST /workspaces/{workspace}/contacts/{contact}/toggle-tag
openapi: 3.1.0
info:
  title: Lancepilot API
  description: API for Lancepilot
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: https://lancepilot.com/api/v3
security:
  - bearerAuth: []
paths:
  /workspaces/{workspace}/contacts/{contact}/toggle-tag:
    post:
      tags:
        - Contacts
      summary: Toggle Tag on Contact
      description: >-
        Attach or detach a tag from a contact. If the tag is already attached,
        it will be detached, and vice versa.
      parameters:
        - name: workspace
          in: path
          description: ID of the workspace.
          required: true
          schema:
            type: string
            format: uuid
        - name: contact
          in: path
          description: ID of the contact.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tag_id
              properties:
                tag_id:
                  type: integer
                  description: ID of the tag to toggle.
            examples:
              toggle:
                summary: Toggle Tag
                value:
                  tag_id: 1
      responses:
        '200':
          description: Tag toggled successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 200
                  message:
                    type: string
                    example: Contact tag toggled successfully
                  data:
                    type: 'null'
        '401':
          $ref: '#/components/responses/401'
        '404':
          $ref: '#/components/responses/404'
        '422':
          $ref: '#/components/responses/422'
components:
  responses:
    '401':
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: Unauthenticated.
            required:
              - message
    '404':
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: Resource not found.
              status:
                type: integer
                example: 404
            required:
              - message
              - status
    '422':
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: Validation error
              errors:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````