GET
# Account Usage API

Retrieve your remaining credits and current billing-period usage for your API key.

## Overview

#### Non-billable

This call does not consume a credit and is not counted in your usage analytics — poll it as often as you reasonably need (about once a minute is plenty).

Use this endpoint to monitor how many credits you have left in the current billing period, build a usage meter, or alert before you run out. The numbers reflect the active billing period and reset at `reset_at`.

### Endpoint

GET https://api.stayapi.com/v1/account/usage 

## Authentication

Authenticate with your API key in the `x-api-key` header (header names are case-insensitive). See the [Authentication guide](/docs/authentication) for details.

```
x-api-key: YOUR_API_KEY
```

## Parameters

No parameters required. Authenticate with your `x-api-key` header.

## Response Format

| Field | Type | Description |
| --- | --- | --- |
| tier | string | Your subscription tier (e.g. `free`, `basic`, `startup`, `scale`). |
| used | integer | Billable requests consumed so far in the current billing period. |
| remaining | integer | Credits left this period — `total_limit − used` (never negative). |
| total\_limit | integer | Total credits available this period — `used + remaining`. |
| plan\_limit | integer | Credits included with your subscription tier. |
| purchased\_credits\_remaining | integer | Add-on credits still available on top of your plan. |
| reset\_at | string | ISO-8601 (UTC) timestamp when the current period ends and `used` resets to 0. |
| period\_start | string | ISO-8601 (UTC) timestamp when the current period started. |

## Status Codes & Errors

- `200` — success; the usage object is returned.
- `401` `INVALID_API_KEY_FORMAT` / `INVALID_API_KEY` — malformed or unknown API key.
- `422` `VALIDATION_ERROR` — the `x-api-key` header is missing.
- `403` `ACCOUNT_BLOCKED` — your account has been blocked.
- `404` `ACCOUNT_NOT_FOUND` — no account is associated with this API key.
- `503` `SERVICE_UNAVAILABLE` — usage data is temporarily unavailable.

### Error responses (Problem Details)

Errors follow [RFC 7807](https://www.rfc-editor.org/rfc/rfc7807) Problem Details with media type `application/problem+json`. Example (`404`):

```
{
  "type": "https://api.stayapi.com/errors/account-not-found",
  "title": "Account not found",
  "status": 404,
  "detail": "No account is associated with this API key.",
  "error_code": "ACCOUNT_NOT_FOUND",
  "instance": "/v1/account/usage",
  "provider": "stayapi",
  "correlation_id": "req_..."
}
```

#### Caching

Successful (200) responses and the route-level 403/404/503 errors are returned with Cache-Control: no-store — always read them live. Auth and validation failures (401, 422) are produced before the route runs and do not carry that header.

Request

```curl
curl -X GET "https://api.stayapi.com/v1/account/usage" \
  -H "x-api-key: YOUR_API_KEY"
```

Response

```json
{
  "tier": "scale",
  "used": 12345,
  "remaining": 92655,
  "total_limit": 105000,
  "plan_limit": 100000,
  "purchased_credits_remaining": 5000,
  "reset_at": "2026-06-15T00:00:00Z",
  "period_start": "2026-05-15T00:00:00Z"
}
```

```json
{
  "type": "https://api.stayapi.com/errors/account-not-found",
  "title": "Account not found",
  "status": 404,
  "detail": "No account is associated with this API key.",
  "error_code": "ACCOUNT_NOT_FOUND",
  "instance": "/v1/account/usage",
  "provider": "stayapi",
  "correlation_id": "req_..."
}
```
