Skip to content
Anlyon
Esc
↑↓navigate↵open⌘Jpreview
On this page

Errors and rate limits

Recognise every error the Anlyon API returns, know which ones are safe to retry, stay under the rate limit, and retry an action call without running it twice.

This page covers the errors the API returns, the rate limit, and how to retry safely.

Why it matters. An agent that retries the wrong error sends the same email twice or refunds an order twice. An agent that gives up on the right one stalls. Anlyon separates the two for you: an error code says what happened, a refused or unknown call is reported in the body rather than as an HTTP error, and an idempotency key makes a retry of the same call answer from the record instead of running again.

Read the error format

Errors share one format:

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message"
  },
  "requestId": "..."
}

Match on error.code. The hosted API leaves error.details out, so read the code and the message. Quote requestId when you contact support.

Read a refused action from the body, not the status

An action invoke that Anlyon refuses at dispatch, or whose outcome is unknown, answers HTTP 200. The refusal is in the body. Read status and grade, not the status code alone.

{
  "status": "failed",
  "grade": "refused",
  "error": "Dispatch refused (impact_limit_exceeded): Not enough allowance: daily emails needs 3, has 2."
}

See When the limit is hit and When the outcome is unknown.

Know what each status code means

Status code Meaning
200 Success. For an action invoke, read status and grade in the body
202 An action invoke is parked for approval
400 Invalid input, or a missing Anlyon-End-User on a key that requires one
401 Authentication failed
402 The workspace has no plan, so actions cannot run
403 A missing scope or role, a capability the plan does not include, or a decision you may not make
404 The resource does not exist in this workspace and environment, or belongs to another end user
409 A conflict: a reused idempotency key, a preview that no longer matches, or an end user who must connect an account
429 A rate limit, a quota or a per-key budget was reached
500 Internal server error
503 Service unavailable, or new expensive work is paused

Handle each error code

AUTHENTICATION_ERROR (401)

The key did not authenticate. An invalid, expired or revoked key gets the same answer.

Solutions:

  • Verify the API key is correct
  • Check the Authorization header format: Bearer anlyon_live_...
  • Check in the dashboard that the key has not been revoked or expired
AUTHORIZATION_ERROR (403)

The credential authenticated and lacks a scope or a role. The message names the missing scope, for example API key is missing required scope: actions:invoke.

Solutions:

  • Create a key with that scope. Scopes are fixed when a key is created
  • See Scopes
RATE_LIMIT_EXCEEDED (429)

Too many requests in one minute, or in one hour.

Retry-After says how many seconds until the window that refused the request resets. A refusal by the hourly limit names the limit and when the count resets, and carries X-RateLimit-Limit-Hour, X-RateLimit-Remaining-Hour and X-RateLimit-Reset-Hour. Read X-RateLimit-Remaining on the responses before it.

Solutions:

  • Wait for the window to reset
  • Retry with exponential backoff
  • Reduce request frequency, or move to a plan with a higher limit. See Rate limits
PAYMENT_REQUIRED (402)

The workspace has no plan, so every action call is refused before anything is counted or sent. Signing in, reading and deleting your data still work.

Solutions:

  • A workspace admin opens Settings → Plan & billing and starts a trial or chooses a plan. See Billing and anlyon.com/pricing
  • Do not retry until the workspace has a plan
QUOTA_EXCEEDED (429)

An allowance, a storage limit or a resource cap was reached. For actions, the call is refused once the plan’s monthly allowance, its grace and any action packs are used up. The message says which limit and what to do. Nothing is charged and nothing is upgraded automatically.

Solutions:

  • Actions: buy an action pack or move to a larger plan in Settings → Plan & billing, or wait for the reset shown there and in GET /api/v2/billing/plan
  • Storage or a resource cap (seats, environments, action definitions): remove unused items. These limits do not reset
  • Watch usage with GET /api/v2/billing/quota and the Analytics API
BUDGET_EXCEEDED (429)

The calling key reached its monthly cap on an Anlyon operation. A budget caps Anlyon operations. It does not cap model tokens or the money an action moves.

Solutions:

  • Wait for the next UTC month, or have an operator raise the cap with budgets:write
VALIDATION_ERROR (400)

Invalid request data.

Solutions:

  • Read the message for the field that failed
  • Check the API reference for required fields
PLAN_FEATURE_REQUIRED or FEATURE_NOT_AVAILABLE (403)

The workspace’s plan does not include the capability, for example creating single sign-on, SCIM, audit streaming, a secret store or per-environment roles. Configurations that already run keep working after a downgrade.

Solutions:

SELF_APPROVAL_NOT_ALLOWED (403)

A person tried to decide an approval their own credential requested: an API key they created, or an app acting for them over OAuth. Another member who can decide approvals in that environment must decide it. Approvals an end user decides in your app are not affected.

Solutions:

  • Ask another approver, or route the approval to a different person with an approval policy
END_USER_REQUIRED (400)

The key was created with Require an end user, and the request did not name one. Nothing ran.

Solutions:

  • Build the client with anlyon.forUser(userId) (TypeScript) or client.for_user(user_id) (Python), or send Anlyon-End-User: <id>
  • An end-user id is 1 to 128 characters from A-Z a-z 0-9 . _ : @ -
END_USER_NOT_CONNECTED and END_USER_RECONNECT_REQUIRED (409)

The action needs an account the end user has not connected, or one that was revoked or stopped refreshing. Nothing was sent. The error carries integration and connectUrl: a link that works once, for 10 minutes, or null when the environment has no default redirect URL. The SDKs throw EndUserNotConnectedError and EndUserReconnectRequiredError. The AI SDK tools and the MCP server return connect_required or reconnect_required as a tool result instead.

Solutions:

  • Show the user a Connect button with connectUrl, or make a link with endUsers.createConnectLink
  • Call again after the user has connected. See Workspace and end-user connections
END_USER_MISMATCH (403)

Your server confirmed a connect flow for a different end user than the one who started it, for example after a connect link was forwarded. Nothing was connected.

Solutions:

  • Confirm with the user from your own session, never an id read from the redirect URL
END_USER_HEADER_NOT_ALLOWED and END_USER_HEADER_MISMATCH (400)

Anlyon-End-User was sent with a credential that is not an API key (an OAuth token, a console session or an end-user session token), or it names a different end user than the path.

Solutions:

  • Send the header only from your server, with an API key
  • On /api/v2/end-users/{endUserId}/..., send the same id in the header as in the path, or leave the header out
REDIRECT_URL_REQUIRED (400)

A connect link needs somewhere to send the user back.

Solutions:

  • Pass redirectUrl from the environment’s allowed redirect URLs, or set a default redirect URL under Integrations → Connect settings
EXPENSIVE_WORK_PAUSED (503)

New expensive work, such as hosted action execution, is temporarily paused for every workspace to protect the service. Signing in, viewing and deleting your data still work.

Solutions:

NOT_FOUND (404)

The resource does not exist where the credential can see it.

Solutions:

  • Verify the resource ID is correct
  • Check that the key belongs to the environment the resource is in
  • Check that the resource has not been deleted

Action invokes have their own 409 codes, such as PREVIEW_MISMATCH, PREVIEW_EXPIRED, PREVIEW_ALREADY_USED, OPERATION_KEY_REUSE and idempotency_key_reuse. See When approval expires or changes and Idempotency and retries.

Stay under the rate limit

Plan Requests per minute Requests per hour
No plan and Early Beta Access 300 10,000
Starter and Pro 1,000 30,000
Team 1,000 45,000
Enterprise Custom Custom

Rate limits are applied per workspace, in one-minute windows and in UTC clock hours. The minute limit absorbs bursts; the hour limit is there for a sustained flood. A request the minute limit refuses does not count toward the hour.

Read the rate limit headers

Responses that pass the limit carry rate limit headers, for the minute and for the hour. A 429 carries Retry-After, in seconds. X-RateLimit-Reset and X-RateLimit-Reset-Hour are Unix times in milliseconds.

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1737381660000
X-RateLimit-Limit-Hour: 30000
X-RateLimit-Remaining-Hour: 29874
X-RateLimit-Reset-Hour: 1737385200000

Retry safely

Check the response status
const response = await fetch(url, options);
const body = await response.json();

if (!response.ok) {
  throw Object.assign(new Error(body.error.message), {
    code: body.error.code,
    status: response.status,
  });
}

return body.data;
Handle specific error codes
try {
  await invokeAction('open-issue', input, idempotencyKey);
} catch (error) {
  if (error.code === 'QUOTA_EXCEEDED') {
    console.warn('Quota exceeded. Wait for the monthly reset or free up room.');
  } else if (error.code === 'RATE_LIMIT_EXCEEDED') {
    // Wait, then send the same request with the same Idempotency-Key.
  } else {
    console.error('Unexpected error:', error);
  }
}
Retry an invoke with the same Idempotency-Key

Anlyon does not retry an action invocation. If your code retries an invoke, send the same Idempotency-Key with the same request. The retry is answered from the recorded invocation, and the action does not run again.

async function retryWithBackoff<T>(
  fn: () => Promise<T>,
  maxRetries = 3,
  baseDelay = 1000
): Promise<T> {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await fn();
    } catch (error) {
      if (attempt === maxRetries - 1) throw error;

      // Do not retry client errors, except a rate limit.
      if (error.status >= 400 && error.status < 500 && error.status !== 429) {
        throw error;
      }

      const delay = baseDelay * Math.pow(2, attempt);
      await new Promise(resolve => setTimeout(resolve, delay));
    }
  }

  throw new Error('Max retries exceeded');
}

Do not retry an invocation whose status is unknown under a new key. Reconcile it first.

Handle errors over plain HTTP

The SDKs do this for you: they retry their own request after a network error, a timeout, 429, 500, 502, 503 or 504, up to 3 attempts by default, with the same idempotency key on an invoke, and they raise a typed error for each code above. These clients show the same handling over plain HTTP.

class AnlyonClient {
  private apiKey: string;
  private baseUrl: string;

  constructor(apiKey: string, baseUrl = 'https://api.anlyon.com') {
    this.apiKey = apiKey;
    this.baseUrl = baseUrl;
  }

  async request<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
    const response = await fetch(`${this.baseUrl}${endpoint}`, {
      ...options,
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/json',
        ...options.headers,
      },
    });

    const data = await response.json();

    if (!response.ok) {
      const error = new Error(data.error?.message || 'Request failed');
      (error as any).code = data.error?.code;
      (error as any).status = response.status;
      (error as any).requestId = data.requestId;
      throw error;
    }

    return data.data;
  }

  async invokeAction(ref: string, input: Record<string, unknown>, idempotencyKey: string) {
    return this.request(`/api/v2/actions/${ref}/invoke`, {
      method: 'POST',
      headers: { 'Idempotency-Key': idempotencyKey },
      body: JSON.stringify({ input }),
    });
  }
}
import requests
from typing import Any, Dict

class AnlyonClient:
    def __init__(self, api_key: str, base_url: str = "https://api.anlyon.com"):
        self.api_key = api_key
        self.base_url = base_url
        self.session = requests.Session()
        self.session.headers.update({
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json",
        })

    def request(self, endpoint: str, method: str = "GET", **kwargs) -> Dict[str, Any]:
        url = f"{self.base_url}{endpoint}"
        response = self.session.request(method, url, **kwargs)

        try:
            data = response.json()
        except ValueError:
            data = {}

        if not response.ok:
            error = data.get("error", {})
            raise Exception(
                f"API Error: {error.get('message', 'Request failed')} "
                f"(Code: {error.get('code')}, Status: {response.status_code})"
            )

        return data.get("data", data)

    def invoke_action(self, ref: str, input: Dict[str, Any], idempotency_key: str) -> Dict[str, Any]:
        return self.request(
            f"/api/v2/actions/{ref}/invoke",
            method="POST",
            json={"input": input},
            headers={"Idempotency-Key": idempotency_key},
        )

Was this page helpful?