Environments and the kill switch
Keep staging and production apart at the API key, protect production from accidental changes, and stop everything an environment's agents are doing with one halt switch.
An environment is an isolated space for your actions, secrets, connected accounts, policies, limits, approvals and receipts. Every API key belongs to exactly one environment. The kill switch halts an environment: its agents stop acting and nothing leaves it until you resume.
Why environments and a halt switch
- Risk. A test run with the wrong key is how staging writes to production. Here the environment is bound to the key itself, so a staging key does not find production data at all.
- Risk, during an incident. A runaway loop, a bad deploy or a suspected prompt injection needs to stop now, not after a redeploy. One call stops every agent in the environment, including calls that were already approved.
- Effort. You do not thread an environment flag through your code or build a feature switch for your agents. You hand each service the key for its environment, and keep one operator key for the switch.
Understand what an environment isolates
A new workspace starts with one protected environment of kind production, named Production, with the slug production. You can add more, up to your plan’s total, and choose each one’s kind: production, staging or development. You can change the kind later.
| Plan | Environments |
|---|---|
| Early Beta Access | 3 |
| Starter | 1 |
| Pro | 2 |
| Team | 3 |
| Enterprise | Unlimited |
See pricing for the plans, and GET /api/v2/billing/plan for your workspace’s own numbers.
A key resolves its environment when it authenticates. It cannot read or write another environment’s actions, secrets, connected accounts, invocations, receipts, approvals, policies, impact limits, events, agents, runs or spans. Names are unique per environment, so refund-order in staging and refund-order in production are two separate actions, and resolving the staging one never returns the production one.
This is logical isolation: rows in shared storage, filtered by an enforced column. It is not dedicated storage or compute.
import { Client } from '@anlyonhq/sdk';
// This key was created for `staging`. The actions it invokes, the approvals it
// requests and the runs it records are staging data. It cannot reach production.
const anlyon = new Client({ apiKey: process.env.ANLYON_STAGING_KEY! });
const { data: environment } = await anlyon.environment.get();
console.log(environment!.slug, environment!.kind, environment!.halted);
GET /api/v2/environment returns the key’s own environment and needs no scope (Get this key’s environment):
{
"success": true,
"data": {
"id": "9d1c6a0e-4b7f-4e3a-8f51-0c2d7e6b1a94",
"kind": "staging",
"name": "Staging",
"slug": "staging",
"isDefault": false,
"isProtected": false,
"halted": false,
"haltedAt": null,
"haltedReason": null,
"createdAt": "2026-10-05T10:02:11.000Z",
"updatedAt": "2026-10-05T10:02:11.000Z"
}
}
Billing counters are workspace-level: every environment draws on the same plan allowance.
Halt an environment
Halt from the console (Environments → Halt), or from a runbook with an operator key. The API halts the calling key’s own environment, so a staging key can halt staging and cannot reach production.
import { Client } from '@anlyonhq/sdk';
// An operator key that holds environments:halt. Never the agent's key.
const operator = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });
const { data } = await operator.environment.halt({ reason: 'Runaway refund loop' });
console.log(data!.halted, data!.haltedAt);
// When the incident is over:
await operator.environment.resume();import os
from anlyon import Client
operator = Client(api_key=os.environ["ANLYON_OPERATOR_KEY"])
operator.environment.halt(reason="Runaway refund loop")
operator.environment.resume()curl -X POST https://api.anlyon.com/api/v2/environment/halt \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d '{ "reason": "Runaway refund loop" }'
curl -X POST https://api.anlyon.com/api/v2/environment/resume \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY"- A key needs
environments:haltto halt and to resume. It is a privileged scope: no key gets it by default. - In the console, an admin or a member can halt, because stopping is the safe direction. Only an admin can resume.
reasonis optional, up to 500 characters, and recorded with the time.
Both answer with the environment. Each halt and resume is an environment.halted or environment.resumed audit record. See Halt this key’s environment and Resume this key’s environment.
Know what a halt stops and what keeps working
The rule: halting stops the agent acting and stops anything leaving, and leaves your controls working. It stops new dispatch after the halt check. A request an external server already accepted is not recalled.
Stopped:
- Action calls from an API key answer
409 ENVIRONMENT_HALTED, and nothing is recorded or sent. - Approved calls do not run. An approval decided while the environment is halted records the decision, and the parked invocation is recorded as
failedwith the halt as its error. It is not sent later. - Hosted function runs and their writes are refused with
409 ENVIRONMENT_HALTED. - A replay of a governed effect is refused. Reconcile, notes and resolve stay available, so you can still settle what happened.
- Events published with an agent’s API key are refused with
409 ENVIRONMENT_HALTED, so a stopped agent cannot queue work that runs the moment you resume. A console session, or a key holding themessages:ingestscope, can still publish. - Anlyon Vigil does not auto-approve in a halted environment.
Still working:
- Approvals can be decided, including denying the ones that piled up.
- Every read answers, so you can see what stopped.
- The console works. A person signed in to the console is not the agent the switch stops.
- Resume works. The switch never disables its own undo.
Protect production from accidental changes
A protected environment needs an explicit confirmation for the changes that would be easy to make by mistake:
- Promoting an agent into it needs
confirmProtected: true. - Removing its protection, or changing its kind, needs
confirmProtected: true. - It cannot be deleted while it is protected.
The default Production environment of a new workspace is protected. An environment you add is unprotected until you protect it. Protection and promotion are included during Early Beta Access and on every paid plan. Without a plan, protecting an environment answers 403 FEATURE_NOT_AVAILABLE. Isolation and the halt switch are on every plan.
Manage environments in the console
Creating, renaming, protecting, reclassifying and deleting environments are console operations for admins (Environments → Manage). They take a signed-in session at /api/v2/workspaces/{workspaceId}/environments, not an API key.
- Change the kind without moving or deleting anything. A change of kind never counts against the plan, which limits the total.
- Make another environment the default: the one new keys and resources default to.
- Delete an empty environment. It must be halted, unprotected and not the default, and you confirm by typing its exact slug. The server refuses while any resource or retained history references it. Deletion never cascades your data.
Before a plan downgrade, make the environments fit the target plan here, and remove protection from any environment the target plan would not protect. See Billing.
Fix the errors you will meet
| Status and code | When | What to do |
|---|---|---|
409 ENVIRONMENT_HALTED |
The environment is halted and the call would act or send something. | Wait for an operator to resume. The same call succeeds afterwards. |
403 AUTHORIZATION_ERROR |
The key lacks environments:halt, or a console member without the admin role tries to resume. |
Use the operator key, or ask an admin. |
409 CONFLICT |
Removing protection, reclassifying a protected environment, or promoting into one without confirmProtected: true; deleting one that is not halted, is protected, is the default or is not empty. |
Confirm explicitly, or complete the step the message names. |
402 QUOTA_EXCEEDED |
Creating an environment past the plan’s total. | Delete an empty one, or move to a plan with more. |
403 FEATURE_NOT_AVAILABLE |
Protecting an environment, or promoting, on a workspace with no plan. | Choose a plan. |
Use environments well
- Create one key per environment per service, and name keys so the environment is obvious.
- Keep
environments:halton an operator key behind an on-call runbook. It stops new dispatch without a redeploy. - Use Immutable versions and rollback to move configuration between environments.
Related
- Authentication and API keys: keys, scopes and the environment a key belongs to.
- Approvals and policies: what happens to approvals during a halt.
- Immutable versions and rollback: promoting into a protected environment.
- Audit records: halts and resumes in the record.

