Skip to main content

Error Handling

The Formstamper API uses standard HTTP status codes and returns consistent error response formats.

HTTP Status Codes

CodeMeaningWhen Used
200OKRequest succeeded
201CreatedResource created successfully
202AcceptedRequest accepted for async processing (webhooks)
400Bad RequestInvalid input, validation error, malformed JSON
401UnauthorizedMissing or expired authentication token
403ForbiddenValid auth, but insufficient permissions
404Not FoundResource doesn't exist
409ConflictResource already exists (e.g., duplicate email)
423LockedAccount is disabled
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error

Error Response Format

Most error responses include a descriptive message:

{
"error": "Bad Request",
"message": "Payload validation failed: missing required field 'tenant_name'",
"status": 400
}

For validation errors, additional field-level details may be included:

{
"error": "Validation Failed",
"message": "Invalid input",
"status": 400,
"fieldErrors": [
{
"field": "email",
"message": "must be a valid email address"
},
{
"field": "password",
"message": "must be at least 8 characters"
}
]
}

Common Error Scenarios

Authentication Errors

ScenarioStatusMessage
No token provided401Missing or invalid token
Expired access token401Token has expired
Invalid refresh token401Invalid refresh token
Account not verified403Email not verified
Account locked423Account is disabled
2FA required200Returns requires2FA: true

Permission Errors

ScenarioStatusMessage
Non-admin accessing admin endpoints403Access denied
Accessing another user's workflow403You do not have permission
Org member editing org settings403Insufficient role

Resource Errors

ScenarioStatusMessage
Template not found404Template not found
Workflow not found404Workflow not found
Webhook for unknown workflow404Workflow not found!
Duplicate email registration409Email already registered

Rate Limiting

When rate limited, the response includes retry headers:

HTTP/1.1 429 Too Many Requests
Retry-After: 60
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1712930400

Best Practices

:::tip Error Handling Tips

  1. Always check the status code before parsing the response body.
  2. Implement token refresh logic — when you get a 401, try refreshing the access token before retrying.
  3. Handle rate limits gracefully — respect the Retry-After header and implement exponential backoff.
  4. Log error responses — include the full error message for debugging.
  5. Validate on the client side — catch obvious errors (empty fields, invalid emails) before sending API requests. :::