Errors
Scrub uses conventional HTTP status codes to indicate success or failure of API requests.
HTTP Status Codes
| Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid request format or parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Request blocked due to PHI (if blocking mode enabled) |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
502 | Bad Gateway - Error from upstream AI provider |
503 | Service Unavailable |
Error Response Format
{
"error": {
"message": "Description of what went wrong",
"type": "error_type",
"code": "error_code"
}
}
Common Errors
Invalid API Key
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
Solution: Check that your API key is correct and hasn't been revoked.
PHI Blocked
{
"error": {
"message": "Request blocked: PHI detected in content",
"type": "phi_error",
"code": "phi_blocked",
"phi_types": ["ssn", "date_of_birth"]
}
}
Solution: Remove PHI from your request, or switch to redact/mask mode in Settings.
Provider Not Configured
{
"error": {
"message": "No AI provider configured. Please add a provider key in your dashboard.",
"type": "configuration_error",
"code": "no_provider"
}
}
Solution: Go to Providers in your Dashboard and add your AI provider's API key.
Rate Limit Exceeded
{
"error": {
"message": "Rate limit exceeded. Please retry after 60 seconds.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}
Solution: Wait and retry, or contact support to increase your limits.
Upstream Provider Error
{
"error": {
"message": "Error from AI provider: insufficient_quota",
"type": "upstream_error",
"code": "provider_error"
}
}
Solution: Check your AI provider account for quota/billing issues.
Handling Errors
We recommend implementing retry logic with exponential backoff for transient errors (429, 500, 502, 503):
import time
import requests
def make_request_with_retry(url, headers, data, max_retries=3):
for attempt in range(max_retries):
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
return response.json()
if response.status_code in [429, 500, 502, 503]:
wait_time = (2 ** attempt) + 1 # Exponential backoff
time.sleep(wait_time)
continue
# Non-retryable error
response.raise_for_status()
raise Exception("Max retries exceeded")