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

# Get Transaction History

> This endpoint retrieves the user's credit transaction history.

## GET /credits/history

This endpoint returns a list of the authenticated user's credit transactions, including purchases, usage, and refunds. Requires session-based authentication (JWT access token).

<Note>
  **For third-party integrations:** Use `GET /credits/history/api` with API Key authentication instead.
</Note>

### Query Parameters

<ParamField query="limit" type="number" default="20">
  Number of transactions to return (max 100).
</ParamField>

<ParamField query="offset" type="number" default="0">
  Number of transactions to skip for pagination.
</ParamField>

<ParamField query="type" type="string">
  Filter by transaction type: `purchase`, `usage`, or `refund`.
</ParamField>

### Response

<ResponseField name="transactions" type="array">
  An array of transaction objects.

  <Expandable title="transaction properties">
    <ResponseField name="id" type="string">
      The unique identifier for the transaction.
    </ResponseField>

    <ResponseField name="type" type="string">
      The type of transaction: `purchase`, `usage`, or `refund`.
    </ResponseField>

    <ResponseField name="amount" type="number">
      The number of credits (positive for additions, negative for usage).
    </ResponseField>

    <ResponseField name="description" type="string">
      A description of the transaction.
    </ResponseField>

    <ResponseField name="siteId" type="string">
      The associated site ID (for usage transactions).
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of the transaction.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="number">
  Total number of transactions.
</ResponseField>

<ResponseField name="hasMore" type="boolean">
  Whether there are more transactions to fetch.
</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

This endpoint returns the user's credit transaction history using API Key authentication. Ideal for third-party integrations.

### Authentication

Requires API Key authentication. Include your API key in the `Authorization` header:

```
Authorization: Bearer llmgen_your_api_key_here
```

### Query Parameters

Same as `/credits/history` above.

### Response

Same as `/credits/history` above.

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