# get\_\_credits\_transactions

`GET /credits/transactions`

*Get Credit Transaction History*

Returns a paginated list of credit transactions for the authenticated user's organization. Each transaction is either a credit in (purchase, grant) or a credit out (consumption). Optional filters include direction, date range, and repository.

#### TypeScript Client Library

```typescript
public getCreditsTransactions = async (query: GetCreditsTransactionsRequest): Promise<GetCreditsTransactionsResponse> => {
  return this.makeRequest<GetCreditsTransactionsResponse>('credits/transactions', 'GET', query);
};
```

#### Code Samples

{% tabs %}
{% tab title="Shell" %}

```shell
# All params optional
curl -X GET 'https://backend.flashback.tech/credits/transactions?page=1&limit=20&direction=out' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
GET https://backend.flashback.tech/credits/transactions?page=1&limit=20&direction=out HTTP/1.1
Host: backend.flashback.tech
Accept: application/json
Authorization: Bearer {access-token}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const params = new URLSearchParams({ page: '1', limit: '20', direction: 'out' });
const headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
};

fetch(`https://backend.flashback.tech/credits/transactions?${params}`, { method: 'GET', headers })
  .then(res => res.json())
  .then(body => console.log(body));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}
params = { 'page': 1, 'limit': 20, 'direction': 'out' }

r = requests.get('https://backend.flashback.tech/credits/transactions', headers=headers, params=params)
print(r.json())
```

{% endtab %}
{% endtabs %}

> Example responses

> 200 Response

```json
{
  "success": true,
  "data": [
    {
      "id": "tx-uuid-1",
      "creditAmount": -12.5,
      "createdAt": "2026-01-30T10:00:00.000Z",
      "description": "Storage egress: 1.25 GB on public node",
      "type": "consumption",
      "rateType": "Public Node",
      "rateConcept": "Per GB Egress",
      "rateUsed": 10,
      "repoId": "repo-uuid",
      "unitId": "unit-uuid",
      "host": "us-east-1-gcp.flashback.tech"
    },
    {
      "id": "tx-uuid-2",
      "creditAmount": 1100,
      "createdAt": "2026-01-15T00:00:00.000Z",
      "description": "Credit pack purchase: Pack 1 (1100 credits)",
      "type": "purchase",
      "packName": "Pack 3"
    }
  ],
  "pagination": {
    "total": 42,
    "page": 1,
    "limit": 20
  }
}
```

> 400 Response

```json
{
  "success": false,
  "error_code": "CREDITS_NOT_ENABLED",
  "message": "Credits system is not enabled"
}
```

> 500 Response

```json
{
  "success": false,
  "error_code": "INTERNAL_ERROR",
  "message": "Failed to retrieve credit transactions"
}
```

#### Query Parameters

| Name        | Type               | Required | Description                            |
| ----------- | ------------------ | -------- | -------------------------------------- |
| » page      | integer            | false    | Page number (default: 1)               |
| » limit     | integer            | false    | Items per page (default: 50)           |
| » direction | string             | false    | `in`, `out`, or `all` (default: `all`) |
| » startDate | string (date-time) | false    | Filter transactions from this date     |
| » endDate   | string (date-time) | false    | Filter transactions until this date    |
| » repoId    | string             | false    | Filter by repository ID                |

#### Responses

| Status | Meaning               | Description                            | Schema |
| ------ | --------------------- | -------------------------------------- | ------ |
| 200    | OK                    | Paginated transaction list             | Inline |
| 400    | Bad Request           | Credits not enabled or no organization | Inline |
| 404    | Not Found             | User not found                         | Inline |
| 500    | Internal Server Error | Server error                           | Inline |

#### Response Schema (200)

| Name                | Type               | Required | Description                                    |
| ------------------- | ------------------ | -------- | ---------------------------------------------- |
| » success           | boolean            | false    | Whether the request succeeded                  |
| » data              | array              | false    | List of transactions                           |
| »» id               | string             | false    | Transaction ID                                 |
| »» creditAmount     | number             | false    | Amount (negative = consumption, positive = in) |
| »» createdAt        | string (date-time) | false    | When the transaction was created               |
| »» description      | string \| null     | false    | Human-readable description                     |
| »» type             | string             | false    | `consumption`, `purchase`, or `grant`          |
| »» rateType         | string             | false    | For consumption: rate type name                |
| »» rateConcept      | string             | false    | For consumption: rate concept name             |
| »» rateUsed         | number             | false    | For consumption: rate applied                  |
| »» repoId           | string             | false    | For consumption: repository ID                 |
| »» unitId           | string             | false    | For consumption: unit or AI LLM ID             |
| »» host             | string             | false    | For consumption: host                          |
| »» llmType          | string             | false    | For AI consumption                             |
| »» llmModel         | string             | false    | For AI consumption                             |
| »» subscriptionName | string             | false    | For grants: subscription name                  |
| »» packName         | string             | false    | For purchases: pack name                       |
| » pagination        | object             | false    | Pagination info                                |
| »» total            | integer            | false    | Total number of transactions                   |
| »» page             | integer            | false    | Current page                                   |
| »» limit            | integer            | false    | Page size                                      |
| » error\_code       | string             | false    | Set on error                                   |
| » message           | string             | false    | Error or status message                        |

#### Security

* **BearerAuth**: Bearer token required.
* **Organization**: Results are scoped to the user's organization.

#### Notes

* Use `direction=out` to get only consumption (e.g. for consumption breakdown). The client method `getCreditsConsumption(query)` calls this endpoint with `direction: 'out'`.
* Consumption items include rate and repo/unit/host (and llmType/llmModel for AI). Purchase/grant items include subscription or pack name.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flashback.tech/support-reference/platform-api-reference/credits/get__credits_transactions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
