Authentication
SimVector map tiles use session-based authentication. Your server exchanges a long-lived API key for a JSON Web Token (JWT). The browser uses only the JWT.
The flow
Browser ──(1) request token──▶ Your server ──(2) GET /auth/jwt + API key──▶ SimVector
Browser ◀──(4) JWT───────────── Your server ◀──(3) JWT─────────────────────── SimVector
Browser ──(5) tile requests with Bearer JWT──────────────────────────────────▶ SimVector tiles- The map client asks your server for a token.
- Your server calls the SimVector token endpoint using the API key.
- SimVector returns a JWT.
- Your server passes the JWT to the client.
- The client sends tile requests with
Authorization: Bearer <JWT>.
Minting a token
GET https://api.simvector.net/v1/auth/jwt
x-api-key: {YOUR_API_KEY}Call this only from server-side code. The key is also accepted as an api_key query parameter, but prefer the header: query strings tend to be written to access logs and proxies.
A successful response looks like this:
{
"token": "eyJhbGciOiJSUzI1NiIs…",
"grants": ["schedule_cloud"]
}Tile access only needs token. See the Get a JWT reference for the full endpoint description.
Keep the API key secret
Never ship your API key in browser or mobile code, and never commit it to source control, including "example" env files and default values in config. Anyone holding it can mint tokens against your subscription. Store it in server configuration or a secrets manager.
About the token
| Property | Value |
|---|---|
| Format | JWT signed with RS256 |
| Lifetime | 48 hours |
| Identifies | Your community |
| Scopes tile access to | The tilesets in your subscription (currently globe and global_elevation_90m) |
| Public keys | Published as a JWKS at https://api.simvector.net/jwks |
You normally treat the token as opaque. You do not need to decode or verify it; the tile service does that.
Caching and refreshing
Tokens last 48 hours, so there is no need to mint one per request or per visitor. A good pattern:
- Server: cache the token for a few minutes (the Quick Start uses 5) and serve the cached value to all visitors. This keeps load on the token endpoint to a handful of calls per hour and stays well inside the 48-hour lifetime.
- Client: let
@simvector/maplibre-protocolhold the token for the life of the page. When a tile request returns401, it calls yourgetTokenagain and retries that request once.
Only the token is worth caching on your server. Do not proxy or cache the tiles themselves: tiles are already served from our global edge network, and a copy of them goes stale when we update the data. See Request tiles directly.
Things to be aware of:
- Refresh is reactive. The handler does not check expiry in advance; it reacts to a
401. - Only
401triggers a retry. Other failures (including403,429and5xx) are thrown as errors with the message[SimVector] <status> <statusText> - <url>and are not retried automatically. Handle them withmap.on('error', …)and, if you need it, your own backoff. - If your server caches tokens, keep the cache shorter than the token lifetime so a retry after
401never receives an already-expired cached token.
Where to find your API key
Sign in to the SimVector Console, open your community, and go to Settings → General. The key is masked, with options to reveal and copy it. A paid Community Subscription is required.
Personal API keys are different
The Console's Settings → API Keys page manages personal keys. The community key on the community settings page is the one used for tile authentication.
Rotating your API key
Owners can regenerate the key from Settings → General. Regenerating immediately invalidates the previous key.
- Regenerate the key in the Console.
- Update the secret in your server configuration.
- Restart or redeploy so the new value is loaded.
- Clear any cached token if you want to be sure the next one comes from the new key. Existing tokens keep working until they expire.
If a key has been committed to a repository or shared by mistake, treat it as leaked: regenerate it, then remove it from the repository and its history.
Using plain HTTPS
If you are not using MapLibre, request tiles directly and set the header yourself:
curl -H "Authorization: Bearer $SIMVECTOR_JWT" \
"https://tiles.simvector.net/global_elevation_90m/0/0/0.png" -o tile.pngTroubleshooting
| Symptom | Likely cause |
|---|---|
Token request fails with 401 | Wrong or regenerated API key. |
Your token endpoint returns 502 or 503 | Upstream call failed, or the key is not configured in that environment. Check your server logs. |
Tiles return 401 repeatedly | Your getToken is returning an empty or expired token. Make it throw on failure and check the token endpoint. |
| Tiles return another error status | The handler throws [SimVector] <status> …. It does not retry; check the status and URL in the message. |
| Works locally but not in production | The token endpoint is not reachable from the deployed client, or the key is not set in the production environment. |