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

# Filter Payments

> Learn how to filter payments by payment fields and metadata using the endpoint GET /stores/{storeId}/payments/filter.

## 📌 Endpoint

`GET /stores/{storeId}/payments/filter`

Filters payments of a store with support for pagination, sorting and metadata filters.

***

## 🔐 Authentication

Private route.

Send the `Authorization` header with your API key and active plan.

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

***

## 🧾 Route parameter

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

***

## 🔎 Query params

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | No | Payment ID |
| `uuid` | string | No | Payment UUID |
| `status` | string | No | `PENDING`, `APPROVED`, `REJECTED`, `CANCELLED`, `REFUNDED`, `CHARGED_BACK`, `EXPIRED` |
| `name` | string | No | Buyer name (contains) |
| `email` | string | No | Buyer email (contains) |
| `cpf` | string | No | CPF (contains) |
| `price` | number | No | Exact price |
| `minPrice` | number | No | Minimum price |
| `maxPrice` | number | No | Maximum price |
| `coupon` | boolean | No | Filters payments with or without coupon |
| `gateway` | string | No | `MERCADOPAGO`, `ASAAS`, `EFI_BANK` or `STRIPE` |
| `shipment` | string | No | `PENDING`, `PREPARING`, `SHIPPED`, `DELIVERED`, `RETURNED`, `CANCELLED` |
| `createdAtFrom` | string (RFC3339) | No | Initial creation timestamp in RFC3339/ISO-8601 format with timezone (e.g., `2026-09-08T00:00:00Z`) |
| `createdAtTo` | string (RFC3339) | No | Final creation timestamp in RFC3339/ISO-8601 format with timezone (e.g., `2026-09-08T23:59:59Z`) |
| `updatedAtFrom` | string (RFC3339) | No | Initial update timestamp in RFC3339/ISO-8601 format with timezone (e.g., `2026-09-08T00:00:00Z`) |
| `updatedAtTo` | string (RFC3339) | No | Final update timestamp in RFC3339/ISO-8601 format with timezone (e.g., `2026-09-08T23:59:59Z`) |
| `productId` | string | No | Filters purchases containing a specific product |
| `metadataKey` | string | No | Path of the key in metadata (accepts nested path with `.`) |
| `metadataValue` | string | No | Value searched in metadata |
| `sortBy` | string | No | `createdAt`, `updatedAt`, `price`, `name`, `email` |
| `sortOrder` | string | No | `asc` or `desc` |
| `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. Only supported with `sortBy=createdAt` (default). Cannot be used together with `page` |

***

## 🔄 Cursor pagination

For large lists (more than \~100 items), prefer **cursor** pagination instead of `page`. The cursor is supported **only** when `sortBy=createdAt` (default):

1. Make the first call **without** `cursor`.
2. If `hasMore` is `true`, the response contains 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/payments/filter?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` (without `total`/`totalPages`):

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

* `cursor` and `page` **cannot** be used together (`400 INVALID_PAGINATION`).
* Using `cursor` with a `sortBy` other than `createdAt` returns `400 INVALID_CURSOR_SORT`.
* `nextCursor: null` with `hasMore: false` indicate the end of the list (the API responds `200` with an empty array).
* Very broad metadata filters may still return `422 FILTER_TOO_BROAD`.

***

## ✅ Example request

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

***

## 🧠 Nested metadata example

Filter by `metadata.items[0].product.sold = 19`:

```bash theme={null}
curl -X GET "https://api.cabrapi.com.br/v1/stores/STORE_ID/payments/filter?gateway=MERCADOPAGO&metadataKey=items.0.product.sold&metadataValue=19&limit=1" \
  -H "Authorization: YOUR_API_KEY_HERE"
```

***

## 📦 Success response (200)

```json theme={null}
{
  "code": "PAYMENTS_FILTERED",
  "payments": [
    {
      "id": "PAYMENT_ID",
      "uuid": "8cf7de6e-4c92-4baf-b978-2f9195f2e0e2",
      "status": "APPROVED",
      "name": "Sebastian Jn",
      "email": "sebastianjnuwu@gmail.com",
      "cpf": "12345678909",
      "price": 49.9,
      "coupon": false,
      "gateway": "MERCADOPAGO",
      "shipment": "PENDING",
      "metadata": {
        "items": [
          {
            "product": {
              "id": "PRODUCT_ID",
              "name": "Curso de Marketing",
              "position": 1,
              "description": "Aprenda marketing digital",
              "price": 49.9,
              "image": "https://cdn.cabrapi.com.br/imagem.jpg",
              "delivery": "DIGITAL",
              "stock": 100,
              "sold": 19,
              "storeId": "STORE_ID",
              "disabled": false,
              "metadata": {},
              "createdAt": "2026-01-01T10:00:00Z",
              "updatedAt": "2026-01-01T10:00:00Z",
              "categories": []
            },
            "quantity": 1,
            "price": 49.9,
            "coupon": null,
            "billingCycleMonths": null
          }
        ],
        "gateway": {
          "Type": "MERCADOPAGO",
          "Method": "MERCADOPAGO_ORDER_PIX",
          "Payment": "PIX",
          "FeePercentage": 0,
          "FeeAmount": 0
        }
      },
      "affiliateCode": null,
      "storeId": "STORE_ID",
      "createdAt": "2026-09-08T19:30:00Z",
      "updatedAt": "2026-09-08T19:30:00Z",
      "products": [
        {
          "id": "PRODUCT_ID",
          "name": "Curso de Marketing",
          "price": 49.9,
          "image": "https://cdn.cabrapi.com.br/imagem.jpg",
          "description": "Aprenda marketing digital"
        }
      ],
      "affiliateCommission": null
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 1,
    "total": 38,
    "totalPages": 38,
    "nextCursor": "v1:e2xFn...",
    "hasMore": true
  }
}
```

> 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 (including timestamps not in RFC3339/ISO-8601 format)
* `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
* `400 INVALID_CURSOR_SORT` → `cursor` used with a `sortBy` other than `createdAt`
* `401 API_KEY_NOT_PROVIDED` → missing `Authorization` header
* `401 INVALID_API_KEY` → invalid API key
* `401 UNAUTHENTICATED` → unauthenticated user
* `403 USER_DISABLED` → user disabled or deleted
* `403 NO_ACTIVE_SUBSCRIPTION` → inactive or expired plan
* `404 STORE_NOT_FOUND` → store not found or does not belong to the account
* `422 FILTER_TOO_BROAD` → metadata filter too broad; refine `metadataKey`/`metadataValue`
* `429 RATE_LIMIT_EXCEEDED` → plan per-minute rate limit exceeded
* `500 INTERNAL_SERVER_ERROR` → internal error
* `503 SERVICE_UNAVAILABLE` → service temporarily unavailable


## OpenAPI

````yaml GET /stores/{storeId}/payments/filter
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/payments/filter:
    get:
      tags:
        - Payments
      summary: Filter payments
      operationId: filterPayments
      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; only
            valid when sortBy=createdAt).
          in: query
          name: cursor
          schema:
            type: string
        - in: query
          name: id
          schema:
            format: uuid
            type: string
        - in: query
          name: uuid
          schema:
            format: uuid
            type: string
        - in: query
          name: name
          schema:
            type: string
        - in: query
          name: email
          schema:
            format: email
            type: string
        - in: query
          name: cpf
          schema:
            type: string
        - in: query
          name: status
          schema:
            enum:
              - PENDING
              - APPROVED
              - REJECTED
              - CANCELLED
              - REFUNDED
              - CHARGED_BACK
              - EXPIRED
            type: string
        - in: query
          name: price
          schema:
            type: number
        - in: query
          name: minPrice
          schema:
            type: number
        - in: query
          name: maxPrice
          schema:
            type: number
        - in: query
          name: coupon
          schema:
            type: boolean
        - in: query
          name: gateway
          schema:
            enum:
              - MERCADOPAGO
              - EFI_BANK
              - ASAAS
              - STRIPE
            type: string
        - in: query
          name: shipment
          schema:
            enum:
              - PENDING
              - PREPARING
              - SHIPPED
              - DELIVERED
              - RETURNED
              - CANCELLED
            type: string
        - in: query
          name: createdAtFrom
          schema:
            format: date-time
            type: string
        - in: query
          name: createdAtTo
          schema:
            format: date-time
            type: string
        - in: query
          name: updatedAtFrom
          schema:
            format: date-time
            type: string
        - in: query
          name: updatedAtTo
          schema:
            format: date-time
            type: string
        - in: query
          name: productId
          schema:
            format: uuid
            type: string
        - in: query
          name: metadataKey
          schema:
            type: string
        - in: query
          name: metadataValue
          schema:
            type: string
        - in: query
          name: sortBy
          schema:
            default: createdAt
            enum:
              - createdAt
              - updatedAt
              - price
              - name
              - email
            type: string
        - in: query
          name: sortOrder
          schema:
            default: desc
            enum:
              - asc
              - desc
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: PAYMENTS_FILTERED
                    type: string
                  payments:
                    type: array
                    items:
                      $ref: '#/components/schemas/Payment'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                required:
                  - code
                  - payments
                  - pagination
                type: object
          description: Filter payments.
        '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.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Filter too broad (metadata scan limit exceeded).
        '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:
    Payment:
      description: Store payment/charge.
      properties:
        affiliateCode:
          nullable: true
          type: string
        affiliateCommission:
          nullable: true
          type: object
          properties:
            code:
              type: string
            name:
              type: string
            email:
              nullable: true
              type: string
            value:
              type: number
          required:
            - code
            - name
            - value
        coupon:
          type: boolean
        cpf:
          nullable: true
          type: string
        createdAt:
          format: date-time
          type: string
        email:
          format: email
          type: string
        gateway:
          type: string
        id:
          format: uuid
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        price:
          type: number
        products:
          items:
            properties:
              description:
                nullable: true
                type: string
              id:
                format: uuid
                type: string
              image:
                nullable: true
                type: string
              name:
                type: string
              price:
                type: number
            required:
              - id
              - name
              - price
            type: object
          type: array
        shipment:
          enum:
            - PENDING
            - PREPARING
            - SHIPPED
            - DELIVERED
            - RETURNED
            - CANCELLED
          type: string
        status:
          enum:
            - PENDING
            - APPROVED
            - REJECTED
            - CANCELLED
            - REFUNDED
            - CHARGED_BACK
            - EXPIRED
          type: string
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
        uuid:
          format: uuid
          type: string
      required:
        - id
        - uuid
        - status
        - name
        - email
        - price
        - coupon
        - gateway
        - shipment
        - storeId
        - createdAt
        - updatedAt
        - products
      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.