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

# Historial de transacciones

> Este extremo devuelve el historial de transacciones de créditos del usuario.

## GET /credits/history

Este extremo devuelve la lista de transacciones de créditos del usuario autenticado, incluidas compras, uso y reembolsos. Requiere autenticación por sesión (token de acceso JWT).

<Note>
  **Para integraciones de terceros:** use `GET /credits/history/api` con autenticación por clave API.
</Note>

### Parámetros de consulta

<ParamField query="limit" type="number" default="20">
  Número de transacciones a devolver (máx. 100).
</ParamField>

<ParamField query="offset" type="number" default="0">
  Número de transacciones a omitir para la paginación.
</ParamField>

<ParamField query="type" type="string">
  Filtro por tipo de transacción: `purchase`, `usage` o `refund`.
</ParamField>

### Respuesta

<ResponseField name="transactions" type="array">
  Lista de objetos de transacción.

  <Expandable title="Propiedades de la transacción">
    <ResponseField name="id" type="string">
      Identificador único de la transacción.
    </ResponseField>

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

    <ResponseField name="amount" type="number">
      Cantidad de créditos (positiva si se añaden, negativa si son consumo).
    </ResponseField>

    <ResponseField name="description" type="string">
      Descripción de la transacción.
    </ResponseField>

    <ResponseField name="siteId" type="string">
      Identificador del sitio asociado (en transacciones de uso).
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      Marca de tiempo ISO 8601 de la transacción.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="number">
  Número total de transacciones.
</ResponseField>

<ResponseField name="hasMore" type="boolean">
  Indica si hay más transacciones disponibles.
</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 Success (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 extremo devuelve el historial de créditos del usuario mediante autenticación por clave API. Adecuado para integraciones de terceros.

### Autenticación

Requiere autenticación por clave API. Incluya su clave en el encabezado `Authorization`:

```
Authorization: Bearer llmgen_your_api_key_here
```

### Parámetros de consulta

Igual que `/credits/history` arriba.

### Respuesta

Igual que `/credits/history` arriba.

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