Error Codes
When an error occurs, the API returns a JSON response with success: false:
json
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error message"
}
}Error Reference
Authentication Errors
| Code | Status | Description | Resolution |
|---|---|---|---|
MISSING_AUTH | 401 | Authorization header is missing | Add Authorization: Bearer YOUR_API_KEY header |
INVALID_API_KEY | 401 | API key is invalid or has been revoked | Check your API key or generate a new one |
INVALID_TOKEN | 401 | JWT token is invalid or expired | Refresh your authentication token |
SUBSCRIPTION_REQUIRED | 403 | Active Pro subscription required | Upgrade to Pro at shotprose.com/pricing |
Request Errors
| Code | Status | Description | Resolution |
|---|---|---|---|
INVALID_REQUEST | 400 | Request body is invalid | Check JSON syntax and required fields |
MISSING_SCREENSHOT | 400 | No screenshot provided | Include screenshot_url or screenshot_base64 |
RATE_LIMITED | 429 | Rate limit exceeded | Wait and retry after the Retry-After period |
Server Errors
| Code | Status | Description | Resolution |
|---|---|---|---|
RENDER_TIMEOUT | 504 | Render operation timed out | Try a simpler configuration or retry |
RENDER_FAILED | 500 | Failed to generate mockup | Check screenshot URL accessibility |
INTERNAL_ERROR | 500 | Unexpected server error | Retry or contact support |
Handling Errors
JavaScript
javascript
const response = await fetch('https://shotprose.com/api/v1/mockup', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
const data = await response.json();
if (!data.success) {
switch (data.error.code) {
case 'RATE_LIMITED':
// Wait and retry
const retryAfter = response.headers.get('Retry-After');
await sleep(parseInt(retryAfter) * 1000);
break;
case 'INVALID_API_KEY':
// Handle authentication error
throw new Error('Please check your API key');
default:
throw new Error(data.error.message);
}
}Python
python
import requests
import time
response = requests.post(
'https://shotprose.com/api/v1/mockup',
headers={'Authorization': f'Bearer {api_key}'},
json=request_body
)
data = response.json()
if not data['success']:
error_code = data['error']['code']
if error_code == 'RATE_LIMITED':
retry_after = int(response.headers.get('Retry-After', 60))
time.sleep(retry_after)
elif error_code == 'INVALID_API_KEY':
raise Exception('Please check your API key')
else:
raise Exception(data['error']['message'])Best Practices
- Always check
success- Don't assume the request succeeded - Handle rate limits gracefully - Implement exponential backoff
- Log error codes - Makes debugging easier
- Validate inputs - Catch errors before making API calls