Skip to main content
When a policy evaluation returns ESCALATE, it creates an escalation. The SDK provides methods to list and resolve these.

Methods

  • listEscalations() — list all escalations for your organization
  • listEscalationsByPolicyId(policyId) — filter by policy ID
  • approveEscalation(escalationId) — approve an escalation
  • declineEscalation(escalationId) — decline an escalation

listEscalations()

Returns all escalation records for your organization. Signature
async listEscalations(): Promise<Escalation[]>
Returns: Array of Escalation objects.
const list = await limits.listEscalations();
for (const e of list) {
  console.log(e.id, e.status, e.response?.message);
}

listEscalationsByPolicyId(policyId)

Returns escalations filtered by policy ID. Signature
async listEscalationsByPolicyId(policyId: string): Promise<Escalation[]>
ParameterTypeRequiredDescription
policyIdstringYesPolicy ID to filter by.
const byPolicy = await limits.listEscalationsByPolicyId(policyId);

approveEscalation(escalationId)

Marks an escalation as approved. Signature
async approveEscalation(escalationId: string): Promise<Escalation>
ParameterTypeRequiredDescription
escalationIdstringYesID of the escalation.
Returns: Updated Escalation (e.g. status: 'ALLOWED').
await limits.approveEscalation(escalationId);

declineEscalation(escalationId)

Marks an escalation as declined. Signature
async declineEscalation(escalationId: string): Promise<Escalation>
ParameterTypeRequiredDescription
escalationIdstringYesID of the escalation.
Returns: Updated Escalation (e.g. status: 'DECLINED').
await limits.declineEscalation(escalationId);

Escalation object

Each item has a fixed response shape and a request-dependent request:
interface Escalation {
  id: string;
  policy_id: string;
  organization_id: string;
  status: 'PENDING' | 'ALLOWED' | 'DECLINED';
  created_at: string;
  updated_at: string;
  request?: any;   // depends on what you sent (e.g. { transaction: { amount: 1000 } })
  response?: {     // policy result at time of escalation
    action: 'ALLOW' | 'BLOCK' | 'ESCALATE';
    message: string;
    success: boolean;
    violated: boolean;
  };
  action_by?: string | null;
}
FieldTypeDescription
idstringEscalation ID.
policy_idstringPolicy that triggered the escalation.
organization_idstringYour organization ID.
statusstringPENDING, ALLOWED, or DECLINED.
created_atstringISO 8601 timestamp.
updated_atstringISO 8601 timestamp.
requestany (optional)Request payload (e.g. { transaction: { amount: 1200 } }).
responseobject (optional)Policy result at time of escalation: action, message, success, violated.
action_bystring | null (optional)ID of user who approved/declined.

Complete example

import { Limits } from '@limits/js';

const limits = new Limits({ apiKey: process.env.LIMITS_API_KEY! });

// Check a policy that might escalate
const result = await limits.check('sensitive-action', {
  amount: 10000,
  currency: 'USD',
});

if (result.isEscalated) {
  console.log('Action escalated, waiting for approval...');

  const escalations = await limits.listEscalations();
  const pending = escalations.find((e) => e.status === 'PENDING');

  if (pending) {
    await limits.approveEscalation(pending.id);
    console.log(`Escalation ${pending.id} has been approved`);
  }
}

Error handling

Throws: InvalidInputError for invalid IDs; APIRequestError, NetworkError for API/network failures.
import { InvalidInputError, APIRequestError } from '@limits/js';

try {
  await limits.approveEscalation(escalationId);
} catch (error) {
  if (error instanceof InvalidInputError) {
    console.error('Invalid escalation ID');
  } else if (error instanceof APIRequestError) {
    console.error('API error:', error.statusCode, error.message);
  }
}

API summary

MethodDescription
limits.listEscalations()List all escalations. Returns Escalation[].
limits.listEscalationsByPolicyId(policyId)List escalations by policy. Returns Escalation[].
limits.approveEscalation(escalationId)Approve by ID. Returns Escalation.
limits.declineEscalation(escalationId)Decline by ID. Returns Escalation.

Next Steps