> ## 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.

# POST /v1/crm/tag-categories

> Create a category to group tags of one scope.

Creates a tag category. Assign tags to it with `category_id` when you [create](https://docs.keebai.com/dev/endpoints/crm-tag-create.md) or [update](https://docs.keebai.com/dev/endpoints/crm-tag-update.md) them; a tag and its category must share the same scope.

The `company` and `project` are taken from your token and must **not** appear in the body. Sending them returns `400`.

## Endpoint

```
POST https://api.keebai.com/v1/crm/tag-categories
```

## Required scope

`crm:tags:write`

## Headers

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

## Body

| Field | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | Category name. Up to 100 characters. Unique per scope within the company. |
| `scope` | `string` | Yes | `ticket` or `client`. |
| `exclusive` | `boolean` | No | When `true`, a record carries at most one tag of this category. Defaults to `false`. |
| `order` | `integer` | No | Position in lists, `0` or more. Defaults to `0`. |

## Example request

```bash curl theme={"system"}
curl -X POST https://api.keebai.com/v1/crm/tag-categories \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Segmento", "scope": "ticket", "exclusive": true }'
```

```js JavaScript theme={"system"}
const response = await fetch("https://api.keebai.com/v1/crm/tag-categories", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "Segmento", scope: "ticket", exclusive: true }),
});
const { category } = await response.json();
```

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

resp = requests.post(
    "https://api.keebai.com/v1/crm/tag-categories",
    headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
    json={"name": "Segmento", "scope": "ticket", "exclusive": True},
    timeout=10,
)
resp.raise_for_status()
category = resp.json()["category"]
```

## Response

### 201 Created

```json theme={"system"}
{
  "category": {
    "_id": "6720a0f1e2d3c4b5a6978877",
    "name": "Segmento",
    "scope": "ticket",
    "exclusive": true,
    "order": 0,
    "created_at": "2026-10-02T12:58:03.114Z",
    "updated_at": "2026-10-02T12:58:03.114Z"
  }
}
```

### 400 Bad Request

* A category with the same `name` already exists in that scope (`Tag category name already exists for this scope`).
* Missing `name` or `scope`, a `scope` outside the allowed set, a negative `order`, or a property the endpoint does not accept — including `company` and `project`.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

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


## OpenAPI

````yaml POST /v1/crm/tag-categories
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/tag-categories:
    post:
      tags:
        - crm-tags
      summary: Crear una categoría de etiquetas
      description: >-
        La company y el project se toman del token. Un nombre que ya existe en
        el mismo scope devuelve 400.
      operationId: PublicTagCategoriesController_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicTagCategoryCreateDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicTagCategoryEnvelopeDto'
      security:
        - PAT: []
components:
  schemas:
    PublicTagCategoryCreateDto:
      type: object
      properties:
        name:
          type: string
          description: Nombre de la categoría. Único por scope dentro de la company.
        scope:
          type: string
          enum:
            - ticket
            - client
        exclusive:
          type: boolean
          default: false
          description: >-
            Si es `true`, un ticket o cliente lleva a lo más una etiqueta de
            esta categoría: agregar otra quita la anterior.
        order:
          type: number
          default: 0
          minimum: 0
      required:
        - name
        - scope
    PublicTagCategoryEnvelopeDto:
      type: object
      properties:
        category:
          $ref: '#/components/schemas/PublicTagCategoryResponseDto'
      required:
        - category
    PublicTagCategoryResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: ObjectId de la categoría
        name:
          type: string
        scope:
          type: string
          enum:
            - ticket
            - client
        exclusive:
          type: boolean
        order:
          type: number
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - name
        - scope
        - exclusive
        - order
        - created_at
        - updated_at
  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.