Usage, Keys & Billing
Monitor usage and quota, cap overage spend, rotate API keys and open the Stripe billing portal from the Air Pixels Data API.
curl https://api.airpixels.com/v1/usage \
-H "Authorization: Bearer $AP_KEY"
{
"data": {
"plan": "builder",
"plan_name": "Builder",
"status": "active",
"month": "2026-11-01",
"calls_used": 8,
"calls_included": 25000,
"calls_remaining": 24992,
"hard_cap": false,
"overage_calls": 0,
"overage_usd_per_call": 0.004,
"estimated_overage_usd": 0,
"spending_cap_usd": null,
"resets_at": "2026-12-01T00:00:00Z",
"rate_limit": 5,
"rate_window_seconds": 1,
"datasets": ["hardware_index", "field_performance", "service_rates"],
"hardware_index_fields": "full",
"key_prefix": "ap_live_••••"
},
"meta": {
"plan": "builder",
"calls_used": 8,
"calls_included": 25000,
"attribution": "Data: Air Pixels (airpixels.com)"
}
}
curl -X POST https://api.airpixels.com/v1/usage/spending-cap \
-H "Authorization: Bearer $AP_KEY" \
-H "Content-Type: application/json" \
-d '{"max_overage_usd": 25}'
curl -X POST https://api.airpixels.com/v1/keys/rotate \
-H "Authorization: Bearer $AP_KEY"
{
"data": {
"api_key": "ap_live_••••",
"key_prefix": "ap_live_••••",
"created_at": "2026-11-06T19:37:16.410Z",
"revoked_key_prefix": "ap_live_••••"
},
"meta": {
"plan": "builder",
"calls_used": 10,
"calls_included": 25000,
"attribution": "Data: Air Pixels (airpixels.com)"
}
}
curl -X POST https://api.airpixels.com/v1/billing-portal \
-H "Authorization: Bearer $AP_KEY"
{
"data": {
"url": "https://billing.stripe.com/p/session/..."
}
}
Read your quota, set a spend cap, rotate a leaked key and open the billing portal, all from the API. These endpoints are free and never counted against your quota, so you can automate them in monitoring scripts and CI without touching your metered usage.
Send your key as a bearer token on every request. See Authentication for key formats and error behavior.
Endpoints
| Method | Path | What it does | Plan |
|---|---|---|---|
GET | /v1/usage | Current month's usage, quota, rate limit and plan state | All plans |
POST | /v1/usage/spending-cap | Set or remove a maximum overage budget | Builder, Operator |
POST | /v1/keys/rotate | Issue a new key and revoke the calling key | All plans |
POST | /v1/billing-portal | Return a single-use Stripe Billing Portal link | Builder, Operator |
POST /keys/rotate and POST /billing-portal take no request body. All four endpoints work in every account status, including past-due and canceled accounts.
Check usage
GET /v1/usage returns your quota and consumption for the current calendar month, plus the rate limit that applies to the key making the call.
The data object contains your account state:
| Field | Type | Description |
|---|---|---|
plan | string | Plan slug, for example builder or operator. |
plan_name | string | Display name of the plan. |
status | string | Account status: active, past due or canceled. Metered calls are rejected on past-due and canceled accounts, but this endpoint keeps working. |
month | string | First day of the quota month in UTC, for example 2026-11-01. |
calls_used | integer | Metered calls made this month by every key on the account. |
calls_included | integer or null | Calls included in your plan this month. null on unlimited contracts. |
calls_remaining | integer or null | Calls left before overage begins. null on unlimited contracts. |
hard_cap | boolean | Whether the plan stops at included calls. false means overage is billed. |
overage_calls | integer | Calls made beyond calls_included this month. |
overage_usd_per_call | number | Price per overage call on your plan. 0 when the plan does not bill overage. |
estimated_overage_usd | number | overage_calls times overage_usd_per_call, rounded to cents. Your invoice is authoritative. |
spending_cap_usd | number or null | Current maximum overage budget in USD. null when no cap is set. |
resets_at | string | ISO 8601 timestamp of the next quota reset. |
rate_limit | integer | Requests allowed per window for the calling key. |
rate_window_seconds | integer | Length of the rate limit window in seconds. |
datasets | array of strings | Dataset identifiers your plan can query. |
hardware_index_fields | string | Field access level on the hardware index dataset, for example full. |
key_prefix | string | Prefix of the key that made this call, for log correlation. |
Quota is counted per account and shared by all of that account's keys. It runs on the calendar month in UTC, not your Stripe billing period, and resets at 00:00 UTC on the 1st. resets_at gives the exact moment. For included calls, overage prices and rate limit windows per plan, see Plans and limits.
Set a spending cap
POST /v1/usage/spending-cap sets a maximum overage budget so a runaway script cannot bill without limit. Builder and Operator keep serving requests past the included calls and bill the overage; this endpoint puts a ceiling on that spend.
The request body has one field:
| Field | Type | Description |
|---|---|---|
max_overage_usd | number or null | Maximum overage spend in USD, from 0 to 1,000,000. Send null to remove the cap. |
The response is your /v1/usage object with spending_cap_usd set to the new value. The cap only applies on Builder and Operator; other plans get 403 not_in_plan.
The cap is converted to a call count with integer division, so requests stop once your included calls plus the overage your cap allows are used:
calls allowed = calls_included + floor(max_overage_usd / overage_usd_per_call)
On Builder, included calls are 25,000 and overage is $0.004 per call. A $25 cap therefore stops at 25,000 plus floor(25 / 0.004), which is 6,250 overage calls:
25,000 + 6,250 = 31,250 calls
A spending cap stops billable calls. Once the limit is reached this month, metered requests return 429 quota_exceeded instead of being served. The cap does not send an alert and keep serving, so size it as the total you are willing to spend, not a warning threshold.
Rotate a key
POST /v1/keys/rotate issues a new API key and revokes the key that made the call, immediately. Rotation is free and takes no request body.
The data object contains:
| Field | Type | Description |
|---|---|---|
api_key | string | The new key, shown only in this response. Store it before the response is lost. |
key_prefix | string | Prefix of the new key, for logging and identification. |
created_at | string | ISO 8601 timestamp when the new key was created. |
revoked_key_prefix | string | Prefix of the key that was revoked by this call. |
Rotation is immediate and irreversible. Any process still using the old key starts getting 401 on its next request, so deploy the new key before or at the same time as you rotate. For key handling practices, see Authentication.
Open the billing portal
POST /v1/billing-portal returns a single-use Stripe Billing Portal link, so you can update a card, download invoices, change billing details or cancel from your own tooling. It is free and takes no request body.
The link is in data.url. Open it in a browser within a few minutes, before the session expires. It is available on Stripe-billed plans (Builder and Operator); Explorer and contract accounts get 403 not_in_plan and manage billing through their contract.
Endpoints that always work
Usage, key rotation and the billing portal keep working in every account status, including past-due and canceled accounts. When a past-due account crosses its 7-day grace period, metered calls start returning 402 subscription_inactive, but these endpoints stay available so you can read your quota, rotate a key and open the portal to fix billing. A canceled account gets 402 on metered calls until it is reactivated.
The free endpoints below are never counted against your quota, and rejected requests (any 400, 401, 402, 403 and both kinds of 429) are not counted either:
GET /v1/usage
POST /v1/usage/spending-cap
POST /v1/keys/rotate
POST /v1/billing-portal
GET /v1/openapi.json
GET /v1/changelog
GET /v1
CORS preflights and MCP initialize, ping, tools/list and notifications are also free.
Errors
| Status | Code | Meaning | Fix |
|---|---|---|---|
400 | bad_request | The spending cap value is out of range or not a number. | Send max_overage_usd between 0 and 1,000,000, or null to remove the cap. |
401 | missing_key / invalid_key / key_revoked | The bearer token is missing, malformed or was revoked (for example by rotation). | Send a current key in the Authorization header. If you just rotated, use the new api_key. |
402 | subscription_inactive | The account is past due beyond its 7-day grace period, or canceled. | Open the billing portal and settle the invoice. These account endpoints keep working during 402. |
403 | not_in_plan | The plan does not include spending caps or the billing portal. | Set caps on Builder or Operator; contract accounts manage billing directly. |
429 | rate_limited | The key exceeded its rate limit window. | Back off and retry after the window; check rate_limit and rate_window_seconds from /v1/usage. |
429 | quota_exceeded | The account used its included calls plus the spend-cap allowance this month. | Raise or remove the spending cap, or wait for resets_at. |
Rate limits and quota are documented in Plans and limits. For the shape of successful responses across the API, see the REST overview.