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

# Reordenar Productos

> Aprenda a reordenar los productos de la tienda usando el endpoint PUT /stores/{storeId}/products/reorder.

## 📌 Endpoint

`PUT /stores/{storeId}/products/reorder`

Reordena los productos de la tienda según la secuencia enviada en `productIds`.

***

## 🔐 Autenticación

* Ruta privada.
* Envíe `Authorization` con su API Key.

***

## 🧾 Parámetros de ruta

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

***

## 🧍 Body

| Campo | Tipo | Obligatorio | Reglas |
| - | - | - | - |
| `productIds` | string\[] | Sí | array con UUIDs válidos y únicos de los productos de la tienda, en el orden final |

***

## ✅ Ejemplo de petición

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/stores/STORE_ID/products/reorder" \
  -H "Authorization: TU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "productIds": [
      "PRODUCT_ID_3",
      "PRODUCT_ID_1",
      "PRODUCT_ID_2"
    ]
  }'
```

***

## 📦 Respuesta exitosa (200)

```json theme={null}
{
  "code": "PRODUCTS_REORDERED"
}
```

***

## ⚠️ Posibles errores

* `400 INVALID_DATA` → payload inválido, array vacío, IDs duplicados o elementos que no son UUIDs válidos
* `400 PRODUCT_LIST_INVALID` → uno o más IDs no pertenecen a la tienda
* `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)
* `404 STORE_NOT_FOUND` → tienda no encontrada o sin permiso
* `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

***

## 📝 Observaciones

* El endpoint `GET /stores/{storeId}/products` devuelve los productos ordenados por `position`.
* El frontend debe enviar la lista completa de IDs en el orden final para garantizar consistencia.


## OpenAPI

````yaml PUT /stores/{storeId}/products/reorder
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/products/reorder:
    put:
      tags:
        - Products
      summary: Reorder products
      operationId: reorderProducts
      parameters:
        - $ref: '#/components/parameters/StoreId'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                productIds:
                  items:
                    format: uuid
                    type: string
                  minItems: 1
                  type: array
                  uniqueItems: true
              required:
                - productIds
              type: object
        description: Ordered product IDs.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: PRODUCTS_REORDERED
                    type: string
                required:
                  - code
                type: object
          description: Positions updated in provided order.
        '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:
    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.