Error Codes
API error codes and how to handle them.
All successful responses return HTTP 200. All errors return a consistent format:
{
"error": {
"message": "Human-readable error message",
"code": "ERROR_CODE"
}
}Error Reference
| HTTP Status | Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid request body or parameters |
| 401 | INVALID_API_KEY | Missing or invalid API key |
| 402 | INSUFFICIENT_CREDITS | Not enough credits for this operation |
| 403 | FORBIDDEN | You don't have access to this resource |
| 404 | NOT_FOUND | Resource not found |
| 409 | ALREADY_PUBLISHED | Post has already been published |
| 413 | FILE_TOO_LARGE | Uploaded file exceeds size limit |
| 413 | STORAGE_QUOTA_EXCEEDED | Account storage quota exceeded |
| 422 | PLATFORM_NOT_CONNECTED | Social platform not connected for publishing |
| 429 | RATE_LIMIT_EXCEEDED | Too many requests |
| 500 | INTERNAL_ERROR | Server error — try again later |
Rate Limits
Rate limits vary by endpoint. When you exceed the limit, you'll receive a 429 response with rate limit headers.
Rate Limit Headers
Every response includes rate limit information:
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: 1736534460Rate Limit Error
{
"error": {
"message": "Rate limit exceeded",
"code": "RATE_LIMIT_EXCEEDED",
"retryAfter": 45
}
}Handling Errors
JavaScript Example
async function generateContent(prompt, postTypes) {
const res = await fetch('https://powerpost.ai/api/v1/content/generate', {
method: 'POST',
headers: {
'x-api-key': process.env.POWERPOST_API_KEY,
'X-Workspace-Id': 'YOUR_WORKSPACE_ID',
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt, post_types: postTypes, research_mode: 'regular' }),
})
if (!res.ok) {
const { error } = await res.json()
switch (error.code) {
case 'INSUFFICIENT_CREDITS':
throw new Error('Please add more credits')
case 'RATE_LIMIT_EXCEEDED':
// Wait and retry
await new Promise((r) => setTimeout(r, error.retryAfter * 1000))
return generateContent(prompt, postTypes)
default:
throw new Error(error.message)
}
}
return res.json()
}Request Tracing
All responses include an X-Request-Id header:
X-Request-Id: 7f3c9a2b-4d5e-6f7g-8h9i-0j1k2l3m4n5oInclude this ID when contacting support for faster debugging.