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

# Credits

> Check the remaining credit balance and usage for your account.

## Authentication

Requires an API key in the `Authorization` header.

```bash theme={"dark"}
Authorization: Bearer YOUR_API_KEY
```

## Request

No parameters required. The balance is scoped to the API key's active workspace
when one is selected, otherwise to the key owner's account.

```bash theme={"dark"}
curl https://encrata.com/api/agent/credits \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Response

<ResponseField name="credits_remaining" type="number">
  Credits currently available to spend.
</ResponseField>

<ResponseField name="credits_used" type="number">
  Total credits consumed to date.
</ResponseField>

<ResponseField name="total_lookups" type="number">
  Total number of lookups performed to date.
</ResponseField>

## Errors

Errors return a JSON body of the form `{"error": "<message>"}` with the matching
HTTP status code.

| Status | Message                            | Cause                      |
| ------ | ---------------------------------- | -------------------------- |
| `401`  | `unauthorized` / `invalid API key` | Missing or invalid API key |
| `405`  | `Only GET method is allowed`       | Wrong HTTP method          |

<ResponseExample>
  ```json 200 theme={"dark"}
  {
    "credits_remaining": 4794,
    "credits_used": 206,
    "total_lookups": 206
  }
  ```

  ```json 401 theme={"dark"}
  { "error": "invalid API key" }
  ```
</ResponseExample>
