POST key usage
The SDK’s trackUsage option calls this endpoint to report the key names
i18next looked up. See Key usage tracking for what
it is for and how to turn it on.
Request
Section titled “Request”POST {apiBaseUrl}/public/projects/{projectSlug}/used/{namespace}https://api.localize.work/public/projects/your-project/used/common| Part | Rules |
|---|---|
projectSlug |
Must match the project the API key belongs to. |
namespace |
1–200 characters, one path segment: /, \, . and .. are rejected. Never created: an unknown namespace reports every name as unknown. |
There is no locale in the path. Usage is recorded per key, whatever language it was looked up in.
Headers
Section titled “Headers”Authorization: Bearer lw_pub_…Content-Type: application/jsonThe token must be a public project API key, the same kind saveMissing uses.
A JSON array of the key names i18next looked up in that namespace:
["welcome", "items_one", "items_other", "nav.home"]Duplicates are allowed and counted once.
Limits
Section titled “Limits”| Limit | Value | Source |
|---|---|---|
| Request body | 1 MiB | PUBLIC_USAGE_BODY_LIMIT_BYTES |
| Names per request | 1–1,000 | PUBLIC_USAGE_NAMES_PER_REQUEST |
| Name length | 1–2,062 bytes (UTF-8) | PUBLIC_USAGE_NAME_MAX_BYTES |
Semantics
Section titled “Semantics”Name to key. For each distinct name, in the namespace’s main branch:
- a key with exactly that name is recorded;
- if the name ends in a plural suffix (
_zero,_one,_two,_few,_many,_other, or_ordinal_followed by one of them), so is every plural key the name can be a lookup of:place_ordinal_oneis an ordinal lookup ofplaceand a cardinal lookup of a key namedplace_ordinal, anditems_oneis a lookup of the plural keyitemseven when a plain keyitems_onealso exists. Recording a key by mistake only keeps it off the unused list; missing one could get a live key deleted; - a name that matches nothing is unknown. So is a name containing a NUL character, which no key name can contain.
Context variants such as friend_male are ordinary key names and match
exactly or not at all.
What is written. Each matched key’s lastUsedAt is set to the time of the
request, unless it was already set within the last 60
minutes, in which case it is left as it is. Nothing else changes: no keys or
namespaces are created, the key’s updatedAt, texts and history are untouched,
and nothing is written to the activity log. The API key’s own “last used” time
is updated, as for saveMissing.
The usage window. The first report that records at least one key sets the
project’s usage start. It moves only when reports lapse: a report that records
a key after more than 7 days without one starts the window again from that
report. “Not used in N days”
filters (the editor, MCP search_keys, GET /v1/keys?unusedDays=) are refused
until that start is at least N days old, and while no report has recorded a key
in the last 7 days. N is at least 7, so a silence that covers a whole window
always restarts it. A report stamps its keys and restarts the window in one
transaction. The last report is read from the
newest key stamp, so it is accurate to within 60 minutes. A
report that matched no key, for example one sent to the wrong namespace, does
not start the window and does not count as a recent report. A key counts as
unused only when its stamp is older than N days plus eight hours, because a
stamp can trail the key’s last lookup (the SDK re-sends a key after six hours,
and the server refreshes stamps at most hourly).
Response
Section titled “Response”200 OK
{ "recorded": 3, "unknown": 1 }| Field | Type | Meaning |
|---|---|---|
recorded |
number | Distinct keys the names matched, whether or not their time was rewritten (see above). items_one and items_other count as one key. |
unknown |
number | Distinct names that matched no key. |
Status codes
Section titled “Status codes”| Code | Body | When |
|---|---|---|
| 200 | the response above | The report was processed, including an unknown namespace (recorded: 0). |
| 400 | {"error":"invalid_namespace"} |
Namespace fails the path-segment rules. |
| 400 | {"error":"bad_body","issues":[…]} |
Body is not an array of 1–1,000 strings of at most 2,062 bytes of UTF-8 each (the longest key path an import stores, 2,048 bytes, plus the longest plural suffix, _ordinal_other). A body is also at most 1 MiB, so long names are split over several requests, as the SDK does. issues is the Zod issue list. |
| 401 | {"error":"unauthorized"} |
Missing/malformed Authorization header, unknown token, secret-kind key, a key of a different project, a key an AI agent created after that agent was revoked, or a key of a deleted organization. |
| 413 | Fastify’s error body | Body larger than the request body limit. |
| 429 | {"error":"rate_limited"} + Retry-After |
Either rate-limit dimension exceeded. |
Rate limits
Section titled “Rate limits”Fixed window, per API key and per client IP, with counters of their own: a burst of usage reports never uses up the saveMissing allowance, and the reverse. Each name in a request counts against the name budget.
| Limit | Value | Source |
|---|---|---|
| Window | 60 s (fixed) | PUBLIC_WRITE_WINDOW_MS |
| Requests per API key | 60 / window | PUBLIC_USAGE_REPORTS_PER_KEY_PER_WINDOW |
| Requests per IP | 30 / window | PUBLIC_USAGE_REPORTS_PER_IP_PER_WINDOW |
| Names per API key | 2,000 / window | PUBLIC_USAGE_NAMES_PER_KEY_PER_WINDOW |
| Names per IP | 1,000 / window | PUBLIC_USAGE_NAMES_PER_IP_PER_WINDOW |
The request limit is checked before the token is looked up. Counters are per API process and reset on deploy.
As for every /public/* route, any origin may call it with a bearer token and
no credentials.
Worked example
Section titled “Worked example”curl -X POST https://api.localize.work/public/projects/your-project/used/common \-H "Authorization: Bearer $LOCALIZE_PUBLIC_KEY" \-H "Content-Type: application/json" \-d '["welcome","items_one","items_other","no.such.key"]'{ "recorded": 2, "unknown": 1 }Related
Section titled “Related”- Key usage tracking — the SDK option and how to read the results.
- POST missing keys — the other public endpoint.