Error Codes
A complete reference of error codes you might encounter.
The Sticker Maker API uses standard HTTP response codes to indicate the success or failure of an API request.
Standard HTTP Codes
| Code | Status | Meaning |
|---|---|---|
200 | OK | The request was successful. |
201 | Created | Resource was created successfully. |
202 | Accepted | The request has been accepted for processing (Async). |
400 | Bad Request | The request was unacceptable, often due to missing a required parameter. |
401 | Unauthorized | No valid API key provided. |
402 | Payment Required | Insufficient credits to perform the operation. |
403 | Forbidden | The API key doesn't have permissions to perform the request. |
404 | Not Found | The requested resource doesn't exist. |
429 | Too Many Requests | You have hit the rate limit. |
500 | Server Error | Something went wrong on our end. |
Custom Error Codes
When an error occurs, the response body will contain a success: false flag and an error object with a specific code.
402 Payment Required
INSUFFICIENT_CREDITS
Problem: Your credit balance is too low for the requested operation. Solution: Purchase more credits in the dashboard or reduce the complexity of the request (e.g., lower resolution).
400 Bad Request
VALIDATION_ERROR
Problem: The request parameters do not match the expected schema.
Solution: Check the details array in the response to see which fields failed validation and why.
INVALID_IMAGE_FORMAT
Problem: The source media format is not supported. Solution: Ensure you are uploading a valid JPEG, PNG, WebP, or GIF.
SOURCE_TOO_LARGE
Problem: The source file exceeds the maximum allowed size. Solution: Compress your image or trim your video before uploading.
429 Too Many Requests
RATE_LIMIT_EXCEEDED
Problem: You are making too many requests in a short period.
Solution: Implement exponential backoff in your code. Check the Retry-After header for how many seconds to wait.
Handling Errors
We recommend wrapping your API calls in a try/catch block and checking the error code:
try {
const result = await client.generateSticker(request);
} catch (err) {
if (err.code === "INSUFFICIENT_CREDITS") {
// Handle low balance
console.error("Time to top up!");
} else {
// Handle other errors
console.error(`Error: ${err.message}`);
}
}