Error Response Format
When an API request fails, the QIMEM Platform returns a structured error response with an appropriate HTTP status code.Standard Error Response
Human-readable error message describing what went wrong.
HTTP Status Codes
The API uses standard HTTP status codes to indicate the success or failure of requests:| Status Code | Meaning | When Used |
|---|---|---|
200 OK | Success | Request completed successfully |
400 Bad Request | Client Error | Invalid input, validation failure, or unsupported operation |
404 Not Found | Resource Not Found | Requested key or resource does not exist |
500 Internal Server Error | Server Error | Unexpected server-side error |
Error Types
The platform defines several error types based on theQimemError enum:
Key Errors
KeyNotFound
HTTP Status:404 Not Found
Returned when a requested encryption key cannot be found in the key store.
- Invalid or non-existent
key_id - Key was deleted or never created
- Wrong key store or database connection
KeyInactive
HTTP Status:400 Bad Request
Returned when attempting to use an inactive (rotated or disabled) key for encryption.
- Use the active key in the lineage
- Rotate to create a new active key version
Envelope Errors
UnsupportedVersion
HTTP Status:400 Bad Request
Returned when the envelope version is not supported by the platform.
- Corrupted envelope data
- Envelope created by incompatible QIMEM version
- Manual envelope modification
UnsupportedAlgorithm
HTTP Status:400 Bad Request
Returned when the encryption algorithm specified in the envelope is not recognized.
0- AES-256-GCM (default)
InvalidEnvelope
HTTP Status:400 Bad Request
Returned when the envelope structure is malformed or cannot be parsed.
- Malformed base64 encoding
- Truncated or corrupted envelope data
- Invalid binary format
Cryptographic Errors
Encryption
HTTP Status:500 Internal Server Error
Returned when encryption operation fails.
- Invalid key material
- Cryptographic library error
- System resource exhaustion
Decryption
HTTP Status:500 Internal Server Error
Returned when decryption operation fails or produces invalid output.
- Tampered envelope or ciphertext
- Authentication tag verification failure
- Wrong key used for decryption
- Corrupted encrypted data
Data Errors
Serialization
HTTP Status:400 Bad Request
Returned when data cannot be serialized or deserialized.
- Invalid JSON in request body
- Missing required fields
- Type mismatch in request parameters
Configuration Errors
Config
HTTP Status:400 Bad Request
Returned when there is a configuration or internal state error.
- Internal concurrency issue
- Invalid server configuration
- Resource initialization failure
Database Errors
Database
HTTP Status:500 Internal Server Error
(Only available with stateful feature enabled)
Returned when a database operation fails.
- Database connection failure
- Query timeout
- Constraint violation
- Transaction conflict
Example Error Scenarios
Encrypting with Non-Existent Key
Request:404 Not Found
Decrypting Invalid Base64
Request:400 Bad Request
Using Inactive Key for Encryption
Request:400 Bad Request
Error Handling Best Practices
Check Status Codes
Always inspect HTTP status codes before parsing response bodies.
Retry Logic
Implement exponential backoff for
500 errors. Never retry 400 or 404 errors.Log Error Messages
Log the full error message for debugging and monitoring.
User-Friendly Messages
Translate technical errors into user-friendly messages in your application.
Debugging Tips
Verify Authentication
Ensure your access token is valid and not expired using
/v1/auth/token/introspect.