Error Handling
The API uses standard HTTP status The Giftoin API uses standard HTTP status codes to indicate the success or failure of an API call. Understanding these error codes will help you troubleshoot issues and handle errors gracefully in your application.
200 (OK)
- The request was successful400 (Bad Request)
- The server could not process the request, most likely because of an invalid argument401 (Unauthorized)
- Your request lacks valid authentication credentials, your API key is missing in the request headers402 (Payment Required)
- Your API request was rejected due to it being a paid subscription plan with an overdue balance403 (Forbidden)
- Your request was rejected due to a permission issue, likely a restriction on the API Key's associated service plan404 (Not Found)
- The requested resource was not found429 (Too Many Requests)
- The API Key's rate limit was exceeded500 (Internal Server Error)
- An unexpected server issue was encountered
Error Response Codes
When an error occurs, the API returns a JSON response with a status object containing:
timestamp
- The time when the error occurrederrorCode
- A numeric code specific to the errorerrorMessage
- A human-readable description of the error
Error Code Reference
Here's a reference of specific error codes you might encounter:
400
1001 [API_KEY_INVALID]
This API Key is invalid.
401
1002 [API_KEY_MISSING]
API key missing.
404
5250[CAMPAIGN_NOT_FOUND]
Campaign not found
404
5252[CAMPAIGN_ORDER_NOT_FOUND]
Order not found
Handling Errors in Your Code
Here are some best practices for handling API errors:
Check for HTTP status codes first - Handle different categories of errors differently (e.g., client errors vs. server errors)
Parse the error message and code - Extract specific information about what went wrong
Implement retry logic for certain errors - For example, retrying after a brief delay for rate limit errors (429)
Log detailed error information - Store the complete error response for debugging
Provide user-friendly error messages - Translate API errors into helpful information for your users
Example error handling in JavaScript:
Last updated
Was this helpful?