SocialCrawl

Error Handling

SocialCrawl API error codes, refund rules, and how to handle each failure

Error Handling

All errors follow the same envelope format:

{
  "success": false,
  "error": {
    "type": "INSUFFICIENT_CREDITS",
    "message": "Your account has 0 credits remaining. This endpoint requires 1 credits.",
    "status": 402,
    "doc_url": "https://www.socialcrawl.dev/docs/errors/insufficient-credits"
  },
  "credits_remaining": 0,
  "request_id": "req-abc123"
}

Every response — success or error — includes an X-Request-Id header matching request_id. Include it when contacting support so we can trace the exact request in our logs.

Error Codes

CodeStatusDescriptionAction
MISSING_API_KEY401No x-api-key header on the requestAdd the x-api-key header
INVALID_API_KEY401Key is malformed, not found, revoked, or expiredCheck the key in Dashboard → API Keys
INSUFFICIENT_CREDITS402Balance is lower than the endpoint costTop up in Dashboard → Billing
INVALID_REQUEST400Missing required params, failed format validation, or no oneOf member satisfiedCheck the endpoint's required parameters
METHOD_NOT_ALLOWED405Non-GET method against /v1/*. Response includes an Allow: GET headerUse GET
ENDPOINT_NOT_FOUND404Platform or resource is not supportedCheck the API Reference
RESOURCE_NOT_FOUND404Upstream returned 404, or the resource exists but contains no usable data. Credits refunded when triggered by empty upstreamVerify the handle/URL exists
IDEMPOTENCY_KEY_CONFLICT409The Idempotency-Key you sent is already in use by another accountGenerate a fresh key (UUIDv4 recommended)
IDEMPOTENCY_KEY_PAYLOAD_MISMATCH422You reused an Idempotency-Key with different query parametersUse a new key for the new payload
CONCURRENCY_LIMIT429More than 50 concurrent requests on the same API keyReduce concurrent requests
UPSTREAM_ERROR502Upstream platform returned an error. Credits refundedRetry after a short backoff
SERVICE_UNAVAILABLE503Circuit breaker is open for this platform. Credits refunded. Response includes Retry-After: 30Wait 30s and retry
INTERNAL_ERROR500Unexpected error. Credits refundedRetry; contact support with the request_id if it persists

Refund Rules

Credits are automatically refunded when:

  • Upstream returns a 5xx error (UPSTREAM_ERROR, 502)
  • The circuit breaker rejects the request (SERVICE_UNAVAILABLE, 503)
  • An unexpected server error occurs (INTERNAL_ERROR, 500)
  • Upstream returns 200 with an empty body — e.g. a nonexistent handle — triggering RESOURCE_NOT_FOUND (404)

Credits are never deducted for these outcomes, so no refund is needed:

  • Cache hits (X-Cache: HIT, X-Credits-Used: 0)
  • METHOD_NOT_ALLOWED (405), IDEMPOTENCY_KEY_CONFLICT (409), and IDEMPOTENCY_KEY_PAYLOAD_MISMATCH (422)
  • Idempotent replays — the original charge already appears on your earlier request

Client errors (MISSING_API_KEY, INVALID_API_KEY, INVALID_REQUEST, ENDPOINT_NOT_FOUND) are rejected before any deduction.

Debugging Tips

  • Every error envelope carries a doc_url pointing at the per-code page at https://www.socialcrawl.dev/docs/errors/…
  • request_id matches the X-Request-Id header and the request_id column on Dashboard → Activity Logs
  • Persistent 502s on a known-good input usually indicate an upstream outage — check GET /v1/status for the platform's circuit state
Error Handling | Socialcrawl