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

# Crear Producto

> Aprenda a crear productos usando el endpoint POST /stores/{storeId}/products.

## 📌 Endpoint

`POST /stores/{storeId}/products`

Crea un nuevo producto en la tienda.

***

## 🔐 Autenticación

* **Ruta privada**.
* Requiere header `Authorization` con tu API key y plan activo.

```json theme={null}
{
	"Authorization": "TU_API_KEY_AQUI"
}
```

***

## 🧾 Parámetros de ruta

| Parámetro | Tipo | Obligatorio | Descripción |
| - | - | - | - |
| `storeId` | string | Sí | ID de la tienda |

***

## 🧍 Body (JSON)

| Campo | Tipo | Obligatorio | Reglas |
| - | - | - | - |
| `name` | string | Sí | 3-32 caracteres |
| `image` | string | No | URL, hasta 512 |
| `description` | string | No | 12-256 caracteres |
| `categoryIds` | string\[] | No | IDs de categorías de la propia tienda |
| `delivery` | string | Sí | `DIGITAL` o `PHYSICAL` |
| `price` | number | Sí | 0.5 hasta 9999 |
| `stock` | number | No | entero, -1 a 9999 (`-1` ilimitado, predeterminado `0`) |
| `disabled` | boolean | No | predeterminado `false` |
| `metadata` | object | No | objeto libre |

***

## ✅ Ejemplo de petición

```bash theme={null}
curl -X POST "https://api.cabrapi.com.br/v1/stores/STORE_ID/products" \
	-H "Authorization: TU_API_KEY_AQUI" \
	-H "Content-Type: application/json" \
	-d '{
		"name": "Curso Premium",
		"description": "Acesso completo ao conteúdo.",
		"delivery": "DIGITAL",
		"price": 49.9,
		"stock": 100,
		"disabled": false,
		"categoryIds": ["CATEGORY_ID"]
	}'
```

***

## Snippet estándar (cURL)

Use el ejemplo cURL de la sección Ejemplo de petición anterior como snippet oficial.

***

## 📦 Respuesta exitosa (200)

```json theme={null}
{
	"code": "SUCCESS",
	"product": {
		"id": "PRODUCT_ID",
		"name": "Curso Premium",
		"position": 1,
		"description": "Acesso completo ao conteúdo.",
		"price": 49.9,
		"image": null,
		"delivery": "DIGITAL",
		"stock": 100,
		"sold": 0,
		"storeId": "STORE_ID",
		"disabled": false,
		"metadata": null,
		"createdAt": "2026-03-02T20:00:00.000Z",
		"updatedAt": "2026-03-02T20:00:00.000Z",
		"categories": [
			{
				"id": "CATEGORY_ID",
				"name": "Cursos"
			}
		]
	}
}
```

***

## ⚠️ Posibles errores

* `400 INVALID_DATA` → body o `storeId` inválido
* `400 INVALID_DATA_NAME_MIN` → `name` ausente o con menos de 3 caracteres
* `400 INVALID_DATA_NAME_MAX` → `name` con más de 32 caracteres
* `400 INVALID_DATA_IMAGE` → `image` con más de 512 caracteres
* `400 INVALID_DATA_DESCRIPTION_MIN` → `description` con menos de 12 caracteres
* `400 INVALID_DATA_DESCRIPTION_MAX` → `description` con más de 256 caracteres
* `400 INVALID_DATA_DELIVERY` → `delivery` ausente o distinto de `DIGITAL`/`PHYSICAL`
* `400 INVALID_DATA_PRICE` → `price` ausente o fuera del intervalo `0.5` a `9999`
* `400 INVALID_DATA_STOCK` → `stock` fuera del intervalo `-1` a `9999`
* `400 INVALID_DATA_CATEGORY_ID` → algún elemento en `categoryIds` vacío o con más de 50 caracteres
* `400 RELATION_NOT_FOUND` → una o más categorías en `categoryIds` no existen en la tienda
* `400 NAME_ALREADY_EXISTS` → ya existe un producto con ese nombre
* `401 API_KEY_NOT_PROVIDED` → header `Authorization` no enviado (o `TOKEN_NOT_PROVIDED` vía Bearer)
* `401 INVALID_API_KEY` → API Key inválida (o `INVALID_TOKEN` / `TOKEN_EXPIRED` / `SESSION_NOT_FOUND` / `SESSION_EXPIRED` / `UNAUTHENTICATED` vía Bearer)
* `403 USER_DISABLED` → usuario desactivado o eliminado
* `403 NO_ACTIVE_SUBSCRIPTION` → plan inactivo o expirado (o `PENDING_2FA` vía Bearer)
* `403 PRODUCT_LIMIT_REACHED` → límite de productos del plan alcanzado
* `404 STORE_NOT_FOUND` → tienda no encontrada
* `429 RATE_LIMIT_EXCEEDED` → límite de solicitudes por minuto excedido
* `500 INTERNAL_SERVER_ERROR` → error interno
* `503 SERVICE_UNAVAILABLE` → servicio o base de datos no disponible


## OpenAPI

````yaml POST /stores/{storeId}/products
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/products:
    post:
      tags:
        - Products
      summary: Create product
      operationId: createProduct
      parameters:
        - $ref: '#/components/parameters/StoreId'
      requestBody:
        content:
          application/json:
            schema:
              description: Fields documented on the reference page.
              type: object
        description: Product details (name, price, stock, categories).
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: SUCCESS
                    type: string
                  product:
                    $ref: '#/components/schemas/Product'
                required:
                  - code
                  - product
                type: object
          description: Create product.
        '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:
    Product:
      description: Store product.
      properties:
        categories:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        createdAt:
          format: date-time
          type: string
        delivery:
          enum:
            - DIGITAL
            - PHYSICAL
          type: string
        description:
          nullable: true
          type: string
        disabled:
          type: boolean
        id:
          format: uuid
          type: string
        image:
          nullable: true
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        position:
          type: integer
        price:
          type: number
        sold:
          type: integer
        stock:
          type: integer
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - name
        - position
        - price
        - delivery
        - stock
        - sold
        - storeId
        - disabled
        - createdAt
        - updatedAt
        - categories
      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.