Error Codes
Complete list of Keymint REST API error codes, HTTP status mapping, and troubleshooting recommendations.
Response Structure
Success responses have code: 0:
{
"code": 0,
"message": "License valid"
}Every error has a top-level message (string), a non-zero code (integer) and a stable errorCode (string):
{
"message": "Invalid license key or insufficient permissions",
"code": 1,
"errorCode": "license_invalid_or_forbidden"
}Branch on errorCode. It never changes for a given situation. message is written for people and may be reworded, so don't match on its text.
Some errors also carry success: false and an error object with a legacy string code: validation errors (VALIDATION_ERROR), the per-action rate limit on activate, checkout and sign (RATE_LIMIT_EXCEEDED) and unknown endpoints (NOT_FOUND). The 405 body carries error as the plain string "Method not allowed". Validation messages always name the field: Field '<name>' is required. or Field '<name>': <problem>.
{
"success": false,
"message": "Field 'licenseKey' is required.",
"code": 1,
"errorCode": "invalid_request",
"error": { "code": "VALIDATION_ERROR", "message": "Field 'licenseKey' is required." }
}Read the message from message and branch on errorCode (or, in older integrations, on the HTTP status and then code). code: 0 only ever accompanies a successful response. Fields may be added to error bodies over time, so ignore any you don't use.
Error Codes (errorCode)
errorCode | HTTP | code | Meaning |
|---|---|---|---|
api_key_missing | 401 | 1 | No Authorization: Bearer <key> header |
api_key_invalid | 401 | 1 | The API key is unknown, expired or revoked, or its scope or product binding doesn't allow this endpoint |
api_key_no_workspace | 403 | 1 | The API key isn't associated with a workspace |
ip_not_allowed | 403 | 1 | The API key has an IP allowlist and this request's address isn't on it |
forbidden | 403 | 1 | The action isn't allowed for this workspace or key (the message says why): a plan limit, an archived product, or a missing permission such as license:manage to delete a customer who holds keys |
license_invalid_or_forbidden | 401 | 1 | Activate, sign and checkout, once the API key is accepted: the license is unknown, expired, blocked, assigned to a disabled customer, the wrong license type, or not allowed on this device. Deliberately one answer, see below. Heartbeat and checkin answer session_invalid instead |
license_not_found | 404 | 1 | Admin and read endpoints: no license with this key for the product |
activation_limit_reached | 403 | 2 | The license is already active on maxActivations devices |
licensee_not_allowed | 403 | 2 | A licensee can't be assigned on the workspace's plan |
offline_license_held | 409 | 1 | The device holds an unexpired offline license, so its activation is kept; the body includes offlineValidUntil |
floating_seats_full | 403 | 4 | Every floating seat is in use; the body includes currentSessions and maxSessions |
session_invalid | 401 | 1 | Floating heartbeat, checkin or repeat checkout with a wrong signature, stale nonce or unknown session |
session_expired | 410 | 5 | The floating session is unknown, was checked in, or expired; call POST /key/checkout again |
product_not_found | 404 | 1 | No active product with this ID in the workspace |
customer_not_found | 403 | 1 | The customer ID isn't in this workspace |
not_found | 404 | 1 | No customer with this ID in the workspace (customer endpoints), or no endpoint at this path |
subscription_required | 402 | 2 | The vendor's workspace needs an active subscription for this operation (the message names it) |
license_archived | 402 | 2 | Archived licenses can't be re-enabled |
plan_selection_required | 402 | 2 | The workspace must renew or finish the Free-plan resource selection first |
invalid_request | 400 | 1 | A parameter is missing, invalid or over its maximum length or value, or the body isn't valid JSON (the message names the field) |
payload_too_large | 413 | 1 | The request body is over 64 KB |
method_not_allowed | 405 | 1 | The endpoint doesn't support this HTTP method |
rate_limited | 429 | 1 or 3 | Too many requests; code: 3 (nested shape) for every route rate limit on /key/activate, /key/checkout and /key/sign |
quota_exceeded | 429 | 1 | The Free plan's monthly API request limit is reached |
conflict | 409 | 2 | A conflicting record already exists (for example a customer with the same email); retry or fix the input |
retry | 409 | 1 | The device was deactivated while its offline license was being signed (/key/sign); try again |
idempotency_in_progress | 409 | 1 | A request with this Idempotency-Key is still running |
idempotency_mismatch | 400 | 1 | The Idempotency-Key was reused for a different request |
idempotency_legacy | 409 | 1 | An old idempotency record can't be replayed; reconcile the original operation |
idempotency_unavailable | 503 | 1 | The idempotency service is temporarily unavailable; retry the same request |
service_unavailable | 503 | 1 | A dependency is temporarily unavailable; retry |
server_error | 500 | 1 | Unexpected server error; contact support if it persists |
Request Limits
A request body over 64 KB (65,536 bytes) gets 413 payload_too_large. This applies to every POST, PUT, PATCH and DELETE, and is checked from Content-Length before anything else runs. Every field also has a maximum; going outside a limit returns 400 invalid_request naming the field.
| Field | Limits |
|---|---|
productId | 22–256 characters |
licenseKey (body, query or x-license-key header) | 20–256 characters |
customerId (request body) | 22–256 characters |
hostId, deviceTag | 1–64 characters |
name (customers, newCustomer, licensee) | 3–255 characters after trimming; no URLs or control characters |
email | 3–320 characters, a valid address |
metadata | 10,000 characters when serialized as JSON |
maxActivations | A whole number up to 1,000,000, or "unlimited"; as text at most 20 characters. On create, omitted, null or "" means unlimited; on update, null or "unlimited" means unlimited |
maxConcurrentSessions | 1–1,000,000 |
heartbeatInterval | 60–86,400 seconds |
sessionLeaseDuration | 300–31,536,000 seconds |
amountKeys | 1–256 |
allowedHosts | 100 entries of up to 255 characters |
expiryDate, versionId | 64 characters |
format | sections 1–10, sectionLength 1–32, separator 3, prefix/suffix 16, charset 2–100 with no whitespace; the format must give at least 60 bits of entropy |
ttl (/key/sign) | 60–315,360,000 seconds (10 years) |
userIdentifier (/key/checkout) | 255 characters |
sessionId | 1–255 characters |
Idempotency-Key header (or X-Idempotency-Key) | 1–255 printable ASCII characters |
timestamp (the floating nonce) | 128 characters |
signature | Exactly 64 hex characters |
GET /customer limit | 1–100 (larger values are capped at 100) |
Numeric Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (see the HTTP status) |
| 2 | License or subscription constraint: activation limit reached, licensee not allowed, workspace subscription required, archived license, or a conflicting record |
| 3 | Per-action rate limit on /key/activate, /key/checkout, and /key/sign (every route rate limit on those three endpoints) |
| 4 | Floating seat limit reached (/key/checkout) |
| 5 | Floating session ended; check out again (/key/heartbeat, /key/checkin) |
Error Reference
| HTTP | Code | When |
|---|---|---|
| 400 | 1 | Missing or invalid parameters (VALIDATION_ERROR names the field), a body that isn't valid JSON, hostId missing on deactivate with a client key, hostId or TTL missing for offline signing, or an Idempotency-Key reused with a different request |
| 401 | 1 | api_key_missing (no Authorization header) or api_key_invalid (Invalid API key or insufficient permissions): the key is invalid, expired, revoked, or its scope or product binding doesn't allow the endpoint |
| 401 | 1 | license_invalid_or_forbidden (activate, sign, checkout) — the license is unknown, expired, blocked, assigned to a disabled customer, the device is not in allowedHosts, or the key's license type doesn't match the endpoint |
| 401 | 1 | session_invalid — floating heartbeat or checkin with a wrong signature or stale nonce, a license that can't be used, or a repeat checkout without a valid signature |
| 402 | 2 | The vendor's workspace has no active subscription for this operation |
| 403 | 2 | activation_limit_reached (the license is already active on maxActivations devices) or licensee_not_allowed (the plan can't take another customer for an activation's licensee claim) |
| 403 | 4 | Floating checkout with every seat in use; the body includes currentSessions and maxSessions |
| 403 | 1 | ip_not_allowed (license endpoints; customer endpoints return the generic 401), api_key_no_workspace, customer_not_found, or forbidden (plan limit, archived product, or a missing permission) |
| 404 | 1 | product_not_found, license_not_found (admin and read endpoints, and deactivate when the device isn't activated), not_found for an unknown customer ID or an unknown path (error.code is NOT_FOUND) |
| 405 | 1 | The endpoint doesn't support this HTTP method |
| 409 | 1 / 2 | A request with the same Idempotency-Key is still in progress or can't be replayed (1), a device holds an offline license (offline_license_held, 1, with offlineValidUntil), the device was deactivated while signing (retry, 1), or a conflicting record already exists (conflict, 2) |
| 410 | 5 | Floating session unknown, checked in or expired — call POST /key/checkout again |
| 413 | 1 | The request body is over 64 KB |
| 429 | 1 / 3 | Rate limit or monthly quota exceeded — see Rate Limits |
| 500 | 1 | Unexpected server error — contact support if persistent |
| 503 | 1 | Authorization or idempotency service temporarily unavailable — retry the same request |
Why license failures look the same
Expired, blocked, unknown, and wrong-device licenses all return the same 401 response on purpose, so a leaked API key can't be used to probe which license keys exist or what state they're in. Treat any 401 from activation as "this license can't be used on this device" and show the user a recovery path (re-enter the key, contact support). To see why a specific license fails, look it up from your server with GET /key using a read-only or admin key, or open it in the dashboard.
Handling Errors
Distinguish a license the server rejected from a request that didn't get an answer. Only the first should lock the user out; for the second, keep the last known state and retry later.
const res = await fetch('https://api.keymint.dev/key/activate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ productId, licenseKey, hostId })
});
const data = await res.json();
const message = data.message;
if (res.ok) {
// Activated — data.code === 0
} else if ([401, 402, 403, 404].includes(res.status)) {
// License rejected: invalid/expired/blocked key, wrong device,
// vendor subscription lapsed, activation limit reached, or the
// product was deactivated (404 product_not_found). Branch on
// data.errorCode for the exact reason, never on the message text.
} else if (res.status === 429) {
// Back off for Retry-After seconds, then retry
} else {
// 5xx: keep the cached license state and retry later
}The official SDKs never return a non-2xx response as a normal result. The Node.js and Python SDKs throw an error with status and code; the Go SDK returns an *ApiError with Status and Code; the C# SDK returns a result with IsSuccess == false and the details in Error. Apply the same rules in that branch.
Never expose raw API error messages to end users. Map them to user-friendly messages in your application.