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

Impact limits

Cap how much money, how many changes or how many units of anything your agent's governed actions may use, per environment or per end user, enforced before every dispatch.

An impact limit caps what your agent’s actions do in the world: money refunded, records changed, emails sent, or any unit you name. Anlyon reserves against the limit immediately before it sends a write, and refuses the write when there is no room.

Why cap impact rather than calls

A rate limit counts requests. The damage an agent does is counted in something else: dollars refunded, emails sent to customers, rows deleted. A prompt injection or a loop that stays under a request rate can still refund the same order ten times.

An impact limit counts the business quantity of each write and is checked by Anlyon at dispatch, outside the agent’s process. So:

  • Risk. A bad loop stops at the cap you chose, before the provider sees the write that would cross it. The agent cannot raise its own cap: changing a limit needs a scope no key receives by default.
  • Effort. You do not build counters, period resets or race-safe reservations in your own code. Every agent, key and session in the environment draws from the same allowance.
  • Cost. An outcome that is still unknown keeps its allowance held, so a lost response never frees room for a duplicate.

What a limit counts

dimension What it counts unit
money Integer minor units in one currency (cents for usd) The currency, for example usd
resource_mutations Changes to resources resource_mutations
A unit you declare, such as emails, messages or rows Whatever the action’s impact.amount evaluates to The dimension name

A declared unit matches ^[a-z][a-z0-9_]{0,31}$.

Limits apply to governed actions: an action with an adapter (stripe.refund, github.file_update, resend.email_send), or an action that carries a declaration (impact, verify or governed: true). An action with neither is not counted. See Actions for the fields.

How a limit is keyed

A limit is keyed on things the server controls:

  • the environment of the key that created it,
  • the dimension and unit,
  • an optional actionName, to cap one action,
  • an optional resourcePrefix, to cap a range of resources (for example github:acme/fixtures@, or http:api.example.com/v1/emails for a declared action, whose resource key is http:<host><path>),
  • a period: day (the UTC day), month (the UTC month) or total (never resets),
  • a scope: environment (the default) or end_user.

No key, session, run or agent is part of the identity. A new API key or a child agent does not get a new allowance.

Create a limit

Creating, changing and archiving limits needs the impact-limits:write scope, which no key receives by default. Keep it on an operator key that your agent never holds. In the console, a member also needs the admin role in the limit’s environment. Reading limits needs impact-limits:read, which is in the default set, so an agent can check available before it asks.

import { Client } from '@anlyonhq/sdk';

// An operator key with impact-limits:write. Never give it to the agent.
const operator = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });

const { data: refunds } = await operator.impactLimits.create({
  name: 'Refunds per day',
  dimension: 'money',
  currency: 'usd',
  period: 'day',
  amount: 50_000, // $500.00 in cents
});

await operator.impactLimits.create({
  name: 'Fixture edits',
  dimension: 'resource_mutations',
  period: 'day',
  amount: 20,
  resourcePrefix: 'github:acme/fixtures@',
});

await operator.impactLimits.create({
  name: 'Daily emails',
  dimension: 'emails',
  period: 'day',
  amount: 500,
});

console.log(refunds!.id, refunds!.available); // lim_01JABCDEF 50000
curl -s -X POST https://api.anlyon.com/api/v2/impact-limits \
  -H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Refunds per day", "dimension": "money", "currency": "usd", "period": "day", "amount": 50000 }'
import os
from anlyon import Client

operator = Client(api_key=os.environ["ANLYON_OPERATOR_KEY"])

refunds = operator.impact_limits.create(
    name="Refunds per day", dimension="money", currency="usd", period="day", amount=50_000
)
operator.impact_limits.create(
    name="Fixture edits", dimension="resource_mutations", period="day", amount=20,
    resource_prefix="github:acme/fixtures@",
)
operator.impact_limits.create(name="Daily emails", dimension="emails", period="day", amount=500)

print(refunds.data["id"], refunds.data["available"])

The response is 201 with the limit:

{
  "success": true,
  "data": {
    "id": "lim_01JABCDEF",
    "name": "Refunds per day",
    "dimension": "money",
    "currency": "usd",
    "unit": "usd",
    "scope": { "environmentId": "6f1c0e2a-5b7d-4c1e-9a43-2d8b7f0e1a55", "actionName": null, "resourcePrefix": null, "kind": "environment" },
    "period": "day",
    "limit": 50000,
    "currentPeriod": "day:2026-10-27",
    "consumed": 0,
    "reserved": 0,
    "unknownExposure": 0,
    "available": 50000,
    "archived": false,
    "createdAt": "2026-10-27T09:00:00.000Z",
    "updatedAt": "2026-10-27T09:00:00.000Z"
  }
}

A limit in a declared unit reads back with that unit and currency: null. API reference: Create an impact limit.

Limit what each of your users can do

When your agent acts in your users’ own accounts, one shared allowance lets one heavy user use up everyone’s room. Give the limit scope: "end_user" and each end user gets the whole amount, counted on their own periods: “each user’s agent may send 20 emails a day”.

await operator.impactLimits.create({
  name: 'Emails per user per day',
  dimension: 'emails',
  period: 'day',
  amount: 20,
  scope: 'end_user',
});
curl -s -X POST https://api.anlyon.com/api/v2/impact-limits \
  -H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Emails per user per day", "dimension": "emails", "period": "day", "amount": 20, "scope": "end_user" }'
operator.impact_limits.create(
    name="Emails per user per day", dimension="emails", period="day", amount=20, scope="end_user"
)

How a per-user limit counts:

  • The end user is the one your server names with the Anlyon-End-User header, which the SDKs send for a client made with forUser(id) (TypeScript) or for_user(id) (Python). See Workspace connections and end-user connections.
  • A call made with no end user counts on the limit’s shared allowance.
  • scope is fixed once the limit is created.

To read one user’s figures, pass ?endUserId= on the list or get call. Without it, the figures are those of calls made with no end user. A key created with endUserRequired always reads its own end user’s figures.

curl -s "https://api.anlyon.com/api/v2/impact-limits?endUserId=user_4417" \
  -H "Authorization: Bearer $ANLYON_API_KEY"

Check what is left before you act

import { Client } from '@anlyonhq/sdk';

const agent = new Client({ apiKey: process.env.ANLYON_API_KEY! });

const { data: limits } = await agent.impactLimits.list();
for (const limit of limits ?? []) {
  console.log(limit.name, limit.unit, limit.consumed, limit.reserved, limit.unknownExposure, limit.available);
}
curl -s https://api.anlyon.com/api/v2/impact-limits \
  -H "Authorization: Bearer $ANLYON_API_KEY"
agent = Client(api_key=os.environ["ANLYON_API_KEY"])

for limit in agent.impact_limits.list().data:
    print(limit["name"], limit["consumed"], limit["reserved"], limit["available"])
Field Meaning
limit The amount you set.
consumed Confirmed impact settled into the current period.
reserved Everything held and not yet settled, across periods: in-flight writes, pending outcomes, unknown outcomes and possible partial failures.
unknownExposure The part of reserved whose outcome is unknown or possibly partial. It is not an additional amount.
available limit - consumed - reserved, never below zero.
currentPeriod The period the figures are for, such as day:2026-10-27, month:2026-10 or total.

list hides archived limits. Pass includeArchived: true (TypeScript), include_archived=True (Python) or ?includeArchived=true to include them. API reference: List impact limits.

Where the quantity comes from

Action Quantity
stripe.refund The refund amount in the action’s one currency, plus one resource mutation.
github.file_update One resource mutation per file update.
resend.email_send One emails unit per recipient, counted across to, cc and bcc.
A declared action The action’s impact.amount, evaluated over the validated input before dispatch: an integer, input.<path>, count(input.<path>), optionally times an integer.

A caller cannot pass a quantity apart from the request. For a declared action the quantity is whatever the declared expression gives for that input. See Govern any HTTP API.

An amount that reads an optional input the caller left out gives no quantity. That effect is unbounded for the dimension. A limit that applies refuses it with impact_unbounded. With no applicable limit it runs. Mark the input required in the action’s schema when the amount depends on it.

Money in another currency does not count against a money limit. A usd limit ignores a eur refund.

How capacity moves

  1. Reserve immediately before dispatch, after any approval. A call waiting for its approval reserves nothing, so its usage is counted only when the approved call runs. Every applicable limit is reserved in one transaction. If one has no room, none is reserved and nothing is sent.
  2. Settle the confirmed impact exactly once, into the period the reservation was made in, even if the outcome arrives next month.
  3. Release what is known not to have happened, and nothing else.
  4. Hold everything else. Outcomes that are still pending after the call was sent, unknown or possibly partial keep their capacity, across restarts and period boundaries, until evidence or an operator settles them.

Repeated attempts of one effect (a replay, a duplicate submission of the same operation) never consume twice. Repeated legitimate changes to the same resource are separate operations and count separately.

Change or archive a limit

A limit’s name and amount can change. Its dimension, scope and period are fixed: create a new limit to change them.

await operator.impactLimits.update('lim_01JABCDEF', { amount: 75_000 });
await operator.impactLimits.archive('lim_01JABCDEF');
curl -s -X PATCH https://api.anlyon.com/api/v2/impact-limits/lim_01JABCDEF \
  -H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 75000 }'

curl -s -X DELETE https://api.anlyon.com/api/v2/impact-limits/lim_01JABCDEF \
  -H "Authorization: Bearer $ANLYON_OPERATOR_KEY"
operator.impact_limits.update("lim_01JABCDEF", amount=75_000)
operator.impact_limits.archive("lim_01JABCDEF")
  • Lowering a limit never releases existing exposure. It blocks new work until availability recovers.
  • Archiving stops the limit applying to new effects. Its existing reservations still settle and release.
  • Each change is recorded in the audit log as impact_limit.created, impact_limit.updated or impact_limit.archived.

API reference: Update an impact limit, Archive an impact limit.

When the limit has no room

An operation is admitted whole or refused whole. A send to four recipients with two left is refused, none of the four is sent, and the two stay available. A refused effect records why, and nothing reaches the provider:

{ "stage": "rejected", "outcome": "not_dispatched", "rejectionReason": "impact_limit_exceeded", "grade": "refused" }

The invoke call still answers HTTP 200. The invocation’s status is failed, its grade is refused, and its error names impact_limit_exceeded with each shortfall. See When the limit is hit.

Errors you may see

Status and code When What to do
200, status: failed, grade: refused, impact_limit_exceeded A limit has no room at dispatch. Wait for the period, raise the limit, or settle held exposure. Then invoke again with a new Idempotency-Key.
200, status: failed, grade: refused, impact_unbounded A limit applies and the call gave no amount for its dimension. Make the input the amount reads required in the action schema.
403 The key lacks impact-limits:write, or a console member is not an admin in that environment. Use an operator key or an admin account.
400 Missing currency on a money limit, a unit that disagrees with the dimension, or an invalid dimension name. Fix the request body.
404 The limit id is not in this key’s environment. Use a key for the environment the limit lives in.

How it behaves

  • A limit counts governed actions. Give an action an adapter or a declaration to put it under a limit.
  • A limit counts the calls made through Anlyon. Keep the provider key in the vault so the action is the path to the provider.
  • A limit belongs to one environment. Staging and production each have their own.
  • The amount of a declared action is your expression. Anlyon enforces what you declare. An upper_bound set too low is an error in the definition.
  • An impact limit and a budget count different things. An impact limit caps what an action changes, such as the money it moves. A per-key budget caps the Anlyon operations a key may perform. See Controls.

Was this page helpful?