# Account

From the Lero API docs: https://lero.studio/docs/en#grupo-conta. Everything in one file: https://lero.studio/docs/en/llms-full.txt.

The account credits.

### Credits left

`GET /v1/balance`

The account credits right now, with this month's allowance, and the plan. Free.

Authentication: key.

Response headers:

- `X-Creditos-Restantes` (integer): The account balance.

Responses:

- `200`: The balance and the plan.
- `401`: `sem_chave`
- `401`: `chave_invalida`
- `401`: `chave_vencida`
- `403`: `plano`
- `403`: `bloqueado`

cURL:

```bash
curl "https://app.lero.studio/api/v1/balance" \
  -H "Authorization: Bearer $LERO_API_KEY"
```

Python:

```python
import os

import requests

r = requests.get(
    "https://app.lero.studio/api/v1/balance",
    headers={"Authorization": f"Bearer {os.environ['LERO_API_KEY']}"},
    timeout=30,
)
r.raise_for_status()
print(r.json())
```

JavaScript:

```javascript
const res = await fetch("https://app.lero.studio/api/v1/balance", {
  headers: { "Authorization": `Bearer ${process.env.LERO_API_KEY}` },
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.erro}`);
console.log(data);
```

Response (200):

```json
{
  "saldo": 1499955,
  "plano": "Dev"
}
```
