Base path: /api/v1
All API responses use the same envelope:
{
"data": 123,
"status": "SUCCESS",
"code": "SUCCESS",
"msg": "SUCCESS"
}Errors use the same envelope with a stable code and an HTTP status. Common codes:
VALIDATION_ERRORUNAUTHORIZEDBIZ_CODE_NOT_FOUNDSEGMENT_ALLOCATE_FAILEDUID_UNAVAILABLECLOCK_MOVED_BACKWARDSWORKER_ID_UNAVAILABLEUPSTREAM_UNAVAILABLEINTERNAL_ERROR
GET /api/v1/segment/identity?bizCode=orders returns the registered allocation row ID as a decimal string in the v1 success envelope. The database uses its existing equality rules. The lookup does not advance the cursor. An unknown code returns 404. Identity is scoped to a single database writer.
When mxsm.uid.security.enabled=true, send one of:
Authorization: Bearer <token> X-API-Key: <token>
Generation and read endpoints accept mxsm.uid.security.tokens or mxsm.uid.security.admin-tokens. The admin endpoint POST /api/v1/segment/rg accepts only admin-tokens. Requests with a missing token or a generation-only token return HTTP 401 with code UNAUTHORIZED and leave the business code unregistered.
/actuator/health/** and /actuator/info do not require a token.
POST /api/v1/segment/rg Content-Type: application/json Authorization: Bearer <admin-token>
{
"bizCode": "orders",
"step": 1000
}bizCode is limited to 128 characters. Registration and allocation share the same business key, so Orders, orders, and orders use one cursor. step must be positive.
Pass the original business name to the SDK, including literal percent characters. Path clients must UTF-8 percent-encode each name as one path segment. For example, a literal space is %20 and a literal "%20" is %2520. Registration accepts slashes, backslashes and dot-only names as well. For these names use POST /api/v1/segment/uid?bizCode=... or GET /api/v1/segment/list?bizCode=...&segmentNum=... with a query-encoded value, including for names registered before these routes were introduced. The same query routes under /api/v2 return exact decimal strings. Upgrade servers before clients that need the query routes.
POST /api/v1/segment/uid/{bizCode} Authorization: Bearer <token>
Legacy compatibility:
GET /api/v1/segment/uid/{bizCode}
The GET endpoint is deprecated because ID generation has side effects. All /api/v1/** responses include Cache-Control: no-store.
GET /api/v1/segment/list/{bizCode}?segmentNum=16 Authorization: Bearer <token>
This endpoint is used by the Java SDK local segment cache. segmentNum must be between 1 and 10000.
POST /api/v1/snowflake/uid Authorization: Bearer <token>
Legacy compatibility:
GET /api/v1/snowflake/uid
The GET endpoint is deprecated.
Server and local SDK generation require the clock to fall within the configured timestamp field. Both endpoints of the range are valid. An out-of-range clock rejects local generator startup or returns UID_UNAVAILABLE (HTTP 503 on the server) if the field expires while running.
GET /api/v1/snowflake/parse/{uid} Authorization: Bearer <token>
Returns timestamp, machine ID, and sequence.
Consumers can opt into the following v2 routes. They use the same authentication, error envelope and cache policy as v1. The v1 routes keep their numeric fields. Create business codes through the existing v1 registration route.
| Route | Exact decimal string |
|---|---|
| POST /api/v2/snowflake/uid | data |
| POST /api/v2/segment/uid/{bizCode} | data |
| GET /api/v2/snowflake/parse/{uid} | data.uid |
| GET /api/v2/segment/list/{bizCode}?segmentNum=2 | data[].segmentStartNum |
Keep the original string as an object or map key. Use BigInt for arithmetic.
const { data: id } = await response.json(); const byId = new Map([[id, order]]); const exact = BigInt(id);
Missing required query parameters, invalid path or query parameter types, and unreadable JSON bodies return HTTP 400. For example, GET /api/v1/segment/list/orders without segmentNum returns a response containing {"status":"EXCEPTION","code":"VALIDATION_ERROR","data":null,"msg":"Missing parameter segmentNum"}.