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

> Aprenda a reordenar lojas da conta usando o endpoint PUT /stores/reorder.

## 📌 Endpoint

`PUT /stores/reorder`

Reordena as lojas da conta autenticada de acordo com a sequencia enviada em `storeIds`.

***

## 🔐 Autenticação

* Rota privada.
* Envie `Authorization` com sua API Key.

***

## 🧍 Body

| Campo | Tipo | Obrigatório | Regras |
| - | - | - | - |
| `storeIds` | string\[] | Sim | array com IDs unicos das lojas da conta, na ordem final |

***

## ✅ Exemplo de requisição

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/stores/reorder" \
  -H "Authorization: SUA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "storeIds": [
      "STORE_ID_3",
      "STORE_ID_1",
      "STORE_ID_2"
    ]
  }'
```

***

## 📦 Resposta de sucesso (200)

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

***

## ⚠️ Possíveis erros

* `400 INVALID_DATA` → payload inválido
* `400 STORE_LIST_INVALID` → um ou mais IDs não pertencem à conta
* `401 API_KEY_NOT_PROVIDED` → header `Authorization` não enviado
* `401 INVALID_API_KEY` → API Key inválida ou não encontrada
* `401 UNAUTHENTICATED` → sessão/usuário não autenticado
* `403 USER_DISABLED` → conta do usuário desativada ou excluída
* `403 NO_ACTIVE_SUBSCRIPTION` → conta sem plano ativo
* `429 RATE_LIMIT_EXCEEDED` → limite de requisições por minuto do plano excedido
* `500 INTERNAL_SERVER_ERROR` → erro interno
* `503 SERVICE_UNAVAILABLE` → serviço temporariamente indisponível

***

## 📝 Observações

* O endpoint `GET /stores` retorna as lojas ordenadas por `position`.
* O frontend deve enviar a lista completa de IDs na ordem final para garantir consistência.


## OpenAPI

````yaml PUT /stores/reorder
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/reorder:
    put:
      tags:
        - Stores
      summary: Reorder stores
      operationId: reorderStores
      requestBody:
        content:
          application/json:
            schema:
              properties:
                storeIds:
                  items:
                    format: uuid
                    type: string
                  minItems: 1
                  type: array
                  uniqueItems: true
              required:
                - storeIds
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: STORES_REORDERED
                    type: string
                required:
                  - code
                type: object
          description: Positions updated in provided order.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: INVALID_DATA, STORE_LIST_INVALID
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: API_KEY_NOT_PROVIDED, INVALID_API_KEY, UNAUTHENTICATED
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: USER_DISABLED, NO_ACTIVE_SUBSCRIPTION
        '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:
  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.