Errors
The error format, status codes and error codes, and how to handle them
Every failed request returns the same JSON shape: a machine-readable code, a message, the HTTP status, a requestId to quote to support and, where it helps, a suggestion and the fields that failed validation.
Error format
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"statusCode": 422,
"requestId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"errors": [
{
"field": "email",
"message": "Invalid email",
"code": "invalid_string"
}
],
"suggestion": "One or more fields have incorrect types. Check that strings are quoted, numbers are unquoted, and booleans are true/false."
},
"timestamp": "2025-11-30T10:30:00.000Z"
}| Field | Type | Description |
|---|---|---|
success | boolean | Always false for errors |
error.code | string | Machine-readable error code (see below) |
error.message | string | Human-readable error description |
error.statusCode | number | HTTP status code |
error.requestId | string | Unique request identifier for debugging |
error.errors | array | Field-level validation errors (validation errors only) |
error.details | object | Additional context about the error (optional) |
error.suggestion | string | Helpful guidance for fixing the error (optional) |
timestamp | string | ISO 8601 timestamp when the error occurred |
Status codes
| Status | Meaning |
|---|---|
200 OK | The request succeeded. |
201 Created | The resource was created. |
400 Bad Request | The request is malformed or has invalid parameters. Check the error details. |
401 Unauthorized | Authentication is missing or failed. Check your API key. |
402 Payment Required | A billing limit was reached or the operation needs a plan upgrade. Returned with BILLING_LIMIT_EXCEEDED and UPGRADE_REQUIRED. |
403 Forbidden | Not allowed: check permissions and project status. Also returned when email verification is required (EMAIL_VERIFICATION_REQUIRED) or the project is disabled (PROJECT_DISABLED). |
404 Not Found | The resource does not exist. Check the ID. |
409 Conflict | The request conflicts with the resource's current state, such as creating a contact with an email that already exists. Returned with CONFLICT. |
422 Unprocessable Entity | Validation failed. The errors array lists the fields. |
429 Too Many Requests | Rate limit exceeded. Wait before retrying. |
500 Internal Server Error | Something went wrong on our side. Contact support with the request ID. |
Error codes
Handle errors by code rather than by status: several codes share a status.
Authentication and access
| Code | Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | General authentication failure |
INVALID_CREDENTIALS | 401 | Login credentials are incorrect |
MISSING_AUTH | 401 | Authorization header is missing or malformed |
INVALID_API_KEY | 401 | API key is invalid or not found |
FORBIDDEN | 403 | Not allowed to perform this action |
PROJECT_ACCESS_DENIED | 403 | No access to this project |
PROJECT_DISABLED | 403 | Project has been disabled |
EMAIL_VERIFICATION_REQUIRED | 403 | The user's email address must be verified before this action |
Validation
| Code | Status | Description |
|---|---|---|
BAD_REQUEST | 400 | General request error |
VALIDATION_ERROR | 422 | Request validation failed (includes field errors) |
INVALID_EMAIL | 422 | Email format is invalid |
INVALID_REQUEST_BODY | 400 | Request body is malformed |
MISSING_REQUIRED_FIELD | 422 | Required field is missing |
Resources
| Code | Status | Description |
|---|---|---|
RESOURCE_NOT_FOUND | 404 | Generic resource not found |
CONTACT_NOT_FOUND | 404 | Contact does not exist |
TEMPLATE_NOT_FOUND | 404 | Template does not exist |
CAMPAIGN_NOT_FOUND | 404 | Campaign does not exist |
WORKFLOW_NOT_FOUND | 404 | Workflow does not exist |
CONFLICT | 409 | Resource conflict (e.g., duplicate) |
EMAIL_NOT_SCHEDULED | 409 | The email can no longer be rescheduled or cancelled: it is sending, sent or already cancelled |
Rate limits and billing
| Code | Status | Description |
|---|---|---|
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
BILLING_LIMIT_EXCEEDED | 402 | Billing limit reached |
UPGRADE_REQUIRED | 402 | Feature requires plan upgrade |
Server
| Code | Status | Description |
|---|---|---|
INTERNAL_SERVER_ERROR | 500 | Unexpected server error |
DATABASE_ERROR | 500 | Database operation failed |
EXTERNAL_SERVICE_ERROR | 500 | External service unavailable |
Examples
Handling errors in your code
Check success before reading data, log the requestId, and branch on error.code:
try {
const response = await fetch('https://api.send.47signals.com/v1/track', {
method: 'POST',
headers: {
'Authorization': `Bearer ${publicKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
event: 'purchase',
email: 'user@example.com'
})
});
const data = await response.json();
if (!data.success) {
// Handle error
console.error(`Error [${data.error.code}]:`, data.error.message);
// Show suggestion to user
if (data.error.suggestion) {
console.log('Suggestion:', data.error.suggestion);
}
// Log request ID for support
console.log('Request ID:', data.error.requestId);
// Handle specific error types
switch (data.error.code) {
case 'VALIDATION_ERROR':
// Show field-level errors
data.error.errors?.forEach(err => {
console.log(`${err.field}: ${err.message}`);
});
break;
case 'INVALID_API_KEY':
// Prompt user to check their API key
break;
case 'RATE_LIMIT_EXCEEDED':
// Implement retry with backoff
break;
}
return;
}
// Handle success
console.log('Event tracked:', data.data);
} catch (error) {
console.error('Network error:', error);
}Retry only what can succeed later: 429 and 5xx responses, with exponential backoff (1s, 2s, 4s, 8s). A 4xx other than 429 fails the same way until the request changes.
Request IDs
Every response carries a request ID, in error.requestId on errors and in the X-Request-ID header on every response, successful ones included. It traces the request through the API, database, queues and workers, so support can see exactly what happened without asking you for more.
// Example: Logging request ID in your application
const response = await fetch('https://api.send.47signals.com/v1/send', {
// ... your request
});
const requestId = response.headers.get('X-Request-ID');
console.log('Request ID:', requestId); // Log for correlation
const data = await response.json();
if (!data.success) {
console.error('Error:', data.error.message);
console.error('Request ID:', data.error.requestId); // Same as header
}When you contact support, include the request ID, what you were trying to do and, if you can, the full error response.
Common issues
If you are still stuck, check the suggestion field, search these docs for the error code, and contact support with the request ID.