Skip to main content

Overview

The OFAuth API uses standard HTTP status codes with structured JSON error responses to provide clear, actionable feedback when things go wrong. This systematic approach helps developers quickly identify and resolve issues.

Error Response Format

All API errors return a consistent JSON structure with three core fields:
  • error: a human-readable description of what went wrong
  • code: a machine-readable identifier you can branch on in your client
  • details: optional contextual information such as the affected field

Error Response Fields

FieldTypeDescription
errorstringHuman-readable error message for developers
codestringMachine-readable error code for programmatic handling
detailsobjectAdditional context like field validation errors

HTTP Status Codes

Success Codes

CodeDescriptionWhen Used
200OKRequest successful, data returned
201CreatedResource successfully created
204No ContentRequest successful, no data to return

Client Error Codes

CodeCategoryDescriptionAction Required
400Client ErrorInvalid request parametersFix request format/data
401Client ErrorInvalid/missing API keyCheck authentication
403Client ErrorInsufficient permissionsContact support
404Client ErrorResource not foundCheck endpoint URL
422Client ErrorValidation failedFix request data
429Client ErrorRate limit exceededWait and retry

Server Error Codes

CodeCategoryDescriptionAction Required
500Server ErrorInternal server errorRetry or contact support
502Server ErrorUpstream service errorRetry or contact support
503Server ErrorService unavailableCheck status page
504Server ErrorGateway timeoutRetry with longer timeout

Error Code Categories

Authentication Errors (AUTH_*)

CodeHTTP StatusDescriptionResolution
AUTH_INVALID_KEY401API key is invalid or malformedVerify API key format and validity
AUTH_KEY_EXPIRED401API key has expiredGenerate new API key
AUTH_INSUFFICIENT_SCOPE403API key lacks required permissionsContact support for permission upgrade
AUTH_CONNECTION_NOT_FOUND404Connection ID doesn’t existRe-authenticate user
AUTH_SESSION_EXPIRED401User session has expiredRe-authenticate user

Validation Errors (VALIDATION_*)

CodeHTTP StatusDescriptionResolution
VALIDATION_REQUIRED_FIELD422Required field missingAdd missing field to request
VALIDATION_INVALID_FORMAT422Field format is incorrectFix field format
VALIDATION_INVALID_VALUE422Field value is invalidUse valid field value
VALIDATION_FIELD_TOO_LONG422Field exceeds maximum lengthShorten field value

Rate Limiting Errors (RATE_LIMIT_*)

CodeHTTP StatusDescriptionResolution
RATE_LIMIT_EXCEEDED429Request rate limit exceededWait and retry with backoff
RATE_LIMIT_QUOTA_EXCEEDED429Monthly quota exceededUpgrade plan or wait for reset

Connection Errors (CONNECTION_*)

CodeHTTP StatusDescriptionResolution
CONNECTION_NOT_FOUND404Connection ID not foundRe-authenticate user
CONNECTION_EXPIRED401Connection has expiredRe-authenticate user
CONNECTION_INVALID_STATE400Connection in invalid stateCheck connection status
CONNECTION_LIMIT_EXCEEDED403Too many connectionsRemove unused connections

Upstream Errors (UPSTREAM_*)

CodeHTTP StatusDescriptionResolution
UPSTREAM_UNAVAILABLE502OnlyFans API unavailableRetry after delay
UPSTREAM_TIMEOUT504OnlyFans API timeoutRetry with longer timeout
UPSTREAM_RATE_LIMITED429OnlyFans rate limit hitWait and retry
UPSTREAM_INVALID_RESPONSE502Unexpected upstream responseReport to support

Dynamic Rules Errors (RULES_*)

CodeHTTP StatusDescriptionResolution
RULES_OUTDATED503Dynamic rules need updatingWait and retry
RULES_UNAVAILABLE503Rules service unavailableWait and retry
RULES_INVALID_SIGNATURE401Request signature invalidUpdate rules and regenerate signature

Error Handling Examples

Basic Error Handling

Follow these practices when calling the API from client code:
  • Check response.ok before parsing the body and surface the HTTP status in your logs.
  • Parse the JSON payload and branch on errorData.code to determine the recovery path.
  • Redirect users to re-authentication when you receive connection or session errors.
  • Respect the X-RateLimit-Retry-After header and pause before retrying rate-limited calls.
  • Bubble up unexpected errors so they can be reported to your monitoring stack.

Advanced Error Handler Class

Build a reusable error-handling helper so every request is treated consistently. The helper should:
  • Centralize logging of HTTP status codes, request identifiers, and the parsed error payload.
  • Categorize errors (retryable, authentication, validation) to route them to the right recovery logic.
  • Apply backoff to retryable errors and honour server-provided retry hints.
  • Trigger re-authentication flows when connection or session errors are detected.
  • Raise typed exceptions (for example ApiError, AuthError, ValidationError) so downstream code can react precisely.

Validation Error Details

Validation errors include specific field information. Expect details.field to identify the problematic input, details.message to describe the issue, and details.value (when provided) to show what was rejected. Handle validation errors with user-friendly messages by mapping the fields in details to UI controls, highlighting the inputs that need attention, and surfacing the descriptive message inline for the user.

Debugging Tips

Use Error Codes

Always check the code field for programmatic error handling

Log Full Responses

Log complete error responses for debugging and support

Monitor Error Patterns

Track error frequency and types to identify issues

Test Error Scenarios

Test your error handling with intentional invalid requests

Error Monitoring

Implement error tracking for production applications by storing structured error metadata, tracking frequency per error code, sending alerts when thresholds are exceeded, and forwarding enriched events (timestamp, status, stack trace, and request context) to your monitoring platform.

Common Error Scenarios

Authentication Issues

When you receive authentication or connection errors:
  • Inspect the response body for CONNECTION_EXPIRED, AUTH_SESSION_EXPIRED, or related codes.
  • Inform the user that they must reconnect and send them through the hosted re-authentication flow.
  • Clear cached credentials so the next attempt starts with a fresh session.
  • Log the status, code, and affected connection ID for support follow-up.

Rate Limiting

Handle rate limits by adopting exponential backoff. Read the X-RateLimit-Retry-After header (it defaults to 60 seconds when missing), pause before the next attempt, and stop retrying once the maximum retry count has been reached. Track cumulative failures so you know when to surface a persistent outage to the user.

Next Steps