Skip to main content

Error Handling

All errors follow a consistent shape. Use the status code to decide what to do, and the error body for details.

Error response shape

Every error response returns this structure:
{
  "error": {
    "code": "error_code_here",
    "message": "Human-readable description",
    "status_code": 400
  }
}
The code field is a stable, machine-readable string. The message field is human-readable and may change between versions — don’t match against it programmatically.

Error code reference

StatusCodeMeaningWhat to do
400validation_errorBad request body or paramsFix the request. Check required fields and types.
401unauthorizedMissing or invalid API keyCheck your X-API-Key header. See Authentication.
402payment_requiredBilling suspended — invoice unpaidFix billing in the dashboard, pay outstanding invoices.
404not_foundResource doesn’t existCheck the ID or username.
429rate_limit_exceededOver your per-minute or per-hour budgetRead Retry-After header or wait for the reset window. See Rate Limits.
500internal_errorSomething broke on the Influship sideRetry with backoff. If persistent, contact support.

Handling errors in code

import Influship, { APIError, RateLimitError } from 'influship';

const client = new Influship();

try {
  const results = await client.creators.search({
    query: 'fitness creators',
  });
} catch (error) {
  if (error instanceof RateLimitError) {
    // Back off and retry
    const retryAfter = error.headers?.get('retry-after');
    console.log(`Rate limited. Retry after ${retryAfter}s`);
  } else if (error instanceof APIError) {
    console.log(`API error ${error.status}: ${error.message}`);
  } else {
    throw error;
  }
}
The SDK throws typed error classes, so you can catch specific error types and handle them differently. For raw HTTP, check the status code of the response.

Rate limit headers

Every response includes rate limit headers so you can track your budget before hitting 429. See Rate Limits & Tiers for the full header reference and trust tier table.

Implementation advice

For production integrations, handle 429 with exponential backoff. A simple strategy: wait 2^attempt seconds, capped at 60 seconds, with jitter. Treat 402 as a billing issue that needs human intervention — don’t retry it automatically. Surface it to your ops team or billing dashboard instead.