Error Reference
Errors return a non-2xx HTTP status and a JSON body:
{ "success": false, "message": "Monitor not found" }Validation errors (400) describe the field that failed, e.g. Minimum interval is 60 seconds.
HTTP status codes
| Status | Meaning |
|---|---|
200 | Success |
400 | Bad request — invalid body or parameters (the message names the field) |
401 | Unauthorized — missing, invalid, revoked or expired API key |
403 | Forbidden — your plan or role does not allow this action |
404 | Not found — the resource doesn't exist or doesn't belong to your team |
429 | Too many requests — rate limit exceeded |
500 | Internal server error — contact support |
Handling errors in code
const res = await fetch('https://api.securecheap.com/api/v1/monitors', {
headers: { 'X-API-Key': process.env.SECURECHEAP_API_KEY },
})
if (!res.ok) {
const { message } = await res.json()
console.error(`[${res.status}] ${message}`)
if (res.status === 429) {
const wait = Number(res.headers.get('RateLimit-Reset') || 60)
await new Promise(r => setTimeout(r, wait * 1000))
}
return
}
const { monitors } = await res.json()