Skip to content

Error Codes

Complete reference for Vettly API error responses.

HTTP Status Codes

StatusNameDescription
200OKRequest successful
201CreatedResource created
400Bad RequestMalformed request syntax
401UnauthorizedInvalid or missing API key
402Payment RequiredQuota exceeded
403ForbiddenInsufficient permissions
404Not FoundResource not found
422Unprocessable EntityValidation error
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error
503Service UnavailableTemporarily unavailable

Error Response Format

All errors return a consistent JSON structure:

json
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Try again in 30 seconds.",
    "details": {
      "limit": 100,
      "remaining": 0,
      "reset": 1699999999
    }
  }
}

Fields

FieldTypeDescription
error.codestringMachine-readable error code
error.messagestringHuman-readable description
error.detailsobjectAdditional context (optional)

Error Codes by Category

Authentication Errors (401)

CodeMessageSolution
INVALID_API_KEYInvalid API key providedCheck your API key is correct
EXPIRED_API_KEYAPI key has expiredGenerate a new key in dashboard
MISSING_API_KEYNo API key providedAdd Authorization: Bearer sk_live_... header
REVOKED_API_KEYAPI key was revokedGenerate a new key in dashboard

Quota Errors (402)

CodeMessageSolution
QUOTA_EXCEEDEDMonthly quota exceededUpgrade plan or wait for reset
TRIAL_EXPIREDFree trial has endedAdd payment method

Permission Errors (403)

CodeMessageSolution
INSUFFICIENT_PERMISSIONSAPI key lacks required permissionsUse a key with appropriate scopes
POLICY_NOT_ACCESSIBLECannot access this policyCheck policy ownership

Not Found Errors (404)

CodeMessageSolution
POLICY_NOT_FOUNDPolicy does not existCheck policy ID is correct
DECISION_NOT_FOUNDDecision does not existCheck decision ID is correct
WEBHOOK_NOT_FOUNDWebhook does not existCheck webhook ID is correct

Validation Errors (422)

CodeMessageSolution
INVALID_CONTENTContent is invalidCheck content format
CONTENT_TOO_LARGEContent exceeds size limitReduce content size
INVALID_CONTENT_TYPEUnsupported content typeUse text, image, or video
INVALID_POLICY_IDPolicy ID format is invalidUse valid policy ID format
INVALID_IMAGE_URLImage URL is not accessibleCheck URL is public
INVALID_BASE64Base64 encoding is invalidFix base64 encoding
MISSING_REQUIRED_FIELDRequired field is missingAdd required field
INVALID_METADATAMetadata format is invalidCheck metadata is valid JSON

Rate Limit Errors (429)

CodeMessageSolution
RATE_LIMIT_EXCEEDEDToo many requestsWait and retry with backoff
BURST_LIMIT_EXCEEDEDBurst limit exceededSlow down request rate

Server Errors (5xx)

CodeMessageSolution
INTERNAL_ERRORInternal server errorRetry automatically
SERVICE_UNAVAILABLEService temporarily unavailableCheck status page
PROVIDER_ERRORAI provider errorRetry automatically

Rate Limit Headers

Rate limited responses include headers:

http
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1699999999
Retry-After: 30
HeaderDescription
X-RateLimit-LimitRequests allowed per window
X-RateLimit-RemainingRequests remaining in window
X-RateLimit-ResetUnix timestamp when window resets
Retry-AfterSeconds to wait before retrying

Endpoint-Specific Errors

POST /v1/check

CodeCause
INVALID_CONTENTContent format invalid
CONTENT_TOO_LARGEExceeds 32KB (text) or 20MB (image)
INVALID_CONTENT_TYPENot text, image, or video
POLICY_NOT_FOUNDPolicy ID doesn't exist

POST /v1/batch

CodeCause
TOO_MANY_ITEMSExceeds 100 items per batch
INVALID_BATCH_ITEMItem in batch is invalid

POST /v1/policies

CodeCause
INVALID_YAMLPolicy YAML is malformed
INVALID_THRESHOLDThreshold not between 0 and 1
INVALID_ACTIONAction not allow/flag/warn/block
DUPLICATE_POLICY_IDPolicy ID already exists

Webhook Endpoints

CodeCause
INVALID_WEBHOOK_URLURL is not valid HTTPS
WEBHOOK_URL_UNREACHABLECannot connect to URL
INVALID_EVENT_TYPEEvent type not recognized

SDK Exception Mapping

SDKs map error codes to typed exceptions:

HTTP StatusTypeScriptPython
401VettlyAuthErrorVettlyAuthError
402VettlyQuotaErrorVettlyQuotaError
422VettlyValidationErrorVettlyValidationError
429VettlyRateLimitErrorVettlyRateLimitError
5xxVettlyErrorVettlyServerError

Best Practices

  1. Always check error codes, not just HTTP status
  2. Log error details for debugging
  3. Implement automatic retry for 429 and 5xx
  4. Don't retry 401, 402, 403, 422 errors
  5. Use SDK typed exceptions for cleaner code
typescript
try {
  await client.check({ ... })
} catch (error) {
  // Log full error for debugging
  console.error({
    code: error.code,
    message: error.message,
    details: error.details
  })

  // Handle by type
  if (error instanceof VettlyRateLimitError) {
    // Retry after delay
  } else if (error instanceof VettlyValidationError) {
    // Fix request and retry
  }
}

See Also