Skip to main content

API docs and build details

Every gateway carries a full description of its own API: an interactive explorer at /, a reference page at /redoc, the machine readable OpenAPI document at /openapi.json and a list of every route at /routes. For your developers this is a map of everything they can call. For a stranger on the internet it is the same map, plus hints about how the gateway is built. Spanway shows that map only to people who have signed in, and keeps the details that help an attacker, such as stack traces, the exact version and the Admin UI source code, out of every answer an anonymous caller can see.

A real-world scenario​

A company puts its gateway on a public address so mobile apps can reach it. A week later a scanner requests /openapi.json, /routes and / on every address in the range, looking for software it knows how to attack. On Spanway each request answers 404 Not Found, the same answer a path that does not exist gets, so the scanner cannot tell what is running or which version it is. The company's platform engineers still open the explorer in their browser after signing in to the Admin UI, and their CI job still downloads /openapi.json with a personal key to build its client.

What an anonymous caller sees​

SurfaceSigned-in userAnyone else
Interactive explorer at / (or DOCS_URL), its login helper at /docs/oauth2-redirect and its files under /swaggerThe explorer.404 with {"detail": "Not Found"}.
Reference page at /redoc (or REDOC_URL)The page.404 with {"detail": "Not Found"}.
OpenAPI document at /openapi.json (or OPENAPI_URL)The full document.404 with {"detail": "Not Found"}.
Route list at /routes and the explorer's /lazy/warm/<feature> loaderThe list, for the roles the route itself allows.404 with {"detail": "Not Found"}.
/mcp/openapi.json, /mcp/docs and /mcp/redocNo explorer or OpenAPI document. MCP clients connect to /mcp directly.The same.
An unexpected error inside the gateway500 with {"error": {"message": "Internal server error", "type": "internal_server_error"}}.The same. The stack trace goes to the gateway log only.
The server response headerNot sent, whether the gateway runs under uvicorn, gunicorn or hypercorn, and in the gateway, backend and worker images. The Admin UI image sends nginx with no version number.The same.
The x-spanway-version response headerSent on answers to model requests, which always need a key.Never sent, because an anonymous request is refused before it reaches a model.
Admin UI source mapsNone. The Admin UI is built without them.None.

A signed-in user is someone whose key or Admin UI session belongs to a person, that is a key with an owner (user_id), with the role proxy_admin, proxy_admin_viewer, org_admin, internal_user or internal_user_viewer. Keys that belong to no person, such as team or service keys built into an application, and customer keys get the same 404 as an anonymous caller, so a key copied out of an app does not reveal the API map either. The paths move with DOCS_URL, REDOC_URL and OPENAPI_URL, and the protection moves with them.

The version number still appears where a signed-in person needs it: in the OpenAPI document, and in GET /health/readiness/details, which needs a key. The public release feed at /public/whats_new, which the Admin UI shows on its home page, names releases on purpose, because its job is to announce what is new.

The setting​

SettingDefaultWhat it does in plain words
SPANWAY_PUBLIC_API_DOCSfalseDecides whether anonymous callers may read the API description.

What it does. With the default, only signed-in users see the explorer, the reference page, the OpenAPI document and the route list. Set SPANWAY_PUBLIC_API_DOCS=true in the gateway's environment and restart to show them to everyone again.

How it helps you. Keeping it off means scanners and curious strangers learn nothing about your gateway from its own documentation, which makes targeted attacks harder. Turning it on is useful for a gateway that only ever runs on a laptop or inside a closed test network, where developers want the explorer without signing in.

When it is on. Anyone who can reach the gateway can read the full API description and the route list. Nothing else changes: every route still checks keys and roles as before.

When it is off. Only signed-in users can read them, everyone else gets 404.

Cost and risk. Turning it on costs nothing, but it publishes the full list of management routes and their request formats to anyone who can reach the gateway. Leave it off on any gateway with a public address.

Who should change it. The operator who runs the gateway, and only for a private development or test gateway. NO_DOCS, NO_REDOC and NO_OPENAPI still remove the pages entirely, for everyone, see environment variables.

Check it on your gateway​

  1. Ask for the OpenAPI document without a key. The gateway answers as if the path did not exist:

    curl -i http://localhost:4000/openapi.json
    HTTP/1.1 404 Not Found
    content-type: application/json

    {"detail":"Not Found"}
  2. Ask again with your own key. The full document comes back:

    curl -s http://localhost:4000/openapi.json -H "Authorization: Bearer $SPANWAY_API_KEY" | head -c 80
    {"openapi":"3.1.0","info":{"title":"Spanway API","description":"The Spanway gat
  3. Open the explorer in a browser. Sign in to the Admin UI at http://localhost:4000/ui first, then open http://localhost:4000/ in the same browser. The explorer loads, because the Admin UI session signs you in. In a private window, without signing in, the same address shows {"detail":"Not Found"}.

  4. In the Admin UI, open Virtual Keys, click Create New Key and expand Advanced Settings. The extra key fields load from the API description, so they show for every signed-in user.

  5. Confirm the gateway does not name its server. No server line appears in the headers:

    curl -sI http://localhost:4000/health/liveliness

The release checks enforce the rest: the image gate fails a gateway image that carries any source map in the Admin UI or in Spanway's own package folders, and the Admin UI bundle check fails when the committed Admin UI carries a source map or a reference to one.

Errors​

SymptomCauseFix
404 with {"detail": "Not Found"} on /, /redoc, /openapi.json or /routesThe request carried no key, a wrong key, a service or customer key, or an Admin UI session from another site.Send your own key in Authorization, or sign in to the Admin UI in the same browser. On a private test gateway, set SPANWAY_PUBLIC_API_DOCS=true.
The explorer at / loads but every request in it answers 401The explorer is open, but its Authorize button was not used, so its test calls carry no key.Click Authorize and enter your key.
Advanced Settings in Create New Key says These advanced fields come from the gateway's API description, which this sign-in cannot read. Ask an admin to set them, or set them through the API.The Admin UI is served from another address than the gateway, so the browser does not send the session to /openapi.json, or the session has expired.Open the Admin UI from the gateway's own address, or sign in again.
404 on /openapi.json with a valid keyNO_OPENAPI=true removed it, or OPENAPI_URL moved it.Ask the operator for the path.

See the error reference for every other 404.

Logs​

LevelLineMeaningAction
INFOSpanway API docs: answered 404 to GET /openapi.json because the caller is not a signed-in user. Set SPANWAY_PUBLIC_API_DOCS=true to publish the docs.A caller without a signed-in user's key asked for the API description and got 404. The line names the method and path, never the key.None. A steady stream from one address is a scanner. When your own tool causes it, give the tool a personal key.

A request with no key and no Admin UI session gets only this line, so a scanner does not fill the log with errors. A request with a wrong key also writes the usual authentication failure line, see request lines. INFO lines show when SPANWAY_LOG=INFO, see the log reference.