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 CodeDescription
200OK - The request was successful
201Created - The resource was successfully created
400Bad Request - The request was invalid or cannot be served
401Unauthorized - Authentication failed or user doesn't have permissions
404Not Found - The resource could not be found
409Conflict - The request conflicts with the current state of the server
429Too Many Requests - Rate limit exceeded
500Internal 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 CodeDescription
INVALID_PARAMETERA required parameter is missing or invalid
AUTHENTICATION_FAILEDThe API key is invalid or missing
LINK_NOT_FOUNDThe requested link could not be found
SLUG_ALREADY_EXISTSThe requested slug is already in use
RATE_LIMIT_EXCEEDEDYou have exceeded the rate limit for API requests
INTERNAL_ERRORAn 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 success field 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