Error Codes
Reference for all API error responses.
Error Response Format
All errors follow this format:
{
"error": "error_code",
"message": "Human-readable description of the error.",
"details": {
// Additional context (optional)
}
}HTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid input |
| 401 | Unauthorized - Invalid API key |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Resource doesn't exist |
| 429 | Too Many Requests - Rate limited |
| 500 | Internal Server Error |
| 503 | Service Unavailable |
Authentication Errors (401)
missing_api_key
{
"error": "missing_api_key",
"message": "API key is required. Include it in the X-API-Key header."
}Fix: Add the X-API-Key header to your request.
invalid_api_key
{
"error": "invalid_api_key",
"message": "The API key provided is invalid or has been revoked."
}Fix: Check your API key is correct and hasn't been revoked.
Request Errors (400)
invalid_request
{
"error": "invalid_request",
"message": "The request body is not valid JSON."
}Fix: Ensure you're sending valid JSON with Content-Type: application/json.
missing_field
{
"error": "missing_field",
"message": "The 'text' field is required.",
"details": {
"field": "text"
}
}Fix: Include all required fields in your request.
text_too_long
{
"error": "text_too_long",
"message": "Text exceeds maximum length of 10,000 characters.",
"details": {
"max_length": 10000,
"actual_length": 15234
}
}Fix: Split long text into smaller chunks.
invalid_mode
{
"error": "invalid_mode",
"message": "Invalid verification mode. Use 'blocking', 'flagging', or 'logging'.",
"details": {
"provided": "strict",
"valid_modes": ["blocking", "flagging", "logging"]
}
}Fix: Use one of the valid mode values.
Permission Errors (403)
insufficient_permissions
{
"error": "insufficient_permissions",
"message": "Your API key does not have permission for this action.",
"details": {
"required_scope": "keys:write",
"current_scopes": ["verify", "harm_detect"]
}
}Fix: Use an API key with the required scopes.
quota_exceeded
{
"error": "quota_exceeded",
"message": "You have exceeded your monthly verification limit.",
"details": {
"current_usage": 50000,
"monthly_limit": 50000,
"resets_at": "2024-02-01T00:00:00Z"
}
}Fix: Upgrade your plan or wait for the next billing cycle.
Rate Limit Errors (429)
rate_limit_exceeded
{
"error": "rate_limit_exceeded",
"message": "You have exceeded your rate limit of 200 requests per minute.",
"details": {
"limit": 200,
"window": "1 minute",
"retry_after": 45
}
}Fix: Wait for retry_after seconds or implement exponential backoff.
Response Headers
Rate-limited responses include:
Retry-After: 45
X-RateLimit-Limit: 200
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1705765200Server Errors (5xx)
internal_error
{
"error": "internal_error",
"message": "An unexpected error occurred. Please try again.",
"details": {
"request_id": "req_abc123"
}
}Fix: Retry the request. If persistent, contact support with the request_id.
service_unavailable
{
"error": "service_unavailable",
"message": "The service is temporarily unavailable. Please try again later.",
"details": {
"retry_after": 60
}
}Fix: Wait and retry. Check status.glyphnet.io (opens in a new tab) for updates.
Handling Errors
Python Example
import requests
def verify_text(text: str) -> dict:
response = requests.post(
"https://api.glyphnet.io/v1/verify",
headers={"X-API-Key": API_KEY},
json={"text": text}
)
if response.status_code == 200:
return response.json()
error = response.json()
if response.status_code == 429:
retry_after = int(response.headers.get("Retry-After", 60))
raise RateLimitError(f"Rate limited. Retry after {retry_after}s")
if response.status_code == 401:
raise AuthenticationError(error["message"])
if response.status_code == 400:
raise ValidationError(error["message"])
raise APIError(f"API error: {error['message']}")JavaScript Example
async function verifyText(text) {
const response = await fetch('https://api.glyphnet.io/v1/verify', {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ text })
});
if (response.ok) {
return response.json();
}
const error = await response.json();
switch (response.status) {
case 429:
const retryAfter = response.headers.get('Retry-After') || 60;
throw new RateLimitError(`Rate limited. Retry after ${retryAfter}s`);
case 401:
throw new AuthenticationError(error.message);
case 400:
throw new ValidationError(error.message);
default:
throw new APIError(`API error: ${error.message}`);
}
}Support
If you encounter persistent errors:
- Check status.glyphnet.io (opens in a new tab)
- Include the
request_idfrom error responses - Contact support@glyphnet.io