Skip to content
PreviewThis is built and live, but young. Details on this page can still change.

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.

POST {apiBaseUrl}/public/projects/{projectSlug}/used/{namespace}
e.g. (substitute your own slug)
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.

Authorization: Bearer lw_pub_…
Content-Type: application/json

The 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.

LimitValueSource
Request body1 MiBPUBLIC_USAGE_BODY_LIMIT_BYTES
Names per request1–1,000PUBLIC_USAGE_NAMES_PER_REQUEST
Name length1–2,062 bytes (UTF-8)PUBLIC_USAGE_NAME_MAX_BYTES

Name to key. For each distinct name, in the namespace’s main branch:

  1. a key with exactly that name is recorded;
  2. 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_one is an ordinal lookup of place and a cardinal lookup of a key named place_ordinal, and items_one is a lookup of the plural key items even when a plain key items_one also exists. Recording a key by mistake only keeps it off the unused list; missing one could get a live key deleted;
  3. 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).

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.
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.

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.

LimitValueSource
Window60 s (fixed)PUBLIC_WRITE_WINDOW_MS
Requests per API key60 / windowPUBLIC_USAGE_REPORTS_PER_KEY_PER_WINDOW
Requests per IP30 / windowPUBLIC_USAGE_REPORTS_PER_IP_PER_WINDOW
Names per API key2,000 / windowPUBLIC_USAGE_NAMES_PER_KEY_PER_WINDOW
Names per IP1,000 / windowPUBLIC_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.

Terminal window
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 }