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

# Reorder Coupons

> Learn how to reorder store coupons using the endpoint PUT /stores/{storeId}/coupons/reorder.

## 📌 Endpoint

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

Reorders the store coupons according to the sequence sent in `couponIds`.

***

## 🔐 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 |
| - | - | - | - |
| `couponIds` | string\[] | Yes | array with valid, unique UUIDs of the store's coupons, in the final order |

***

## ✅ Example request

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/stores/STORE_ID/coupons/reorder" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "couponIds": [
      "COUPON_ID_3",
      "COUPON_ID_1",
      "COUPON_ID_2"
    ]
  }'
```

***

## 📦 Success response (200)

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

***

## ⚠️ Possible errors

* `400 INVALID_DATA` → invalid payload or elements that are not valid UUIDs
* `400 COUPON_LIST_INVALID` → one or more IDs do not belong to the store
* `401 API_KEY_NOT_PROVIDED` → `Authorization` header not provided
* `401 INVALID_API_KEY` → invalid API key
* `401 UNAUTHENTICATED` → unauthenticated user
* `403 USER_DISABLED` → user disabled
* `403 NO_ACTIVE_SUBSCRIPTION` → no active plan
* `404 STORE_NOT_FOUND` → store not found or no permission
* `429 RATE_LIMIT_EXCEEDED` → per-minute rate limit exceeded
* `500 INTERNAL_SERVER_ERROR` → internal error
* `503 SERVICE_UNAVAILABLE` → service unavailable

***

## 📝 Notes

* The endpoint `GET /stores/{storeId}/coupons` returns the coupons ordered by `position`.
* The frontend must send the complete list of IDs in the final order to ensure consistency.


## OpenAPI

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