Error Handling

Error codes, format, and retry strategies.

Edit this page·Last updated: July 13, 2026

Error Handling

All errors follow a consistent JSON format.

Error format

{
  "error": {
    "code": "validation_error",
    "message": "text is required",
    "field": "text",
    "docs": "https://docs.pepe.business/errors#validation_error"
  },
  "requestId": "req_xxx"
}

HTTP codes

CodeMeaning
400Invalid request (validation)
401Unauthenticated
403Insufficient permissions
404Resource not found
409Conflict (duplicate slug)
422Unprocessable entity
429Rate limit exceeded
500pepe server error
502Underlying platform error (Twitter, etc.)
503Service unavailable

Error codes

CodeCause
validation_errorInvalid or missing field
unauthorizedMissing or invalid API key
forbiddenInsufficient scope
not_foundNonexistent resource
rate_limit_exceededToo many requests
platform_errorError on the social network side
media_too_largeFile exceeding the limit
account_disconnectedThe OAuth account has expired
duplicate_slugSlug already used
webhook_failedWebhook delivery failed

Automatic retry

5xx and 429 errors can be retried. 4xx errors must never be retried (client-side error).

Idempotency

For sensitive POST/PATCH, add an Idempotency-Key header:

POST /v1/posts
Idempotency-Key: my-unique-key-123
{...}

If the same key is used twice, the second request returns the response of the first without recreating the resource. Useful for retries without risk of duplication.

Logging

Always log the requestId to facilitate support:

try {
  await pepe.posts.create({...});
} catch (err) {
  console.error(`[req:${err.requestId}] pepe error: ${err.code}`);
}

Was this page helpful?