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

# Update Category

> Learn how to update a store category using the endpoint PUT /stores/{storeId}/categories/{categoryId}.

## 📌 Endpoint

`PUT /stores/{storeId}/categories/{categoryId}`

Updates the data of an existing category.

***

## 🔐 Authentication

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

***

## 🧾 Route parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `storeId` | string | Yes | ID of the store |
| `categoryId` | string | Yes | ID of the category |

***

## 🧾 Body

> Send only the fields you want to change.

| Field | Type | Required | Rules |
| - | - | - | - |
| `name` | string | No | 4 to 32 characters |
| `description` | string | No | 12 to 256 characters |
| `image` | string | No | URL between 12 and 512 chars |
| `metadata` | json | No | free JSON object |
| `position` | number | No | integer greater than or equal to 1 |

***

## ✅ Example request

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/stores/STORE_ID/categories/CATEGORY_ID" \
	-H "Authorization: YOUR_API_KEY" \
	-H "Content-Type: application/json" \
	-d '{
		"name": "Premium Electronics",
		"description": "Updated category",
		"metadata": {
			"featured": false,
			"slug": "premium-electronics"
		}
	}'
```

***

## 📦 Success response (200)

```json theme={null}
{
	"code": "CATEGORY_UPDATED",
	"category": {
		"id": "CATEGORY_ID",
		"name": "Premium Electronics",
		"description": "Updated category",
		"image": null,
		"metadata": {
			"featured": false,
			"slug": "premium-electronics"
		},
		"position": 2,
		"storeId": "STORE_ID",
		"createdAt": "2026-03-02T20:00:00.000Z",
		"updatedAt": "2026-03-02T21:00:00.000Z"
	}
}
```

***

## ⚠️ Possible errors

* `400 INVALID_DATA` → empty/invalid payload or invalid parameters
* `400 INVALID_DATA_NAME_MIN` → `name` 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 INVALID_DATA_POSITION` → `position` less than `1`
* `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 STORE_NOT_FOUND` → store not found or no permission
* `404 CATEGORY_NOT_FOUND` → category not found
* `429 RATE_LIMIT_EXCEEDED` → rate limit per minute exceeded
* `500 INTERNAL_SERVER_ERROR` → internal error
* `503 SERVICE_UNAVAILABLE` → service or database unavailable


## OpenAPI

````yaml PUT /stores/{storeId}/categories/{categoryId}
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/categories/{categoryId}:
    put:
      tags:
        - Categories
      summary: Update category
      operationId: updateCategory
      parameters:
        - $ref: '#/components/parameters/StoreId'
        - $ref: '#/components/parameters/CategoryId'
      requestBody:
        required: true
        description: Category fields to update.
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  maxLength: 32
                  minLength: 4
                  type: string
                description:
                  maxLength: 256
                  minLength: 12
                  type: string
                image:
                  maxLength: 512
                  minLength: 12
                  type: string
                metadata:
                  type: object
                position:
                  minimum: 1
                  type: integer
              minProperties: 1
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: CATEGORY_UPDATED
                    type: string
                  category:
                    $ref: '#/components/schemas/Category'
                required:
                  - code
                  - category
                type: object
          description: Update 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
    CategoryId:
      in: path
      name: categoryId
      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.