> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flarepayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Listar Transações

> Retorna o histórico de cobranças e saques com filtros e paginação

## Descrição

Retorna uma lista paginada de transações (cobranças e saques) com suporte a filtros por tipo, status e data.

***

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token de autenticação. Formato: `Bearer sk_live_xxx`
</ParamField>

***

## Query Parameters

<ParamField query="limit" type="integer" default="10">
  Quantidade de resultados (mín: 1, máx: 100)
</ParamField>

<ParamField query="starting_after" type="string">
  Cursor de paginação: ID da última transação da página anterior
</ParamField>

<ParamField query="type" type="string">
  Filtrar por tipo: `charge` ou `withdrawal`
</ParamField>

<ParamField query="status" type="string">
  Filtrar por status: `pending`, `paid`, `expired`, `failed`, `processing`
</ParamField>

<ParamField query="created[gte]" type="string">
  Data mínima de criação (ISO 8601)
</ParamField>

<ParamField query="created[lte]" type="string">
  Data máxima de criação (ISO 8601)
</ParamField>

***

## Exemplo de Requisição

<CodeGroup>
  ```bash cURL theme={null}
  # Listar as últimas 20 cobranças pagas
  curl "https://api.flarepayments.com/v1/transactions?limit=20&type=charge&status=paid" \
    -H "Authorization: Bearer sk_live_sua_chave_aqui"
  ```

  ```bash Paginação theme={null}
  # Próxima página após o último ID retornado
  curl "https://api.flarepayments.com/v1/transactions?limit=10&starting_after=ch_flare_dc7dc11b7f984d2886d2b429" \
    -H "Authorization: Bearer sk_live_sua_chave_aqui"
  ```

  ```javascript Node.js theme={null}
  const params = new URLSearchParams({
    limit: '20',
    type: 'charge',
    status: 'paid',
    'created[gte]': '2026-03-01T00:00:00Z',
    'created[lte]': '2026-03-31T23:59:59Z'
  });

  const response = await fetch(
    `https://api.flarepayments.com/v1/transactions?${params}`,
    { headers: { 'Authorization': 'Bearer sk_live_sua_chave_aqui' } }
  );
  const { data, has_more } = await response.json();
  ```
</CodeGroup>

***

## Resposta `200 OK`

<ResponseField name="object" type="string">
  Sempre `"list"`
</ResponseField>

<ResponseField name="data" type="array">
  Lista de transações
</ResponseField>

<ResponseField name="has_more" type="boolean">
  `true` se existem mais resultados
</ResponseField>

<ResponseField name="url" type="string">
  URL do endpoint
</ResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "object": "list",
    "data": [
      {
        "id": "ch_flare_dc7dc11b7f984d2886d2b429",
        "object": "charge",
        "amount": 10.00,
        "amount_cents": 1000,
        "currency": "BRL",
        "status": "paid",
        "description": "Pedido #1234",
        "customer": {
          "name": "João Silva",
          "email": "joao@email.com"
        },
        "fee": {
          "amount": 0.50,
          "net_amount": 9.50
        },
        "created_at": "2026-03-05T18:14:48.552Z",
        "paid_at": "2026-03-05T18:16:22.000Z",
        "livemode": true
      }
    ],
    "has_more": true,
    "url": "/v1/transactions"
  }
  ```
</ResponseExample>

***

## Paginação

A API usa **cursor-based pagination** com o campo `starting_after`:

```javascript theme={null}
// Buscar todas as transações automaticamente
async function buscarTodasTransacoes() {
  const transacoes = [];
  let cursor = null;

  do {
    const params = new URLSearchParams({ limit: '100' });
    if (cursor) params.set('starting_after', cursor);

    const res = await fetch(`https://api.flarepayments.com/v1/transactions?${params}`, {
      headers: { 'Authorization': 'Bearer sk_live_xxx' }
    });
    const { data, has_more } = await res.json();

    transacoes.push(...data);
    cursor = has_more ? data[data.length - 1].id : null;
  } while (cursor);

  return transacoes;
}
```

<Note>
  Quando `has_more` é `true`, existem mais resultados. Use o `id` da última transação retornada como `starting_after` para buscar a próxima página.
</Note>
