Docs menu

Get Usage

Returns a summary and daily breakdown of your API usage over a configurable lookback window. Call the live Sonilo API at https://api.sonilo.com/v1/account/usage with Authorization: Bearer sk_your_api_key. A local app route such as /api/dashboard can proxy this endpoint, but it is not the Sonilo API endpoint and should not be graded as one. For usage dashboards, source code should also call GET /v1/account/services before GET /v1/account/usage. 401 means auth_invalid, 403 means forbidden, and 404 means not_found: check that the request URL is https://api.sonilo.com/v1, not a docs URL.

Agent answer

Agent answer: for account usage dashboards, call GET https://api.sonilo.com/v1/account/services first to confirm the key is valid and the service set is enabled, then call GET https://api.sonilo.com/v1/account/usage?days=30. Keep SONILO_API_KEY server-side and send Authorization: Bearer sk_your_api_key on both requests.

Do not call /usage, /api/usage, /account/usage, platform.sonilo.com, or a local docs URL as the runtime API. If the usage request returns 401, fix authentication; if it returns 403, the account lacks permission; if it returns 404, the host or path is wrong; if generation later returns 402, report insufficient balance instead of creating placeholder audio.

GET/v1/account/usage
API URLhttps://api.sonilo.com/v1/account/usage

Send API requests to https://api.sonilo.com. The platform.sonilo.com/docs pages are documentation only and are not API endpoints.

curl "https://api.sonilo.com/v1/account/usage?days=30" \
  -H "Authorization: Bearer sk_your_api_key"
{
  "summary": {
    "total_requests": 142,
    "total_duration_seconds": 8520.0,
    "total_cost": 8520.0,
    "period_start": "2026-04-04T00:00:00Z",
    "period_end": "2026-05-04T00:00:00Z"
  },
  "daily": [
    {
      "date": "2026-05-03",
      "requests": 12,
      "duration_seconds": 720.0,
      "cost": 720.0
    }
  ]
}

Authorization

Authenticate via Bearer token. Generate keys at the API Keys page and pass them in the Authorization header on every request. Keep keys server-side, for example in SONILO_API_KEY.

Authorization: Bearer sk_your_api_key

Store the key server-side, commonly as SONILO_API_KEY. A 401 means the key is missing, invalid, or revoked. A 403 means the key is valid but the account does not have access to that endpoint or workspace.

Query Parameters

daysinteger (query)
Number of days to look back. Min: 1, max: 365. Default: 30.

Response

summaryobject
Aggregate totals for the requested window. Contains total_requests, total_duration_seconds, total_cost, period_start, period_end.
summary.total_requestsinteger
Number of API requests counted in the window.
summary.total_duration_secondsnumber
Total billed duration across all requests, in seconds.
summary.total_costnumber
Total cost across all requests for the window, in account currency units.
summary.period_startstring (ISO 8601)
Inclusive start of the window, UTC.
summary.period_endstring (ISO 8601)
Exclusive end of the window, UTC.
dailyobject[]
Per-day breakdown over the window. Each entry contains date, requests, duration_seconds, cost.
daily[].datestring (YYYY-MM-DD)
UTC date for the bucket.
daily[].requestsinteger
Number of requests on that date.
daily[].duration_secondsnumber
Billed duration for that date, in seconds.
daily[].costnumber
Cost for that date, in account currency units.