Narro docs
Loading…
A key works only from the places you registered for it. If it leaks, it is useless anywhere else.
| Scope | For | Checked against |
|---|---|---|
allowed_origins | Widgets and browsers: the pages that embed a widget. | The Origin of the request, or the origin of its Referer. |
allowed_ip_ranges | Your servers: the API and MCP. | The address the request comes from. |
A key can have either or both. You give the origins and the address ranges in the Programs setup, and a new live key starts with them. You can also set them on the key when you create it. A key holds at most 25 origins and 50 address ranges. Both are optional. A live key that is used for widgets must have at least one allowed origin.
localhost and 127.0.0.1, and only on test keys.https://*.example.com. It needs a real domain behind it, at least two labels. It matches subdomains and not the bare domain, so list https://example.com too if you need it. A wildcard cannot appear anywhere else, and there is no wildcard for the scheme or the port./8 for IPv4 or /16 for IPv6.api.thenarro.com from. Call from a server with a stable address, not through a shared proxy that changes it.| Key has | A request must |
|---|---|
| IP ranges (a server key) | Come from an address inside a range. If it also carries an Origin, that origin must match the allowed origins too. An Origin header is easy to forge outside a browser, so the address check is never skipped because an Origin is present. |
| Origins only (a browser key) | Carry a matching Origin. |
| Neither (an unscoped key) | A sandbox key is allowed. A live key with neither list is allowed for its 90 day life, cannot hold the widget scope, and never treats an empty list as every origin. A scoped key must name something, so a scoped key with neither list is refused. |
The check runs before the request does anything else, and for MCP before any tool runs. Every refusal is also recorded on Narro's side as a flag on the key, which can lead to a closer look at it.
A browser can call the API with a key or a token only from an origin that is allowed for it. Narro never answers with a wildcard and never allows credentials. Browsers call the public path, /public/standard/v1/..., because the preflight is answered only there. Servers use /programs/v1/....
Access-Control-Allow-Origin only when the request's Origin is the one origin of the widget token, or one of the allowed_origins of the partner key. Otherwise the browser blocks the response.204 only for an origin that an active key lists, and with 403 for any other. The allowed methods are GET, POST, PUT, PATCH and OPTIONS. The allowed request headers are Authorization, Content-Type, Idempotency-Key, Narro-Timestamp, Narro-Nonce, Narro-Signature, Narro-Widget-SDK, Narro-Challenge and Narro-Link-Token. A preflight is cached for 600 seconds.X-Request-Id, RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, Retry-After, Deprecation, Sunset, Link and Idempotent-Replay.Origin header is sent by the caller. Keep a browser key to what a page may do, such as minting widget tokens, and use IP ranges for every server key.| Environment | Answer |
|---|---|
| A detailed environment (staging) | The status is 403 and the code names the cause: ip_not_allowed, origin_not_allowed or unscoped_key_not_allowed. |
| Production, including api.thenarro.com | The same 403 with one generic answer, request_not_permitted, for every cause. It never says whether it was the address, the origin or the scope. |
The generic answer is on purpose: an error that names the rule helps someone with a stolen key find the rule to get around. Which form you get depends on the environment that serves the request, not on the key. The production host answers generically for test keys too. If you cannot tell which check failed, compare the address and the origin you registered with the ones your request really comes from, and quote the request_id when you ask Narro. See Errors and retries.
Origins and IP ranges are optional, so you can start without registering anything. A sandbox key can be unscoped. A live key created with no allowed origins and no IP ranges is unscoped: it lives 90 days, and it cannot hold the widget scope, because a live key used for widgets needs at least one allowed origin. An empty list never means every origin or address is permitted for a widget. Narro checks the key on every request, so it stops the moment it expires. For a live key that lives longer, give it origins or IP ranges when you create it.