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

# Create Category

> Learn how to create a category in a store using the POST /stores/{storeId}/categories endpoint.

## 📌 Endpoint

`POST /stores/{storeId}/categories`

Creates a new category for the informed store.

***

## 🔐 Authentication

* **Private route**.
* Send `Authorization` with your API Key.

***

## 🧾 Route parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `storeId` | string | Yes | Store ID |

***

## 🧾 Body

| Field | Type | Required | Rules |
| - | - | - | - |
| `name` | string | Yes | 4 to 32 characters |
| `description` | string | No | 12 to 256 characters |
| `image` | string | No | URL (validates string length from 12 to 512 characters) |
| `metadata` | json | No | free-form JSON object |

***

## ✅ Request example

```bash theme={null}
curl -X POST "https://api.cabrapi.com.br/v1/stores/STORE_ID/categories" \
	-H "Authorization: YOUR_API_KEY" \
	-H "Content-Type: application/json" \
	-d '{
		"name": "Eletrônicos",
		"description": "Produtos eletrônicos em geral",
		"image": null,
		"metadata": {
			"featured": true,
			"slug": "eletronicos"
		}
	}'
```

***

## 📦 Success response (201)

```json theme={null}
{
	"code": "CATEGORY_CREATED",
	"category": {
		"id": "c6f0d28a-8ce2-4a8f-9771-4df1f2a7f3a1",
		"storeId": "STORE_ID",
		"name": "Eletrônicos",
		"description": "Produtos eletrônicos em geral",
		"image": null,
		"metadata": {
			"featured": true,
			"slug": "eletronicos"
		},
		"position": 1,
		"createdAt": "2026-03-02T20:00:00.000Z",
		"updatedAt": "2026-03-02T20:00:00.000Z"
	}
}
```

***

## ⚠️ Possible errors

* `400 INVALID_DATA` → invalid payload or `storeId`
* `400 INVALID_DATA_NAME_MIN` → `name` missing or shorter than 4 characters
* `400 INVALID_DATA_NAME_MAX` → `name` longer than 32 characters
* `400 INVALID_DATA_DESCRIPTION_MIN` → `description` shorter than 12 characters
* `400 INVALID_DATA_DESCRIPTION_MAX` → `description` longer than 256 characters
* `400 INVALID_DATA_IMAGE` → `image` outside 12 to 512 characters
* `400 NAME_ALREADY_EXISTS` → category with the same name
* `401 API_KEY_NOT_PROVIDED` → `Authorization` header not sent (or `TOKEN_NOT_PROVIDED` via Bearer)
* `401 INVALID_API_KEY` → invalid API Key (or `INVALID_TOKEN` / `TOKEN_EXPIRED` / `SESSION_NOT_FOUND` / `SESSION_EXPIRED` / `UNAUTHENTICATED` via Bearer)
* `403 USER_DISABLED` → user disabled or deleted
* `403 NO_ACTIVE_SUBSCRIPTION` → inactive or expired plan (or `PENDING_2FA` via Bearer)
* `403 CATEGORY_LIMIT_REACHED` → plan category limit reached
* `404 STORE_NOT_FOUND` → store not found
* `429 RATE_LIMIT_EXCEEDED` → rate limit per minute exceeded
* `500 INTERNAL_SERVER_ERROR` → internal server error
* `503 SERVICE_UNAVAILABLE` → service or database unavailable


## OpenAPI

````yaml POST /stores/{storeId}/categories
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/categories:
    post:
      tags:
        - Categories
      summary: Create category
      operationId: createCategory
      parameters:
        - $ref: '#/components/parameters/StoreId'
      requestBody:
        required: true
        description: Category details (name, description, image, metadata).
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  maxLength: 32
                  minLength: 4
                  type: string
                description:
                  maxLength: 256
                  minLength: 12
                  type: string
                  nullable: true
                image:
                  maxLength: 512
                  minLength: 12
                  type: string
                  nullable: true
                metadata:
                  nullable: true
                  type: object
      responses:
        '201':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: CATEGORY_CREATED
                    type: string
                  category:
                    $ref: '#/components/schemas/Category'
                required:
                  - code
                  - category
                type: object
          description: Create category.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid API key.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden (inactive plan or insufficient permissions).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Rate limit exceeded.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal server error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security:
        - ApiKey: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Category:
      description: Store product category.
      properties:
        createdAt:
          format: date-time
          type: string
        description:
          nullable: true
          type: string
        id:
          format: uuid
          type: string
        image:
          nullable: true
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        position:
          type: integer
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - name
        - position
        - storeId
        - createdAt
        - updatedAt
      type: object
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object
  securitySchemes:
    ApiKey:
      in: header
      name: Authorization
      type: apiKey
      x-default: YOUR_API_KEY_HERE

````

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