# Get the credit balance

`GET https://evohub.io/api/v1/billing/credit`

Part of the [Billing API](https://docs.evohub.io/billing.md) reference · operationId `getCredit`.

The organization's prepaid EHU balance, the price per EHU for a
bundle (after any offer agreed for the organization), the smallest
bundle that can be bought, the suggested bundle sizes, and the last
50 movements on the balance, newest first.

Credit is used before the card: a statement draws on it after the
free allowance. Bought credit never expires; credit given by EvoHub
(a campaign or a goodwill grant) may, at `expires_at`.
`can_purchase` is `false` while there is no saved card. Bundles are
bought in the console.

Requires the `billing:usage:read` scope.

## Authorization

Any one of:

- `bearerKey`
- `headerKey`

Where:

- `bearerKey`: HTTP Bearer — An EvoHub API key (`evohub_…`) as a bearer token.
- `headerKey`: API key in the header `X-API-Key` — An EvoHub API key (`evohub_…`).

## Responses

### 200 — The credit balance.

Content type: `application/json`

Type: `object`

- `data` (CreditSummary)
  - `balance_ehu` (number)
  - `usd_per_ehu` (number): The bundle price per EHU.
  - `minimum_ehu` (number): The smallest bundle that can be bought.
  - `presets` (array of number): Suggested bundle sizes, in EHU.
  - `entries` (array of CreditEntry): The last 50 movements, newest first.
    - `id` (integer)
    - `org_id` (string)
    - `kind` (string, one of `purchase`, `grant`, `consumption`, `adjustment`): `purchase`: a bundle bought. `grant`: credit given by EvoHub. `consumption`: a statement drew on the balance (negative). `adjustment`: a correction.
    - `ehu` (number): Positive adds to the balance, negative spends it.
    - `usd_paid` (number): What was paid, for a purchase.
    - `reason` (string)
    - `granted_by` (string): Who at EvoHub gave a grant. Left out for anything automatic.
    - `stripe_ref` (string): The payment a purchase was made with.
    - `receipt_url` (string (uri))
    - `invoice_url` (string (uri))
    - `invoice_pdf_url` (string (uri))
    - `period_start` (string (date-time)): The statement that consumed it, for a consumption.
    - `expires_at` (string (date-time)): When given credit stops counting. Bought credit never expires.
    - `created_at` (string (date-time))
  - `can_purchase` (boolean): `false` while no card is saved.

### 401 — No API key was sent, or it is unknown, revoked or expired (`UNAUTHORIZED`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `STATEMENT_NOT_FOUND`)
  - `message` (string, required, example `No statement for that period.`)
  - `request_id` (string)

### 403 — The key lacks the scope this endpoint needs (`FORBIDDEN`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `STATEMENT_NOT_FOUND`)
  - `message` (string, required, example `No statement for that period.`)
  - `request_id` (string)

### 429 — Too many requests (`RATE_LIMITED`). Wait for `Retry-After` seconds.

Headers:

- `Retry-After` (integer): Seconds to wait before retrying.

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `STATEMENT_NOT_FOUND`)
  - `message` (string, required, example `No statement for that period.`)
  - `request_id` (string)

### 500 — The balance could not be loaded (`CREDIT_UNAVAILABLE`). Retry later.

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `STATEMENT_NOT_FOUND`)
  - `message` (string, required, example `No statement for that period.`)
  - `request_id` (string)

## Example request

```bash
curl -X GET 'https://evohub.io/api/v1/billing/credit' \
  -H 'Authorization: Bearer <TOKEN>'
```
