Skip to content

Features

API key request limits

Requires a license with the apikey-pro feature. See pricing.

A request limit caps how many requests one API key may make in a clock hour, a day or a calendar month. A key can carry any of the three. Once it reaches one, every further request answers 429 until that window ends or you raise the limit. Everything else about keys, from creating them to reading their history, stays free on every install.

Open Access > API keys. The Usage (this month) column shows each key's requests, with a bar for a key that has a monthly limit and its other limits below it, such as Also 3/h. To change a key's limits, choose its Request limits button. The drawer has Per hour, Per day and Per month, where 0 sets no ceiling, and Save applies them. The New key form has the same three fields under Request limits.

The Request limits drawer for the partner-feed key, open over the API keys list, with 3 requests per hour, no daily limit and 1000 per month.

QuestionAnswer
What is countedEvery request the key makes on the Content API, whatever it answers, except the ones refused at a limit.
When the count resetsOn the hour, at midnight and on the first of the month, each in UTC. A limit set partway through a window counts from then.
What a key over its limit gets429 with X-RateLimit-Exceeded: true, Retry-After in seconds until the window ends, and {"error": "hourly request limit (1000) exceeded", "window": "hourly"}. When several limits are spent, the answer names the one that resets last.
How the limits relateA shorter window's limit cannot be above a longer one's, because it could never be reached.
What 0 meansNo limit. It is the default.
Who countsUsage and quotas, which runs on every install. If the count cannot be read, the request goes through.
How exact it isThe count is checked before a request and written after it, so requests that arrive together can pass a limit by as many as are in flight at once.

Run this on an install whose license carries apikey-pro, signed in as an admin or super_admin. The quickstart creates the post content type used here, and the key's viewer role needs an access rule that reads post, as step 1 of API keys creates.

Create a key that may make three requests an hour:

Console v0.28.0

  1. Open Access > API keys and choose New key. Enter partner-feed in Name. Under Roles, untick editor, which the form ticks for you, and tick viewer.
  2. Leave Content on Every content type with Read ticked.
  3. Under Request limits, enter 3 in Per hour and 1000 in Per month, then choose Create.
  4. Copy the key from API key created into KEY. It is shown once.

Engine API v0.62.0

You need an admin or super admin token in TOKEN. The quickstart shows how to get one.

Shell
curl -X POST http://localhost:3001/api/admin/api-keys \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "partner-feed", "roles": ["viewer"], "scopes": ["content:read"], "hourly_limit": 3, "monthly_limit": 1000}'

The answer is 201 with "hourly_limit": 3 and "monthly_limit": 1000. Copy raw_key into KEY and id into KEY_ID. raw_key is shown once.

Call the Content API four times with the key. This is the same on both paths:

Shell
for i in 1 2 3 4; do
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:3002/api/v1/content/post \
-H "X-API-Key: $KEY"
done

You see 200, 200, 200, then 429. The fourth answer carries Retry-After with the seconds left in the hour.

Read the key's use this month:

Console v0.28.0

On Access > API keys, the key's row shows 3 req under Usage (this month), with Also 3/h below the bar. The refused fourth call is not counted.

Engine API v0.62.0

Shell
curl http://localhost:3001/api/admin/usage/api-key/$KEY_ID \
-H "Authorization: Bearer $TOKEN"
JSON
{ "api_key_id": "b0872381-...", "tenant_id": "default", "billing_period": "2026-10", "requests": 3, "bytes_in": 0, "bytes_out": 540 }

The refused fourth call is not counted.

Clear the hourly limit, and the key is served again:

Console v0.28.0

Choose the key's Request limits button. Set Per hour to 0 and choose Save. Also 3/h goes from the row, and Per month keeps 1000.

Engine API v0.62.0

Shell
curl -X PATCH http://localhost:3001/api/admin/api-keys/$KEY_ID/limits \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"hourly_limit": 0}'

The answer is the key with "hourly_limit": 0 and its monthly limit unchanged, because a field the body leaves out keeps its value.

Console v0.28.0

Give a new key limits under Request limits in the New key form, or choose an existing key's Request limits button on Access > API keys, change Per hour, Per day or Per month and choose Save.

Engine API v0.62.0

Give a new key limits with hourly_limit, daily_limit and monthly_limit on POST /api/admin/api-keys, as in Try it, or change the limits of an existing key:

Shell
curl -X PATCH http://localhost:3001/api/admin/api-keys/$KEY_ID/limits \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"daily_limit": 5000, "monthly_limit": 100000}'

PATCH /api/admin/api-keys/{id}/monthly-limit still sets the monthly limit alone.

Both routes, and LyEve Console's forms, take an admin or super_admin with a signed-in session. An admin token or another API key is refused.

Each limit is judged on its own:

WriteNeeds apikey-pro
Create a key with any limit above 0Yes
Give a key with no limit its first oneYes
Raise a key's limitYes
Lower a key's limitNo
Clear a limit with 0No
Send back the value the key already holdsNo

Every limit you set keeps being enforced, because it caps what a client can spend and a lapse must not lift it. Lowering and clearing a limit stay free, so you can still tighten a key you worry about. Setting a first limit or raising one needs apikey-pro again.

StatusMessageCause
400validation failed on field "monthly_limit"A limit is below 0.
402payment_required, naming feature:apikey-proThe write sets a first limit or raises one without apikey-pro. Nothing is stored.
404api key not foundNo key with that id in your tenant.
422daily_limit (<n>) is above monthly_limit (<n>), so it can never be reachedA shorter window's limit is above a longer one's.
429hourly request limit (<n>) exceeded, or daily or monthlyThe key used that limit for the current window.

The 402 body in full:

JSON
{"error": "payment_required", "plugin": "apikey", "feature": "feature:apikey-pro", "upgrade_url": ""}

The other errors of the key routes are on API keys.