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

# Histórico de transações

> Este endpoint retorna o histórico de transações de créditos do usuário.

## GET /credits/history

Este endpoint retorna a lista de transações de crédito do usuário autenticado (compras, uso e reembolsos). Exige autenticação por sessão (JWT).

<Note>
  **Para integrações de terceiros:** use `GET /credits/history/api` com autenticação por chave de API.
</Note>

### Parâmetros de consulta

<ParamField query="limit" type="number" default="20">
  Quantidade de transações a retornar (máximo 100).
</ParamField>

<ParamField query="offset" type="number" default="0">
  Quantidade de transações a ignorar (paginação).
</ParamField>

<ParamField query="type" type="string">
  Filtrar por tipo: `purchase`, `usage` ou `refund`.
</ParamField>

### Resposta

<ResponseField name="transactions" type="array">
  Lista de objetos de transação.

  <Expandable title="Propriedades da transação">
    <ResponseField name="id" type="string">
      Identificador único da transação.
    </ResponseField>

    <ResponseField name="type" type="string">
      Tipo: `purchase`, `usage` ou `refund`.
    </ResponseField>

    <ResponseField name="amount" type="number">
      Quantidade de créditos (positiva em inclusões, negativa em uso).
    </ResponseField>

    <ResponseField name="description" type="string">
      Descrição da transação.
    </ResponseField>

    <ResponseField name="siteId" type="string">
      ID do site associado (em transações de uso).
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      Data e hora em ISO 8601.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="number">
  Número total de transações.
</ResponseField>

<ResponseField name="hasMore" type="boolean">
  Se há mais transações para buscar.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.llmgenerator.com/api/v1/credits/history?limit=10" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.llmgenerator.com/api/v1/credits/history?limit=10&type=usage',
    {
      headers: { 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' }
    }
  );

  const history = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json Sucesso (200) theme={null}
  {
    "transactions": [
      {
        "id": "txn_abc123",
        "type": "purchase",
        "amount": 500,
        "description": "Purchased Professional Pack",
        "siteId": null,
        "createdAt": "2026-01-15T10:00:00.000Z"
      },
      {
        "id": "txn_def456",
        "type": "usage",
        "amount": -50,
        "description": "llms.txt generation for example.com (enhanced)",
        "siteId": "550e8400-e29b-41d4-a716-446655440000",
        "createdAt": "2026-01-20T14:30:00.000Z"
      },
      {
        "id": "txn_ghi789",
        "type": "usage",
        "amount": -25,
        "description": "llms.txt generation for another-site.com (simple)",
        "siteId": "660e8400-e29b-41d4-a716-446655440001",
        "createdAt": "2026-01-22T09:15:00.000Z"
      }
    ],
    "total": 47,
    "hasMore": true
  }
  ```
</ResponseExample>

***

## GET /credits/history/api

Este endpoint retorna o histórico com autenticação por chave de API. Indicado para integrações externas.

### Autenticação

```
Authorization: Bearer llmgen_your_api_key_here
```

### Parâmetros de consulta

Iguais aos de `/credits/history`, acima.

### Resposta

Igual à de `/credits/history`, acima.

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.llmgenerator.com/api/v1/credits/history/api?limit=10" \
    -H "Authorization: Bearer llmgen_your_api_key_here"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.llmgenerator.com/api/v1/credits/history/api?limit=10&type=usage',
    {
      headers: { 'Authorization': 'Bearer llmgen_your_api_key_here' }
    }
  );

  const history = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.llmgenerator.com/api/v1/credits/history/api',
      headers={'Authorization': 'Bearer llmgen_your_api_key_here'},
      params={'limit': 10, 'type': 'usage'}
  )

  history = response.json()
  ```
</RequestExample>
