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

# PATCH /v1/crm/tags/:id

> Rename a tag, change its color, or move it to another category.

Updates a tag in place. Tickets and customers reference tags by id, so a rename shows up everywhere the tag is applied. The `scope` cannot change.

## Endpoint

```
PATCH https://api.keebai.com/v1/crm/tags/{id}
```

## Required scope

`crm:tags:write`

## Headers

| Header | Required | Value |
| - | - | - |
| `Authorization` | Yes | `Bearer kbai_pk_<token>` |
| `Content-Type` | Yes | `application/json` |

## Path parameters

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | `ObjectId` of the tag. |

## Body

All fields optional. Send only what changes.

| Field | Type | Description |
| - | - | - |
| `name` | `string` | New name. Up to 100 characters. Unique per scope within the company. |
| `color` | `string` | Hex color. |
| `category_id` | `string` \| `null` | `ObjectId` of a category of the same scope. Send `null` to remove the tag from its category. |

## Example request

```bash curl theme={"system"}
curl -X PATCH https://api.keebai.com/v1/crm/tags/6720a1b2c3d4e5f6a7b8c9d0 \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{ "name": "VIP", "category_id": null }'
```

```js JavaScript theme={"system"}
const response = await fetch(`https://api.keebai.com/v1/crm/tags/${tagId}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "VIP", category_id: null }),
});
const { tag } = await response.json();
```

```python Python theme={"system"}
import os, requests

resp = requests.patch(
    f"https://api.keebai.com/v1/crm/tags/{tag_id}",
    headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
    json={"name": "VIP", "category_id": None},
    timeout=10,
)
resp.raise_for_status()
tag = resp.json()["tag"]
```

## Response

### 200 OK

```json theme={"system"}
{
  "tag": {
    "_id": "6720a1b2c3d4e5f6a7b8c9d0",
    "name": "VIP",
    "color": "#f5a623",
    "scope": "ticket",
    "category_id": null,
    "created_at": "2026-10-02T13:04:11.512Z",
    "updated_at": "2026-11-18T15:22:40.031Z"
  }
}
```

### 400 Bad Request

* Another tag of the same scope already has that `name` (`Tag name already exists for this scope`).
* The category belongs to the other scope (`Tag scope must match its category scope`).
* An empty `name`, a malformed `category_id`, or a property the endpoint does not accept — including `scope`.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `crm:tags:write` scope.

### 404 Not Found

No tag with that id in your company (`Tag not found`), or `category_id` does not match a category of your company (`Tag category not found`).


## OpenAPI

````yaml PATCH /v1/crm/tags/{id}
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/crm/tags/{id}:
    patch:
      tags:
        - crm-tags
      summary: Actualizar una etiqueta
      description: Cambia nombre, color o categoría. El scope no se puede cambiar.
      operationId: PublicTagsController_update
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicTagUpdateDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicTagEnvelopeDto'
      security:
        - PAT: []
components:
  schemas:
    PublicTagUpdateDto:
      type: object
      properties:
        name:
          type: string
          description: Nuevo nombre, único por scope.
        color:
          type: string
          description: Color hexadecimal.
        category_id:
          type: string
          nullable: true
          description: >-
            Categoría de la etiqueta, del mismo scope. `null` la deja sin
            categoría.
    PublicTagEnvelopeDto:
      type: object
      properties:
        tag:
          $ref: '#/components/schemas/PublicTagResponseDto'
      required:
        - tag
    PublicTagResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: ObjectId de la etiqueta
        name:
          type: string
        color:
          type: string
          example: '#1890ff'
        scope:
          type: string
          enum:
            - ticket
            - client
        category_id:
          type: string
          nullable: true
          description: ObjectId de la categoría, o `null` si no tiene.
        category:
          nullable: true
          description: >-
            Resumen de la categoría. Sólo viene en el listado; el detalle trae
            `category_id`.
          type: object
          allOf:
            - $ref: '#/components/schemas/PublicTagCategorySummaryDto'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - name
        - color
        - scope
        - category_id
        - created_at
        - updated_at
    PublicTagCategorySummaryDto:
      type: object
      properties:
        id:
          type: string
          description: ObjectId de la categoría
        name:
          type: string
        exclusive:
          type: boolean
      required:
        - id
        - name
        - exclusive
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````

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