Error Handling Guide
This guide explains how errors are structured in the Facilitron Public API and best practices for handling them in your integration.
Error Response Format
All API error responses follow a consistent structure:
Code
HTTP Status Codes
The API uses standard HTTP status codes to indicate the general category of response:
| Status Code | Description |
|---|---|
| 200 | OK – The request was successful |
| 400 | Bad Request – The request contains invalid parameters or is malformed |
| 401 | Unauthorized – Authentication credentials are missing or invalid |
| 403 | Forbidden – Authentication succeeded, but you don't have permission |
| 404 | Not Found – The requested resource could not be found |
| 409 | Conflict – The request could not be completed due to a conflict |
| 429 | Too Many Requests – You’ve exceeded your rate limit quota |
| 500 | Internal Server Error – Something went wrong on our end |
| 502 | Bad Gateway – Received an invalid response from the upstream server |
| 503 | Service Unavailable – Server timeout or service is temporarily unavailable |
| 504 | Gateway Timeout – The server didn't respond in time |
- ** not all endpoints support all error status codes. See API Overview for details
Error Code Categories
Error codes are categorized by domain to simplify troubleshooting:
| Prefix | Category | Description |
|---|---|---|
| PR### | Property | Property-related errors (e.g., not found, access denied) |
| FC### | Facility | Facility-related errors (e.g., not found, access denied) |
| EV### | Event | Event-related errors (e.g., not found, invalid state, conflict, duplicate) |
| SY### | System | System-level errors (e.g., validation, upstream service, timeout) |
| US### | User | User-related errors (e.g., user not found, invalid renter) |
| AU### | Authentication | Authentication and authorization errors (e.g., missing or invalid API key) |
| AC### | Account Config | API key and user-role related configuration errors |
| AT### | Activity Type | Activity-type-specific errors (e.g., not found) |
| RC### | Rate Category | Rate-category-specific errors (e.g., not found) |
| A### | Success | Success codes for confirming normal operations |
Detailed Error Codes
Property Errors (PR###)
| Code | Description | Resolution |
|---|---|---|
| PR001 | Property not found – The property with the specified ID does not exist. | Check that the property ID is correct. |
| PR002 | Property access denied – The API user does not have permission to access this property. | Verify your API user has been granted access to this property. |
| PR003 | Property retrieval failed – An error occurred while fetching property details. | Try again later or contact support if the issue persists. |
Facility Errors (FC###)
| Code | Description | Resolution |
|---|---|---|
| FC001 | Facility not found – The facility with the specified ID could not be located. | Verify the facility ID exists and is active. |
| FC002 | Facility access denied – The facility belongs to a different property and cannot be queried. | Confirm that the facility belongs to a property your API user can access. |
| FC003 | Facility retrieval failed – An error occurred while fetching facility details. | Try again or contact support if the issue persists. |
Event Errors (EV###)
| Code | Description | Resolution |
|---|---|---|
| EV001 | Event not found – No event exists for the provided identifier. | Verify the event ID is correct. |
| EV002 | Time slot not found – The requested time slot for the event does not exist. | Check the time slot ID. |
| EV004 | Event is already declined – The event has been declined and cannot be cancelled or modified. | No action needed - event is already in declined state. |
| EV005 | Event is already cancelled – The event has been cancelled. | No action needed - event is already cancelled. |
| EV006 | Event cannot be modified – The event was not created via the API. | Only events created through the API can be modified through the API. |
| EV007 | Event update failed – An error occurred while updating the event. | Check your inputs and try again. |
| EV008 | Duplicate event creation – The event was already created; duplicate creations are not allowed. | Verify the event doesn't already exist by checking the external_system_event_id. |
| EV009 | Conflicting event schedule – The event conflicts with another scheduled event. | Choose a different time slot that doesn't conflict with existing events. |
| EV010 | Event cancellation failed – An error occurred while cancelling the event. | Try again or contact support. |
System Errors (SY###)
| Code | Description | Resolution |
|---|---|---|
| SY001 | Validation failed – One or more input parameters are invalid or missing. This includes invalid date ranges where the provided date range exceeds the maximum allowed period (31 days) or includes past dates. | Check the request parameters for correct format and required fields. For date ranges, ensure they don't exceed 31 days and don't include past dates. |
| SY002 | Configuration error – Account misconfiguration; please contact support. | Contact Facilitron support for assistance. |
| SY003 | Timeout error – The operation timed out before completion. | Try breaking down your request into smaller chunks or try at a less busy time. |
| SY004 | Internal server error – An unexpected error occurred. | Contact Facilitron support with the invocation_id for assistance. |
| SY005 | Data processing error – There was an error processing the request data. | Check your request data format. |
| SY006 | Too Many Requests – Your account has exceeded the allowed number of requests. | Reduce the request frequency. |
Authentication Errors (AU###)
| Code | Description | Resolution |
|---|---|---|
| AU001 | Missing API key – The request is missing a required API key in the headers. | Include both the API key and API User ID in your request headers. |
| AU002 | Unable to authenticate – The provided API credentials are invalid or missing. | Verify your API credentials are correct. |
| AU003 | Insufficient permissions – The API user does not have sufficient permissions to perform this operation. | Your API user needs additional permissions for this operation. |
AWS Lambda Specific Error Handling
Our API is implemented using AWS Lambda functions with specific timeout configurations:
- Read operations (GET): 30-second timeout
- Write operations (POST, PATCH): 30-second timeout
If you receive a SY003 Timeout error or a 503 Service Unavailable response, your request might be:
- Too large (trying to query too much data at once)
- Made during a period of high system load
- Getting delayed by a Lambda cold start (this will only account for a few seconds of the delay)
Best Practices for Error Handling
- Always check the status code first to determine the category of error.
- Parse the error response to extract the
message_codeandmessage. - Implement retry logic for 429 (rate limit) and 5xx (server) errors with exponential backoff.
- Log the invocation_id for all errors to help with troubleshooting.
- Respect rate limits to avoid being throttled.
- For date range errors (SY001), ensure you're requesting 31 days or less and not including past dates.
Implementing a Robust Error Handler
Here's a pseudocode example of a robust error handling approach that accounts for different error formats:
Code
Response Examples By Status Code
This section provides concrete examples of responses for each status code you might encounter when using the API.
200 OK: Successful Response
Code
Context: This indicates a successful API call. Note that success responses include a message_code that starts with "A".
Handling: Process the data as needed in your application.
400 Bad Request: Invalid Parameters
Code
Context: This error occurs when your request contains invalid parameters. In this example, the date range specified exceeds the 31-day maximum.
Handling: Validate input parameters before making API calls. For date ranges, ensure they don't exceed 31 days.
401 Unauthorized: Authentication Failure
Code
Context: This error occurs when the API key is invalid, or expired.
Handling: Verify that your API credentials are correct.
Code
Context: This error occurs when the API key is missing.
Handling: Verify that your API credentials are properly included in the request headers.
403 Forbidden: Access Denied
Code
Context: This error occurs when your API user doesn't have permission to access the requested resource. This can happen when trying to access a property or facility that isn't in your allowed list.
Handling: Verify that the resource ID is correct and that your API user has been granted access to it. Contact Facilitron support if you need access to additional resources.
404 Not Found: Resource Doesn't Exist
Code
Context: This error occurs when the requested resource (property, facility, or event) doesn't exist.
Handling: Verify that the resource ID is correct. If you're using IDs obtained from previous API calls, ensure your data is up to date.
429 Too Many Requests: Rate Limit Exceeded
Code
Context: This error occurs when you've exceeded your API rate limit quota.
Handling: Implement exponential backoff logic and consider caching frequently accessed data to reduce API calls. If you regularly hit rate limits, contact Facilitron to discuss quota increases.
500 Internal Server Error: Server-Side Issue
Code
Context: This error occurs when an unexpected server-side issue prevents the request from being fulfilled.
Handling: Log the invocation_id and retry the request. If the error persists, contact Facilitron support with the invocation_id for further assistance.
503 Service Unavailable: Timeout
Code
Context: This error occurs when the operation times out before completion. This may happen with complex queries or during periods of high system load.
Handling: Try simplifying your request (e.g., smaller date ranges) or retry at a less busy time. Implement retry logic with exponential backoff.
Example Error Scenarios and Handling
Example 1: Invalid Date Range
Code
Handling: Adjust your start_date and end_date parameters to ensure they don't span more than 31 days and don't include dates in the past.
Example 2: Authentication Failure
Code
Handling: Ensure your request includes the required Authorization header with Bearer YOUR_API_KEY.
Example 3: Resource Not Found
Code
Handling: Check that the property ID exists and your API user has access to it.
Example 4: Rate Limiting
Code
Handling: Rate limit responses follow the HTTP Problem Details format. Implement exponential backoff logic and consider caching results to reduce API calls.
Example 5: Handling Lambda Cold Starts
If you receive occasional 503 errors that resolve on retry, you may be experiencing Lambda cold starts. This happens when a Lambda function hasn't been used recently and needs to be initialized.
Handling:
- Implement retry logic with a 3-5 second delay
- Keep your frequently used endpoints "warm" with periodic lightweight calls
- Consider making API calls during business hours when Lambda functions are likely to be warm
Example 6: Exponential Backoff Implementation
Code
Need Help?
If you encounter persistent errors or need assistance, contact Facilitron API Support with the following information:
- The HTTP status code
- The complete error response including message_code and invocation_id
- Details about your request (endpoint, parameters)
- Date and time when the error occurred
For support, contact [email protected].