API and developers
UPCS API Security Checklist
A practical security checklist for UPCS integrations: keep API keys on the server, register https origins, use separate keys and rotate when needed.
Updated 14 October 2026 · 2 min read
Run through this list before you take a UPCS integration live. Most of it comes down to one rule: the API key is a secret and belongs on the server.
Checklist
- Keep the key on the server. It must not appear in page source, front-end bundles, mobile apps or public repositories. The page receives only a session token. See create a map session.
- Store it as a secret. Use environment variables or your platform's secret storage, not source files.
- Register only the origins you need. Use https for live sites and add
http://localhost:5173only for development. See manage allowed origins. - Use a separate key per site and environment. A leak is then easy to contain. See naming and separating keys.
- Keep session lifetimes short. Use the default or a smaller
ttl; see session expiry. - Protect your session endpoint. If your server issues session tokens to pages, make sure only the pages that should have a map can request one.
- Do not trust the browser result blindly. Data from
onSelectcomes from the client. Re-check important codes on the server by resolving the coordinates again with server-to-server resolve. - Handle errors without leaking details. Log the
codeandmessage, never the key, and give users a short message. See error codes explained. - Watch the request limit. Unexpected spikes can indicate misuse. See handle the rate limit.
- Be ready to revoke. Know how to disable or delete a key and replace it quickly.
If a key is exposed
- Generate a new key.
- Update your server configuration or plugin settings.
- Disable or delete the exposed key.
- Review the traffic that used it.
Removing an origin or disabling a key immediately stops sessions that depend on it, which limits the window of misuse.
Frequently asked questions
Is it safe to put the API key in JavaScript?
No. Keep the key on your server. The browser should only receive a short-lived session token.
Related reading
Countries Supported by the UPCS APIThe UPCS API returns codes for 25 supported countries. See the list, how the country prefix works, and what unsupported_location means.Quick Start: Embed the UPCS Map on Your SiteEmbed the UPCS map in a few steps: register your origin, create a session on your server, then mount the map in your page and read the selected code.Create a UPCS Map Session From Your ServerCreate a short-lived UPCS map session with POST /v1/embed/sessions, pass your origin and optional ttl, and read the session token from the response.WordPress UPCS Test API Connection FailsIf Test API Connection fails in the UPCS WordPress plugin, check the API key, key status, allowed origin and your server's outgoing connection.
