# Account

```http
GET https://api.qelka.com/v1/account
```

Returns the plan, credit balance and limits of the organization that owns the key, and describes the key itself. It takes no parameters and costs no credits.

Common uses:

- show your remaining balance in your own admin screens;
- warn before a large job if the balance is too low;
- check at startup that a service runs with the key and mode you expect;
- monitor the API from your side: a successful call proves that the network path, your key and the API all work, for free.

## Request

```bash
curl https://api.qelka.com/v1/account \
  -H "Authorization: Bearer $API_KEY"
```

```javascript
const response = await fetch('https://api.qelka.com/v1/account', {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
})
const account = await response.json()
```

## Response

```json
{
  "object": "account",
  "org": { "id": "org_01M84BDPNRQBDQEPZ7787ST5TH", "name": "Acme" },
  "plan": {
    "id": "starter",
    "interval": "month",
    "monthly_credits": 10000,
    "renews_at": "2026-12-23T00:00:00.000Z"
  },
  "credits": {
    "balance": 12450,
    "expiring": [
      { "credits": 2450, "expires_at": "2027-01-23T00:00:00.000Z" },
      { "credits": 10000, "expires_at": "2027-02-23T00:00:00.000Z" }
    ]
  },
  "limits": {
    "per_key": { "requests": 200, "window_seconds": 10 },
    "per_org": { "requests": 1000, "window_seconds": 60 }
  },
  "key": {
    "id": "key_01M84BDPNREK4SFJN6ECRF2HYK",
    "name": "signup-service-production",
    "mode": "live",
    "prefix": "sk_live_8Hq2"
  }
}
```

Values in the example are illustrative.

| Field | Type | Description |
|---|---|---|
| `object` | string | Always `account`. |
| `org` | object | The organization that owns the key. |
| `org.id` | string | Identifier of the organization. |
| `org.name` | string | Name of the organization. |
| `plan` | object | The current plan. |
| `plan.id` | string | `free`, `starter`, `growth`, `scale` or `business`. |
| `plan.interval` | string or null | `month` or `year` for a paid plan. Null on the free plan. |
| `plan.monthly_credits` | integer | Credits the plan grants each month. |
| `plan.renews_at` | string or null | When the paid subscription renews, ISO 8601 in UTC. Null on the free plan. |
| `credits` | object | Your credit balance. |
| `credits.balance` | integer | Credits available now, all sources combined. The same number as the `X-Credits-Remaining` header. |
| `credits.expiring` | array | Credits that have an expiry date, grouped by that date, soonest first: plan credits, which roll over until they expire, and credit packs. Empty when none do. Calls spend the credits that expire first. |
| `credits.expiring[].credits` | integer | Number of credits in this group. |
| `credits.expiring[].expires_at` | string | When they expire, ISO 8601 in UTC. |
| `limits` | object | Rate limits that apply to you. See [Rate limits](/docs/rate-limits). |
| `limits.per_key.requests` | integer | Requests allowed per key in each window. |
| `limits.per_key.window_seconds` | integer | Length of the per-key window, in seconds. |
| `limits.per_org.requests` | integer | Requests allowed for the whole organization in each window. |
| `limits.per_org.window_seconds` | integer | Length of the organization window, in seconds. |
| `key` | object | The key that made this call. |
| `key.id` | string | Identifier of the key. |
| `key.name` | string | The name given to the key when it was created. |
| `key.mode` | string | `live` or `test`. |
| `key.prefix` | string | The first characters of the key, as shown in the dashboard. Safe to log; the full key is not. |

The account never includes the full key: we do not have it. Only a SHA-256 hash of each live key is stored.

## Example: warn before a large job

```javascript
const response = await fetch('https://api.qelka.com/v1/account', {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
})
const { credits, key } = await response.json()

if (key.mode !== 'live') throw new Error('Bulk jobs need a live key')
const rows = 48210
if (credits.balance < rows) {
  console.warn(`The job needs ${rows} credits and the balance is ${credits.balance}.`)
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 401 | [invalid_api_key](/docs/errors#invalid_api_key) | The key is missing, invalid or revoked |
| 403 | [forbidden](/docs/errors#forbidden) | The key is restricted to other endpoints |
| 429 | [rate_limited](/docs/errors#rate_limited) | Too many requests; wait `Retry-After` seconds |
| 500 | [internal_error](/docs/errors#internal_error) | Unexpected error on our side; retry with backoff |

None of these responses is billed.
