Skip to content

Errors

All SDK methods throw ConfigureError on failure. Each error has a machine-readable code for programmatic handling, structured metadata for retry logic and suggested actions, and an optional statusCode from the HTTP response.

Import

typescript
import { ConfigureError, ErrorCode, classifyError } from 'configure';

ConfigureError

typescript
class ConfigureError extends Error {
  readonly code: ErrorCodeValue;
  readonly statusCode?: number;
  readonly message: string;
  readonly type?: string;
  readonly param?: string | null;
  readonly retryable?: boolean;
  readonly suggestedAction?: string | null;
  readonly docUrl?: string | null;
  readonly retryAfter?: number | null;
  readonly requestId?: string;

  constructor(code: ErrorCodeValue, message: string, statusCode?: number, details?: ErrorDetails);
  static fromResponse(status: number, body: Record<string, unknown>): ConfigureError;
  static fromCatch(error: unknown, fallbackMessage: string): ConfigureError;
}
PropertyTypeDescription
codeErrorCodeValueMachine-readable error code (see table below).
statusCodenumber | undefinedHTTP status code from the API, if applicable.
messagestringHuman-readable error description.
typestring | undefinedBackend error type (e.g., "authentication_error", "tool_error").
paramstring | nullThe field or parameter that caused the error.
retryableboolean | undefinedWhether the same request might succeed if retried.
suggestedActionstring | nullMachine-readable next action (e.g., "reauthenticate", "connect_tool").
docUrlstring | nullLink to error documentation.
retryAfternumber | nullSeconds to wait before retrying (rate limits).
requestIdstring | undefinedBackend request ID for debugging and support.

Error Codes

CodeHTTP StatusCauseSolution
API_KEY_MISSINGN/ANo API key provided to ConfigureClient.Pass the key as the first argument or set CONFIGURE_API_KEY env var.
AUTH_REQUIRED401, 403Token is missing, invalid, or expired.Re-authenticate via auth.verifyOtp().
INVALID_INPUT400Input failed validation before reaching the API.Check parameter format (e.g., E.164 phone, 6-digit OTP).
TOOL_NOT_CONNECTED400The requested tool is not connected for this user.Prompt the user to connect the tool via tools.connect().
ACCESS_DENIED403Not authorized for this resource (distinct from AUTH_REQUIRED).Check the user's permission settings or agent access.
TOOL_ERRORvariesTool operation failed (provider error, misconfiguration).Retryable — retry after a short delay.
PAYMENT_REQUIRED402Billing or quota limit reached.Upgrade your plan in the dashboard.
NETWORK_ERRORN/ANetwork request failed (DNS, connection refused, etc.).Check connectivity, retry with backoff.
RATE_LIMITED429Too many requests.Back off and retry after the cooldown period. Use retryAfter if available.
NOT_FOUND404Resource not found.Verify the path, user ID, or resource exists.
SERVER_ERROR500+Server-side failure.Retry with backoff. If persistent, check the status page.
TIMEOUTN/ARequest timed out.Increase the timeout option or retry.

Usage

typescript
import { ConfigureClient, ConfigureError, ErrorCode } from 'configure';

const client = new ConfigureClient('sk_your_api_key');

try {
  const profile = await client.profile.get(token, userId);
} catch (error) {
  if (error instanceof ConfigureError) {
    switch (error.code) {
      case ErrorCode.AUTH_REQUIRED:
        // error.suggestedAction === 'reauthenticate'
        console.log('Please log in again');
        break;
      case ErrorCode.TOOL_NOT_CONNECTED:
        // error.suggestedAction === 'connect_tool'
        // error.param === 'tool'
        console.log('Please connect the required tool');
        break;
      case ErrorCode.ACCESS_DENIED:
        // error.suggestedAction === 'check_permissions'
        console.log('Permission denied');
        break;
      case ErrorCode.RATE_LIMITED:
        // error.retryable === true
        // error.retryAfter — seconds to wait
        console.log('Rate limited, retrying...');
        break;
      case ErrorCode.PAYMENT_REQUIRED:
        // error.suggestedAction === 'upgrade_plan'
        console.log('Quota exceeded');
        break;
      case ErrorCode.NETWORK_ERROR:
      case ErrorCode.TIMEOUT:
        // error.retryable === true
        console.log('Network error, retrying...');
        break;
      default:
        console.error(`Error [${error.code}]: ${error.message}`);
    }
  }
}

classifyError()

Classifies any caught error into a ConfigureError with a friendly user-facing message. Works with SDK errors, Anthropic errors, network errors, or plain strings. See the Error Handling guide for full examples and the friendly message table.

typescript
import { classifyError } from 'configure';

const classified = classifyError(error);
// classified.code — e.g., ErrorCode.RATE_LIMITED
// classified.message — e.g., "taking a breather — try again in a moment."

Input Validation

The SDK validates inputs before making API calls and throws ConfigureError with code INVALID_INPUT:

  • Phone numbers must be in E.164 format (e.g., +14155551234).
  • OTP codes must be exactly 6 digits.
  • Storage paths must not contain ../ (path traversal).
  • Tool types must be one of: gmail, calendar, drive, notion.
  • Required parameters must not be empty or null.
typescript
// These throw ConfigureError with INVALID_INPUT before any network call
client.auth.sendOtp('not-a-phone');      // Invalid E.164 format
client.auth.verifyOtp('+1415555', '12');  // OTP must be 6 digits
client.self.write('../../../etc/passwd', 'x');  // Path traversal blocked

Identity and memory infrastructure for AI agents