API and developers
Generate and Store a UPCS Code via the API
Use POST /v1/upcs/generate with latitude, longitude and an optional address and label to create a UPCS code and get its share URL.
Updated 14 October 2026 · 2 min read
The generate endpoint creates a UPCS code for coordinates and lets you attach an address and a label to it. It is the right call when your system knows where something is and wants a code to keep.
The request
curl -X POST https://api.upcs.io/api/v1/upcs/generate \
-H "x-api-key: upcs_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"latitude": 31.5204,
"longitude": 74.3587,
"address": "12 Example Street",
"label": "Main entrance"
}'
| Field | Required | Notes |
|---|---|---|
latitude |
Yes | Latitude of the point. |
longitude |
Yes | Longitude of the point. |
address |
No | Address text to attach. |
label |
No | A short name for the place. |
The response
upcs_code: the code,CC-XXXX-XXXX.is_existing:trueif a code already existed for that location.share_url: a link to share.
Steps
- Validate that the point is a real latitude and longitude.
- Call the endpoint from your server.
- Save
upcs_codewith your customer or order record. - Share
share_urlif you want someone to open it.
Same place, same code
Each code corresponds to a 3 m x 3 m cell, and the same coordinates give the same code. A second call for a nearby point inside the same cell returns the same code, with is_existing set to true.
Errors
- 422
unsupported_locationfor points outside the supported countries. - 422 for invalid coordinates.
- 401 or 403 for key problems; see error codes explained.
To read a code back, use look up a code.
Frequently asked questions
What does is_existing mean?
It tells you whether a code already existed for that location. The same coordinates always give the same code.
Related reading
UPCS API Error Codes ExplainedA reference to UPCS API errors: session_expired, key_inactive, partner_required, origin_not_allowed, unsupported_location and rate_limited, with fixes.UPCS Map Session Expiry and RenewalUPCS map sessions are short-lived, 15 minutes by default and 60 to 3600 seconds with ttl. Learn how to detect session_expired and renew a session.Handle the UPCS API Rate Limit (429)Each UPCS API key has an hourly request limit. See what a 429 rate_limited response looks like and how to handle it safely in your code.Fix a Missing or Invalid UPCS x-api-keyA 401 response about the API key means the x-api-key header is missing or the key is wrong. Check the header name, the value and your server code.
