Skip to main content

Error handling

This guide covers error handling for the k-ID API, including common error codes, error response formats, and best practices for handling errors.

Error response format

All API errors follow a consistent response format. Error responses include an error field and an errorMessage field:

{
"error": "ERROR_CODE",
"errorMessage": "Human-readable error message"
}

HTTP status codes

The k-ID API uses standard HTTP status codes to indicate the result of API requests:

Status CodeDescriptionWhen It Occurs
200OKRequest successful
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Common error codes

Authentication errors

UNAUTHORIZED

Status: 401
Description: Invalid or missing API key

{
"error": "UNAUTHORIZED",
"errorMessage": "Unauthorized"
}

Common causes:

  • Missing Authorization header
  • Invalid API key format
  • Expired API key

Resolution:

  • Verify API key is correct
  • Check if key is active and not expired
  • Ensure key is properly formatted in Authorization header

Request validation errors

INVALID_INPUT

Status: 400
Description: Request validation failed

{
"error": "INVALID_INPUT",
"errorMessage": "The age verification could not be found."
}

Resolution:

  • Review validation error details
  • Correct the invalid field values
  • Refer to API documentation for valid values

Resource errors

Rate limiting errors

Status: 429
Description: Rate limit exceeded No Response Body

Resolution:

  • Implement exponential backoff
  • Reduce request frequency
  • Cache responses when appropriate

Server errors

Status: 500
Description: Internal server error

{
"error": "INTERNAL_ERROR",
"errorMessage": "Internal server error"
}

Resolution:

  • Retry the request after a delay
  • Contact support if error persists
  • Check service status page

Next steps