Skip to content

Errors

All API errors return a consistent JSON format with a machine-readable error code and human-readable message.

{
"error": "Human-readable error message",
"code": "ERROR_CODE"
}

Some errors include additional fields:

{
"error": "Usage limit exceeded",
"code": "USAGE_LIMIT_EXCEEDED",
"usage": { "used": 5000, "limit": 5000 },
"upgradeUrl": "https://app.promptlycms.com/settings?upgrade"
}
FieldTypeAlways presentDescription
errorstringYesHuman-readable error message
codestringYesMachine-readable error code
usageobjectNoUsage data (only on 429 responses)
upgradeUrlstringNoPlan upgrade link (only on 429 responses)
{
"error": "Missing or invalid API key",
"code": "UNAUTHORIZED"
}

Cause: The Authorization header is missing or empty.

Solution: Include a valid Bearer token: Authorization: Bearer pk_live_...

{
"error": "Prompt not found",
"code": "NOT_FOUND"
}

Cause: The prompt ID does not exist or the prompt has not been published.

Solution: Check the prompt ID in your CMS dashboard. Make sure the prompt is published - drafts are not accessible via the API.

{
"error": "Invalid request",
"code": "BAD_REQUEST"
}

Cause: The request is malformed (e.g. invalid prompt ID format).

Solution: Check that your request URL and parameters are correctly formatted.

{
"error": "Usage limit exceeded",
"code": "USAGE_LIMIT_EXCEEDED",
"usage": { "used": 5000, "limit": 5000 },
"upgradeUrl": "https://app.promptlycms.com/settings?upgrade"
}

Cause: You have exceeded your monthly request quota.

Solution: Upgrade your plan at the provided upgradeUrl, or wait for your quota to reset. See Rate Limits for details on plan tiers and best practices.

{
"error": "Method not allowed",
"code": "METHOD_NOT_ALLOWED"
}

Cause: You used an HTTP method other than GET or OPTIONS.

Solution: The API is read-only. Use GET for all requests.

{
"error": "Internal server error",
"code": "INTERNAL_ERROR"
}

Cause: An unexpected error occurred on the server.

Solution: Retry the request. If the error persists, contact support.

const response = await fetch(
`https://api.promptlycms.com/prompts/${promptId}`,
{
headers: { Authorization: `Bearer ${apiKey}` },
},
);
if (!response.ok) {
const body = await response.json();
if (body.code === 'NOT_FOUND') {
console.error(`Prompt "${promptId}" not found`);
return null;
}
if (body.code === 'USAGE_LIMIT_EXCEEDED') {
console.error('Rate limited:', body.usage);
console.error('Upgrade at:', body.upgradeUrl);
return null;
}
throw new Error(`API error: ${body.code} - ${body.error}`);
}
const prompt = await response.json();
CodeHTTP StatusIssueSolution
UNAUTHORIZED401Missing API keyAdd Authorization: Bearer pk_live_... header
INVALID_KEY401Invalid or revoked keyCheck or regenerate key in dashboard
NOT_FOUND404Prompt does not existVerify prompt ID and publish status
VERSION_NOT_FOUND404Version does not existOmit version or check available versions
BAD_REQUEST400Malformed requestCheck URL and parameter format
USAGE_LIMIT_EXCEEDED429Monthly quota exceededUpgrade plan or wait for reset
METHOD_NOT_ALLOWED405Wrong HTTP methodUse GET requests only
INTERNAL_ERROR500Server errorRetry the request