Error Handling
Understanding error responses and status codes from the NeuralRev Integration API.
The NeuralRev Integration API uses standard HTTP status codes to indicate the success or failure of requests.
HTTP Status Codes
| Code | Meaning | When It Occurs |
|---|---|---|
200 | Success | Request completed successfully |
400 | Bad Request | Validation error or invalid request body |
401 | Unauthorized | Missing or invalid API key |
403 | Forbidden | Key lacks permission or workspace is deactivated |
404 | Not Found | Referenced resource does not exist |
422 | Unprocessable Entity | Request is valid JSON but fails business logic |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Unexpected server-side error |
Error Response Format
All error responses follow a consistent format:
{
"error": "Human-readable error message",
"statusCode": 400
}For validation errors, additional field-level details may be included:
{
"error": "Validation failed",
"statusCode": 400,
"details": [
{"field": "first_name", "message": "Required"},
{"field": "date_of_birth", "message": "Must be a valid ISO 8601 date"}
]
}Common Error Scenarios
401 — Invalid or Missing API Key
{
"error": "Invalid API key",
"statusCode": 401
}Causes:
- No
x-api-keyheader orAuthorization: Bearertoken provided - API key is malformed or does not exist
- API key has been deleted
Resolution: Verify your API key is correct and active in Settings > API Keys.
403 — Permission Denied
{
"error": "API key is deactivated",
"statusCode": 403
}Causes:
- API key has been deactivated (but not deleted)
- The workspace associated with the key has been deactivated
Resolution: Reactivate the key or workspace in Settings.
400 — Referenced Entity Not Found
{
"error": "Payer not found for id: PAYER-999",
"statusCode": 400
}Causes:
- Creating a patient with insurance that references a payer that doesn't exist
- Creating an encounter that references a patient, provider, or facility that doesn't exist
Resolution: Ensure referenced entities are created first. The recommended creation order:
- Payers
- Providers
- Facilities
- Patients (with insurance referencing payers)
- Encounters (referencing patients, providers, facilities)
429 — Rate Limit Exceeded
{
"error": "Too many requests. Please try again later.",
"statusCode": 429,
"retryAfter": 60
}Causes:
- Exceeded 100 requests per minute from the same IP
Resolution: Wait for the retryAfter duration (in seconds), then retry. Implement exponential backoff in your integration.
404 — Resource Not Found
{
"error": "Encounter not found",
"statusCode": 404
}Causes:
- Uploading a document to an encounter ID that doesn't exist
- Deleting a document that doesn't exist
Resolution: Verify the resource ID is correct. Ensure the encounter was created before uploading documents.
Best Practices
Retry Strategy
Implement exponential backoff for transient errors:
async function apiCallWithRetry(fn, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error) {
if (error.status === 429 || error.status >= 500) {
const delay = Math.pow(2, attempt) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
throw error; // Don't retry 4xx errors (except 429)
}
}
throw new Error('Max retries exceeded');
}Error Categorization
| Category | Status Codes | Action |
|---|---|---|
| Client errors | 400, 401, 403, 404, 422 | Fix the request (don't retry) |
| Rate limiting | 429 | Wait and retry |
| Server errors | 500+ | Retry with backoff |
Idempotency
All integration endpoints are idempotent by design (upsert semantics). If you're unsure whether a request succeeded, it's safe to retry — sending the same id will update the existing record rather than create a duplicate.
Monitoring
- Monitor for
401errors to detect key rotation issues - Alert on
429errors to identify integration throughput problems - Track
400errors to catch data quality issues in your EMR sync - All API calls are logged in the NeuralRev audit trail