Error Codes

Response Structure

Success:

json
{
  "code": 0,
  "data": { ... }
}

Error:

json
{
  "message": "Descriptive error message",
  "code": 1
}

The code field differentiates error types within the same HTTP status.

Error Code Reference

Success

HTTPCodeDescription
2000Request completed successfully

Client Errors

HTTPCodeDescription
4001Missing or invalid parameters
4011Invalid or missing API key
4032License expired, blocked, or activation limit reached
4033Unauthorized device — hostId not in allowedHosts
4041Resource not found (product, license key, or customer)
4092Conflict — duplicate email or existing resource
4291Rate limit exceeded

Server Errors

HTTPCodeDescription
5001Unexpected server error — contact support if persistent

Handling Errors

javascript
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();

if (!res.ok) {
  switch (res.status) {
    case 401: // Re-authenticate or check API key
    case 403: // License restricted — check data.code for specifics
    case 404: // Invalid product or key
    case 429: // Back off and retry
      break;
  }
}

Never expose raw API error messages to end users. Map them to user-friendly messages in your application.