# Spend through the API

> Review API run counts, failures and spending over the last 7 or 30 days.

Source: https://docs.fous.com/api-reference/getApiUsage

`GET /v1/usage`

Runs made with an API key over the last 7 or 30 days, by day and by tool: spend in USD micros, runs and failures. Needs tools:read.

Authentication: `Authorization: Bearer $FOUS_API_KEY`.

## Query parameters

- `period` (string): Default "7d". One of "7d", "30d".

## Response 200

Success

- `success` (true, required)
- `data` (object, required)
  - `period` (string, required): One of "7d", "30d".
  - `from` (string, required)
  - `to` (string, required)
  - `total_usd_micros` (integer, required)
  - `runs` (integer, required)
  - `failed` (integer, required)
  - `series` (array of object, required)
    - `date` (string, required)
    - `spend_usd_micros` (integer, required)
    - `runs` (integer, required)
    - `failed` (integer, required)
  - `workflows` (array of object, required)

## Errors

Every error uses the Error schema: branch on `error.code`. Codes are listed at https://docs.fous.com/guides/errors.

- 400
- 401 (headers: WWW-Authenticate)
- 402
- 403
- 404
- 408
- 409
- 410
- 413
- 422
- 429 (headers: Retry-After)
- 500
- 502
- 503 (headers: Retry-After)
- 504

## Example request

```bash
curl 'https://api.fous.com/v1/usage?period=30d' \
  -H "Authorization: Bearer $FOUS_API_KEY"
```
