Skip to content
API Reference

Error Reference

Complete error catalog for the Trusteed API v1 and MCP Gateway. Use this to write precise retry logic and handle failures gracefully.

Error Response Format

All errors follow a consistent JSON envelope. Parse the error field to identify the error type programmatically.

{
  "error": "error_code",
  "message": "Human-readable message",
  "details": { ... }
}

The error field is stable across API versions — build retry logic against it, not against the message string.

Authentication Errors

Returned when the API key is missing, invalid, or lacks the required permissions to perform the requested action.

HTTP CodeErrorMeaningRecommended Action
401unauthorizedMissing or invalid API keyVerify the X-Agent-Api-Key header is present and correctly formatted (agnt_xxx)
401token_expiredOAuth token has expiredRefresh the token via POST /api/v1/oauth/token
403forbiddenKey lacks the required scope for this actionCheck key scopes in the Dashboard under Agent Keys
403tier_requiredFeature requires a higher subscription tierUpgrade the plan from the Dashboard
403store_suspendedMerchant trust_score is below 0.20Choose a different merchant — only proceed with trust_score ≥ 0.70

Rate Limit Errors

Rate limits are enforced per key and per tool. Read the X-RateLimit-Reset header to know when the window resets.

HTTP CodeErrorMeaningRecommended Action
429rate_limit_exceededPer-key request limit hitPause and retry after the Unix timestamp in X-RateLimit-Reset
429tool_limit_exceededPer-tool limit exceeded (e.g. search_products: 20/min)Reduce search frequency or batch requests

Rate limit response headers

  • X-RateLimit-LimitMaximum requests allowed in the current window
  • X-RateLimit-RemainingRequests remaining before the limit is hit
  • X-RateLimit-ResetUnix timestamp (seconds) when the window resets

Business Logic Errors

Returned when a request is structurally valid but fails due to application state (e.g. cart expired, store not found).

HTTP CodeErrorMeaningRecommended ActionRetryable
400invalid_slugStore slug format is invalidUse alphanumeric characters and hyphens only (e.g. my-store)No
404store_not_foundStore does not exist or is inactiveVerify the slug from the merchant directoryNo
404product_not_foundProduct is unavailable or delistedCall search_products again to get an updated product listNo
409cart_expiredCart is older than 30 minutesCreate a new cart with create_cartNo
422checkout_not_readyCart is empty or missing required fieldsAdd items before calling complete_checkoutNo
500internal_errorUnexpected server errorRetry with exponential backoff (see Retry Guidance below)Yes
503service_unavailableTemporary overload or maintenanceRetry after 30 secondsYes

Retry Guidance

Not all errors are worth retrying. Follow these rules to build resilient integrations.

Retryable errors

429, 500, 503

Backoff: 1s → 2s → 4s → 8s (max 4 retries)

Non-retryable errors

400, 401, 403, 404, 409, 422

Fix the request before retrying

Recommended backoff strategy

// Exponential backoff — max 4 retries
const RETRYABLE = new Set([429, 500, 503]);

async function callWithRetry(fn: () => Promise<Response>): Promise<Response> {
  let attempt = 0;
  while (attempt <= 4) {
    const res = await fn();
    if (res.ok || !RETRYABLE.has(res.status)) return res;

    if (res.status === 429) {
      const reset = res.headers.get("X-RateLimit-Reset");
      const waitMs = reset ? (Number(reset) * 1000 - Date.now()) : 1000;
      await sleep(Math.max(waitMs, 0));
    } else {
      await sleep(1000 * 2 ** attempt); // 1s → 2s → 4s → 8s
    }
    attempt++;
  }
  return fn();
}

function sleep(ms: number): Promise<void> {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

Back to Developer Docs

Explore authentication, MCP tools, webhooks, and more.

Developer Documentation
API Error Reference | Trusteed Developers