Error Handling
Learn how to handle errors from the Shortify API.
Error Response Format
When an error occurs, the API will return an error response with details about what went wrong. All error responses include a success: false field and anerror message.
400
Example Error Response{
"success": false,
"error": "shortLink parameter is required"
}HTTP Status Codes
The Shortify API uses standard HTTP status codes to indicate the success or failure of an API request.
| Status Code | Description |
|---|---|
| 200 | OK - The request was successful |
| 201 | Created - The resource was successfully created |
| 400 | Bad Request - The request was invalid or cannot be served |
| 401 | Unauthorized - Authentication failed or user doesn't have permissions |
| 404 | Not Found - The resource could not be found |
| 409 | Conflict - The request conflicts with the current state of the server |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Server encountered an unexpected condition |
Common Error Codes
The following are common error codes that you may encounter when using the Shortify API:
| Error Code | Description |
|---|---|
| INVALID_PARAMETER | A required parameter is missing or invalid |
| AUTHENTICATION_FAILED | The API key is invalid or missing |
| LINK_NOT_FOUND | The requested link could not be found |
| SLUG_ALREADY_EXISTS | The requested slug is already in use |
| RATE_LIMIT_EXCEEDED | You have exceeded the rate limit for API requests |
| INTERNAL_ERROR | An unexpected error occurred on the server |
Error Handling Best Practices
Here are some best practices for handling errors from the Shortify API:
- Always check the
successfield in the response to determine if the request was successful - Handle specific error codes appropriately in your application
- Implement retry logic with exponential backoff for rate limiting errors
- Log detailed error information for debugging purposes
- Display user-friendly error messages to your users