# API: Credits

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/credits` | The credit balance, today's top-up limit, auto top-up and agent top-up settings, and the free-model daily allowance | `billing:read` |
| POST | `/v1/credits/checkout` | Add credits (owners): returns a secure payment page to open. Credits arrive when the payment is confirmed; a bank transfer takes a few days (web app only) | `billing:write` |
| PUT | `/v1/credits/controls` | Owners, in the web app: auto top-up (off by default; a balance to top up at, an amount and a monthly limit), agent top-ups (off by default, with a monthly limit), the low-balance notice amount, or forget the saved card (web app only) | `billing:write` |
| POST | `/v1/credits/invoice` | Owners, in the web app: add credits on an invoice (accounts with payment terms). The invoice is emailed, with your purchase order number and tax IDs; the credits arrive when it's issued (web app only) | `billing:write` |
| GET | `/v1/credits/invoicing` | Whether this account can add credits on an invoice: its payment terms (net days), its limit on unpaid invoices, what's owed now and whether any invoice is past due | `billing:read` |
| GET | `/v1/credits/quote` | What a top-up costs: the credits, the fee (4.5% by card with an 80-cent minimum, 1% by bank transfer) and the total charged (no sign-in) | — |
| GET | `/v1/credits/tax-ids` | The tax IDs printed on this account's invoices and receipts | `billing:read` |
| POST | `/v1/credits/tax-ids` | Owners, in the web app: add a tax ID to print on invoices (a VAT number, an EIN and the like) (web app only) | `billing:write` |
| DELETE | `/v1/credits/tax-ids/:id` | Owners, in the web app: remove a tax ID from future invoices (web app only) | `billing:write` |
| GET | `/v1/credits/topups` | Top-ups, newest first: credits, fee, total, status and the receipt link | `billing:read` |
| POST | `/v1/credits/topups` | For agents: add credits by charging the organization's saved card, within the monthly limit an owner set for agent top-ups. Refused when agent top-ups are off, over the limit, or no card is saved | `billing:topup` |
| GET | `/v1/credits/topups/:id` | One top-up: its status, credits, fee, total and receipt link | `billing:read` |

## Examples

### GET /v1/credits

The credit balance, today's top-up limit, auto top-up and agent top-up settings, and the free-model daily allowance

```bash
curl -s "https://manage.restolayer.com/v1/credits" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/credits/invoicing

Whether this account can add credits on an invoice: its payment terms (net days), its limit on unpaid invoices, what's owed now and whether any invoice is past due

```bash
curl -s "https://manage.restolayer.com/v1/credits/invoicing" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits/invoicing`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/credits/quote

What a top-up costs: the credits, the fee (4.5% by card with an 80-cent minimum, 1% by bank transfer) and the total charged. No sign-in, so it sends no key.

```bash
curl -s "https://manage.restolayer.com/v1/credits/quote"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits/quote`, {
  method: "GET",
});
const data = await res.json();
```

### GET /v1/credits/tax-ids

The tax IDs printed on this account's invoices and receipts

```bash
curl -s "https://manage.restolayer.com/v1/credits/tax-ids" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits/tax-ids`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/credits/topups

Top-ups, newest first: credits, fee, total, status and the receipt link

```bash
curl -s "https://manage.restolayer.com/v1/credits/topups" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits/topups`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/credits/topups

For agents: add credits by charging the organization's saved card, within the monthly limit an owner set for agent top-ups. Refused when agent top-ups are off, over the limit, or no card is saved

```bash
curl -s -X POST "https://manage.restolayer.com/v1/credits/topups" \
  -H "Authorization: Bearer $LG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits/topups`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### GET /v1/credits/topups/$ID

One top-up: its status, credits, fee, total and receipt link

```bash
curl -s "https://manage.restolayer.com/v1/credits/topups/$ID" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/credits/topups/${id}`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

Request and response schemas: [https://www.restolayer.com/openapi.json](https://www.restolayer.com/openapi.json). All resources: [API reference](https://www.restolayer.com/docs/api).
