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

# Get Categories

> Learn how to list a store’s categories using the GET /stores/{storeId}/categories endpoint.

## 📌 Endpoint

`GET /stores/{storeId}/categories`

Returns all categories of a store.

Categories are returned in `position` order (ascending), ideal for building menus/listings in the frontend.

***

## 🔐 Authentication

* **Public route** for queries.
* The store linked to `storeId` must have an active plan.

***

## 🧾 Route parameters

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

***

## ✅ Request example

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

***

## 🔎 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 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/categories?cursor=v1:YOUR_CURSOR_HERE&limit=20"
```

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

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

* `cursor` and `page` **cannot** be used together (`400 INVALID_PAGINATION`).
* When there are no categories, **offset** mode (without `cursor`) returns `404 CATEGORIES_NOT_FOUND`, whereas **cursor** mode returns `200` with `categories: []`, `nextCursor: null`, and `hasMore: false`.
* `nextCursor: null` with `hasMore: false` indicate the end of the list (the API responds `200` with an empty array).

***

## 📦 Success response (200)

```json theme={null}
{
	"code": "CATEGORIES_FETCHED",
	"categories": [
		{
			"id": "c6f0d28a-8ce2-4a8f-9771-4df1f2a7f3a1",
			"name": "Eletrônicos",
			"description": "Produtos eletrônicos em geral",
			"image": null,
			"metadata": {
				"featured": true,
				"slug": "eletronicos"
			},
			"position": 1,
			"storeId": "STORE_ID",
			"createdAt": "2026-03-02T20:00:00.000Z",
			"updatedAt": "2026-03-02T20:00:00.000Z"
		}
	],
	"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 parameter
* `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 UNAUTHENTICATED` → could not identify the subscription user
* `403 NO_ACTIVE_SUBSCRIPTION` → inactive or expired plan
* `404 STORE_NOT_FOUND` → store not found
* `404 CATEGORIES_NOT_FOUND` → no categories found (returned only in offset mode when `total` is `0`; cursor mode returns `200` with `[]`)
* `429 RATE_LIMIT_EXCEEDED` → rate limit per minute exceeded
* `500 INTERNAL_SERVER_ERROR` → internal server error
* `503 SERVICE_UNAVAILABLE` → service or database unavailable


## OpenAPI

````yaml GET /stores/{storeId}/categories
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/categories:
    get:
      tags:
        - Categories
      summary: List categories
      operationId: listCategories
      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: CATEGORIES_FETCHED
                    type: string
                  categories:
                    type: array
                    items:
                      $ref: '#/components/schemas/Category'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                required:
                  - code
                  - categories
                  - pagination
                type: object
          description: List categories.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Unauthorized (missing store owner or unavailable database).
        '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: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Category:
      description: Store product category.
      properties:
        createdAt:
          format: date-time
          type: string
        description:
          nullable: true
          type: string
        id:
          format: uuid
          type: string
        image:
          nullable: true
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        position:
          type: integer
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - name
        - position
        - storeId
        - createdAt
        - updatedAt
      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

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.