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

# List Coupons

> Learn how to list coupons from a store using the endpoint GET /stores/{storeId}/coupons.

## 📌 Endpoint

`GET /stores/{storeId}/coupons`

Lists the store coupons (not expired).

Coupons are returned in `position` order (ascending).

***

## 🔐 Authentication

* **Private route**.
* Requires header `Authorization` with your API key and active plan.

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

***

## 🧾 Route parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `storeId` | string | Yes | Store ID |

***

## ✅ Example request

```bash theme={null}
curl -X GET "https://api.cabrapi.com.br/v1/stores/STORE_ID/coupons?page=1&limit=20" \
	-H "Authorization: YOUR_API_KEY_HERE"
```

***

## 🔎 Query params

| Parameter | Type | Required | Description |
| - | - | - | - |
| `page` | number | No | Current page (default: `1`) |
| `limit` | number | No | Items per page (default: `20`, max: `100`) |
| `cursor` | string | No | Opaque cursor for cursor-based pagination. Use the `nextCursor` from the previous response. Cannot be used together with `page` |

***

## 🔄 Cursor pagination

For large lists (more than \~100 items), prefer **cursor** pagination instead of `page`:

1. Make the first call **without** `cursor`.
2. If `hasMore` is `true`, the response includes the `nextCursor` field.
3. Send that `nextCursor` in the `cursor` parameter of the next request to fetch the next page.

```bash theme={null}
curl -X GET "https://api.cabrapi.com.br/v1/stores/STORE_ID/coupons?cursor=v1:YOUR_CURSOR_HERE&limit=20" \
	-H "Authorization: YOUR_API_KEY_HERE"
```

In cursor mode, pagination is returned only with `nextCursor`, `hasMore` and `limit`:

```json theme={null}
{
	"code": "COUPONS_FETCHED",
	"coupons": [],
	"pagination": {
		"nextCursor": "v1:e2xFn...",
		"hasMore": true,
		"limit": 20
	}
}
```

* `cursor` and `page` **cannot** be used together (`400 INVALID_PAGINATION`).
* `nextCursor: null` with `hasMore: false` indicate the end of the list (only cursor mode responds `200` with an empty array `[]`; offset mode with `page` returns `404 COUPONS_NOT_FOUND` when total is `0`).

***

## Standard snippet (cURL)

Use the cURL example from the Request example section above as the official snippet.

***

## 📦 Success response (200)

```json theme={null}
{
	"code": "COUPONS_FETCHED",
	"coupons": [
		{
			"id": "COUPON_ID",
			"code": "bemvindo10",
			"discount": 10,
			"position": 1,
			"useLimit": -1,
			"rules": [],
			"expiredAt": null,
			"storeId": "STORE_ID",
			"createdAt": "2026-09-08T19:30:00Z",
			"updatedAt": "2026-09-08T19:30:00Z",
			"products": [
				{ "id": "PRODUCT_ID", "name": "Curso Premium" }
			],
			"categories": []
		}
	],
	"pagination": {
		"page": 1,
		"limit": 20,
		"total": 1,
		"totalPages": 1,
		"nextCursor": null,
		"hasMore": false
	}
}
```

> The first call (without `cursor`) already returns `nextCursor` and `hasMore` in the pagination, allowing cursor pagination to start without extra calls.

***

## ⚠️ Possible errors

* `400 INVALID_DATA` → invalid parameters
* `400 INVALID_PAGINATION_LIMIT` → `limit` outside the allowed range (`1` to `100`)
* `400 INVALID_PAGINATION_PAGE` → invalid `page`
* `400 INVALID_PAGINATION_CURSOR` → invalid or malformed `cursor`
* `400 INVALID_PAGINATION` → `page` and `cursor` used together
* `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
* `404 COUPONS_NOT_FOUND` → no coupons found (returned in offset mode when total is `0`; only cursor mode returns `200` with `[]`)
* `429 RATE_LIMIT_EXCEEDED` → per-minute rate limit exceeded
* `500 INTERNAL_SERVER_ERROR` → internal error
* `503 SERVICE_UNAVAILABLE` → service unavailable


## OpenAPI

````yaml GET /stores/{storeId}/coupons
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/coupons:
    get:
      tags:
        - Coupons
      summary: List coupons
      operationId: listCoupons
      parameters:
        - $ref: '#/components/parameters/StoreId'
        - in: query
          name: page
          schema:
            default: 1
            minimum: 1
            type: integer
        - in: query
          name: limit
          schema:
            default: 20
            maximum: 100
            minimum: 1
            type: integer
        - description: Opaque cursor from previous page (do not combine with page).
          in: query
          name: cursor
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: COUPONS_FETCHED
                    type: string
                  coupons:
                    type: array
                    items:
                      $ref: '#/components/schemas/Coupon'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                required:
                  - code
                  - coupons
                  - pagination
                type: object
          description: List coupons.
        '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:
    Coupon:
      description: Store discount coupon.
      properties:
        categories:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        code:
          type: string
        createdAt:
          format: date-time
          type: string
        discount:
          type: integer
        expiredAt:
          format: date-time
          nullable: true
          type: string
        id:
          format: uuid
          type: string
        position:
          type: integer
        products:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        rules:
          items:
            properties:
              type:
                enum:
                  - SINGLE_USE_PER_CUSTOMER
                  - MIN_ORDER_AMOUNT
                  - AFFILIATE_ONLY
                  - MIN_ITEMS_QUANTITY
                  - PAYMENT_METHOD
                type: string
              value: {}
            required:
              - type
            type: object
          nullable: false
          type: array
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
        useLimit:
          type: integer
      required:
        - id
        - code
        - discount
        - position
        - useLimit
        - storeId
        - createdAt
        - updatedAt
        - products
        - categories
        - rules
        - expiredAt
      type: object
    Pagination:
      properties:
        hasMore:
          type: boolean
        limit:
          type: integer
        nextCursor:
          nullable: true
          type: string
        page:
          type: integer
        total:
          type: integer
        totalPages:
          type: integer
      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.