API Error Resolution Guide
This guide provides resolution workflows for common REST API errors when integrating with AnkaSecure.
Error Response Format
All AnkaSecure errors follow RFC 7807 (Problem Details for HTTP APIs):
{
"error": "ERROR_CODE",
"message": "Human-readable error description",
"timestamp": "2025-12-26T10:15:30Z",
"traceId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"details": { /* Additional error-specific fields */ }
}
Key Fields:
- error: Machine-readable error code (e.g., AUTH_001, KEY_001)
- message: Human-readable description
- traceId: Correlation ID for support (include when contacting support)
4xx Client Errors
400 Bad Request
Cause: Invalid request format or missing required fields
Resolution Workflow:
-
Validate JSON structure:
-
Check required fields:
-
Verify Content-Type header:
See detailed error: invalid-input →
401 Unauthorized
Cause: Authentication failure
Resolution Workflow:
-
Check Authorization header:
-
Verify X-Tenant-ID header:
-
Test authentication:
See detailed error: unauthorized →
403 Forbidden
Cause: Authorization failure (authenticated but not authorized)
Resolution Workflow:
-
Check resource ownership: Verify key/resource belongs to your tenant
-
Verify permissions: Contact tenant admin to grant required role
- Tenant Admin: Full tenant management
- Application Admin: API key generation, key management
-
User: Cryptographic operations only
-
Check tenant isolation: Cannot access other tenants' resources
See detailed error: forbidden →
404 Not Found
Cause: Resource doesn't exist or endpoint URL incorrect
Resolution Workflow:
-
Verify endpoint URL:
-
Check resource ID: Key ID, user ID, application ID exist
-
List resources:
See detailed error: not-found →
409 Conflict
Cause: Resource already exists
Example: Key ID already in use
Resolution:
-
Use unique ID:
-
Delete existing resource (if replacing):
See detailed error: conflict →
413 Payload Too Large
Cause: Request body >5 MB (use streaming API instead)
Resolution:
Use streaming endpoints for large files:
# ✅ CORRECT: Streaming API for >5 MB
POST /api/v1/crypto/stream/encrypt
# ❌ WRONG: Compact API for large payloads
POST /api/v1/crypto/encrypt # Limited to 5 MB
415 Unsupported Media Type
Cause: Missing or invalid Content-Type header
Resolution:
# ✅ REQUIRED for POST/PUT/PATCH
curl -X POST https://api.ankasecure.com/api/v1/crypto/encrypt \
-H "Content-Type: application/json" # Must include this header
-d '{"keyId":"my-key","plaintext":"..."}'
See detailed error: unsupported-media-type →
422 Unprocessable Entity
Cause: Request valid but cryptographic operation failed
Common Scenarios:
Ciphertext Integrity Failure:
- Solution: Verify ciphertext not corrupted, use correct keyInvalid Key State:
- Solution: Use ACTIVE key, check key statusSee detailed errors: unprocessable-entity →
429 Too Many Requests
Cause: Rate limit exceeded
Resolution Workflow:
-
Check rate limit headers:
-
Wait and retry:
-
Implement exponential backoff:
5xx Server Errors
500 Internal Server Error
Cause: Server-side error (not caused by client)
Resolution Workflow:
-
Retry request: Temporary server issue may resolve on retry
-
Check platform status:
-
Contact support: If persistent, report with trace ID
See detailed error: internal-error →
503 Service Unavailable
Cause: Service temporarily unavailable (maintenance, overload)
Resolution:
-
Check Retry-After header:
-
Wait and retry: Service typically recovers within minutes
-
Check status page:
https://status.ankasecure.com(for SaaS)
See detailed error: service-unavailable →
Error Resolution Flowchart
API Error
│
├── 4xx (Client Error)
│ ├── 400 → Validate request format
│ ├── 401 → Check authentication (token/API key)
│ ├── 403 → Verify permissions and tenant access
│ ├── 404 → Verify resource exists (key ID, endpoint)
│ ├── 409 → Use unique ID or delete existing resource
│ ├── 413 → Use streaming API for large payloads
│ ├── 415 → Add Content-Type: application/json header
│ ├── 422 → Check crypto error details (integrity, key state)
│ └── 429 → Wait (Retry-After) and implement backoff
│
└── 5xx (Server Error)
├── 500 → Retry request, contact support if persistent
└── 503 → Wait (Retry-After), check platform status
Best Practices
1. Always Check HTTP Status Code
try {
EncryptResponse response = client.encrypt(request);
// Success (200 OK)
} catch (AnkaSecureException e) {
switch (e.getHttpStatus()) {
case 401:
// Re-authenticate
break;
case 429:
// Wait and retry (respect Retry-After)
Thread.sleep(e.getRetryAfter() * 1000);
break;
case 500:
// Log and alert (server error)
log.error("Server error [traceId={}]", e.getTraceId());
break;
default:
log.error("Unexpected error: {}", e.getMessage());
}
}
2. Log Correlation IDs
Why: Correlation IDs help support team diagnose issues quickly.
3. Implement Retry Logic
With exponential backoff:
int maxRetries = 3;
int backoffMs = 1000;
for (int i = 0; i < maxRetries; i++) {
try {
return client.encrypt(request);
} catch (RateLimitException e) {
if (i == maxRetries - 1) throw e;
Thread.sleep(backoffMs);
backoffMs *= 2;
}
}
Related Resources
- Common Errors - FAQ-style troubleshooting
- Error Catalog - Complete error code reference (27 codes)
- SDK Troubleshooting - SDK-specific issues
- CLI Troubleshooting - CLI-specific issues
Documentation Version: 3.0.0 Last Updated: 2025-12-26