Govern any HTTP API
Declare an action on any HTTPS API so each call is counted against a limit, approved as the exact request, sent with the right account's credential and graded by a read-back.
Your agent needs to write to an API Anlyon has no adapter for: your own backend, a mailer, a ticketing system. Called directly, that write has no cap, no reviewed request and no record of whether it landed, and the agent holds the API key. A declared action fixes all four. You write an ordinary HTTP template and two declarations: what one call changes (impact) and how to read the result back (verify). Anlyon then:
- reserves the call’s impact against a limit before anything is sent, for the environment or for each of your users;
- binds every approval to a digest of the exact request, so what was approved is what runs;
- adds the credential at dispatch, so neither the agent nor the model ever sees it;
- returns a receipt with a grade:
confirmedwhen your read-back matched.
This guide uses a fictional mailer at https://api.example.com. Nothing here is specific to email. The unit could be rows, tickets or anything else you count.
Define the action and declare its impact
Two keys are in play. An operator key stores the credential and defines the action: it needs secrets:write, actions:write, and secrets:read, because an action that references a credential can only be saved by a key holding secrets:read. An agent key with actions:invoke calls the action and never holds a credential.
import { Client } from '@anlyonhq/sdk';
const ops = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });
await ops.secrets.put('MAILER_TOKEN', {
value: process.env.MAILER_TOKEN!,
allowedHosts: ['api.example.com'],
allowedPlacements: ['header'],
});
const { data: action } = await ops.actions.create({
name: 'send-email',
method: 'PUT',
urlTemplate: 'https://api.example.com/v1/emails/{{input.emailId}}',
headers: { Authorization: 'Bearer {{secret:MAILER_TOKEN}}' },
bodyTemplate: { to: '{{input.to}}', subject: '{{input.subject}}' },
inputSchema: {
type: 'object',
required: ['emailId', 'to', 'subject'],
properties: {
emailId: { type: 'string', pattern: '^[a-z0-9-]{1,40}$' },
to: { type: 'array', items: { type: 'string' } },
subject: { type: 'string' },
},
},
impact: { dimension: 'emails', amount: 'count(input.to)', bound: 'exact' },
verify: {
url: 'https://api.example.com/v1/emails/{{input.emailId}}',
status: 200,
match: [{ path: 'subject', equals: '{{input.subject}}' }],
},
});curl -s -X PUT https://api.anlyon.com/api/v2/secrets/MAILER_TOKEN \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d "{ \"value\": \"$MAILER_TOKEN\", \"allowedHosts\": [\"api.example.com\"], \"allowedPlacements\": [\"header\"] }"
curl -s -X POST https://api.anlyon.com/api/v2/actions \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "send-email",
"method": "PUT",
"urlTemplate": "https://api.example.com/v1/emails/{{input.emailId}}",
"headers": { "Authorization": "Bearer {{secret:MAILER_TOKEN}}" },
"bodyTemplate": { "to": "{{input.to}}", "subject": "{{input.subject}}" },
"inputSchema": {
"type": "object",
"required": ["emailId", "to", "subject"],
"properties": {
"emailId": { "type": "string", "pattern": "^[a-z0-9-]{1,40}$" },
"to": { "type": "array", "items": { "type": "string" } },
"subject": { "type": "string" }
}
},
"impact": { "dimension": "emails", "amount": "count(input.to)", "bound": "exact" },
"verify": {
"url": "https://api.example.com/v1/emails/{{input.emailId}}",
"status": 200,
"match": [{ "path": "subject", "equals": "{{input.subject}}" }]
}
}'import os
from anlyon import Client
ops = Client(api_key=os.environ["ANLYON_OPERATOR_KEY"])
ops.secrets.put(
"MAILER_TOKEN",
value=os.environ["MAILER_TOKEN"],
allowed_hosts=["api.example.com"],
allowed_placements=["header"],
)
action = ops.actions.create(
name="send-email",
method="PUT",
url_template="https://api.example.com/v1/emails/{{input.emailId}}",
headers={"Authorization": "Bearer {{secret:MAILER_TOKEN}}"},
body_template={"to": "{{input.to}}", "subject": "{{input.subject}}"},
input_schema={
"type": "object",
"required": ["emailId", "to", "subject"],
"properties": {
"emailId": {"type": "string", "pattern": "^[a-z0-9-]{1,40}$"},
"to": {"type": "array", "items": {"type": "string"}},
"subject": {"type": "string"},
},
},
impact={"dimension": "emails", "amount": "count(input.to)", "bound": "exact"},
verify={
"url": "https://api.example.com/v1/emails/{{input.emailId}}",
"status": 200,
"match": [{"path": "subject", "equals": "{{input.subject}}"}],
},
).dataThe stored action comes back with governed: true. The server fills in the unit of a non-money impact.
{
"governed": true,
"adapter": null,
"impact": { "dimension": "emails", "unit": "emails", "amount": "count(input.to)", "bound": "exact" },
"verify": { "status": 200, "match": [{ "path": "subject", "equals": "{{input.subject}}" }] }
}
The block shows the declaration fields. The full response also carries the stored verify.url and the rest of the definition.
Write the impact declaration
| Field | Meaning |
|---|---|
dimension |
money, resource_mutations, or a unit you name. A unit is lowercase letters, digits and underscores, starts with a letter, and is at most 32 characters. |
unit |
Required for money: one lowercase ISO currency such as usd. For every other dimension the unit is the dimension name and you may leave it out. |
amount |
An expression over the validated input. See the grammar below. |
bound |
exact or upper_bound. |
The amount grammar is small on purpose. An amount is one of three terms, with one optional multiplication by an integer:
| Expression | Value |
|---|---|
1 |
An integer literal. Every call counts the same. |
input.amount |
The value at that input path. It must be a non-negative integer. |
count(input.to) |
The length of the array at that input path. |
count(input.to) * 2 |
Any of the three, times an integer literal. |
Nothing else parses. An expression such as len(input.to) is refused when you save the action.
The amount is evaluated at admission, before dispatch, from the input after schema validation. The agent never states the quantity.
bound says how to read the number. exact means the call changes exactly that much. upper_bound means the call changes at most that much. Both reserve the full amount against a limit, so set an upper_bound at the most one call can change.
An optional input yields no quantity. If the amount reads an input the caller left out, the effect has no quantity for that dimension. It is unbounded, never zero. An applicable limit refuses it with impact_unbounded. With no applicable limit it runs. Make an input required in the schema when the amount depends on it. See When the limit is hit.
Write the verify rule
verify is a read-back. After the provider accepts the write, Anlyon issues one GET and compares the answer with your rule.
- The request is a
GETon the action’s own host. A verify URL on another host is refused when you save the action. - The URL may use
{{input.x}}and{{response.x}}.{{response.x}}reads the provider’s answer to the write, for an API that chooses the id itself. statusis the HTTP status the read-back must answer with.matchis a list of at most 10 equality checks. Each has a dotted JSONpathinto the read-back body and anequalsvalue.equalsis a string, number, boolean ornull, or exactly one{{input.x}}or{{response.x}}.- The read-back is sent through the same transport with the action’s own headers, so it carries the same credential.
A match grades the receipt confirmed. A 2xx with no verify rule, or with a read-back that did not match, grades acknowledged. A read-back never changes an outcome and is never a second write.
A verify URL that uses {{response.x}} cannot be rebuilt when the response is lost. The preview says so in its limitations. See When the outcome is unknown.
Write a rule that distinguishes this write. A read-back on a resource that already existed can match, so match on a value this request set, such as the subject.
Govern an action with nothing to count
An action is governed when it carries impact, verify, or governed: true. Set governed: true alone when you want the bound approval and the receipt grade and have nothing to count or read back.
A governed action needs a fixed https host. A URL template whose host contains {{input.x}} is refused when the declarations are saved: an input may not choose where a governed request is sent.
An action with no declaration and no adapter is not governed. It creates no effect, draws from no limit and returns no grade.
Choose whose credential the action sends
The credential reference in a header decides which account the call acts in. Pick one per action.
| Reference | Resolves to | Use it for |
|---|---|---|
{{secret:NAME}} |
The secret stored under NAME in this environment. A stored key goes to its own allowedHosts, in the placements you allowed. |
Your company’s own key for an API that is not in the integration catalogue, like the mailer above. |
{{connection:<integration>}} |
On a call made for one of your users, that user’s own account. On any other call, this environment’s connected account for the integration. | Acting in your users’ accounts: {{connection:github}}, {{connection:notion}}. |
The rules for {{connection:<integration>}}:
- It travels in a header only. A connection reference in the URL or the body is refused when you save the action.
- It goes only to the integration’s catalogue hosts. A
{{connection:github}}header on a URL outsideapi.github.comis refused when you save the action, and checked again at every dispatch. No input can send the token anywhere else. - A call made for a user never falls back to your account. A user who has not connected gets
409 END_USER_NOT_CONNECTEDwith aconnectUrl, and nothing is sent. - A call with no user needs exactly one connected account for the integration in the environment. With none, the call is refused before it is sent. With two, the reference is ambiguous: name one with
{{secret:NAME}}.
A {{secret:NAME}} that names a connected account behaves the same way on a call made for a user: it resolves to that user’s account. A stored key with no integration stays your key on every call.
The quickstart declares a GitHub action with Authorization: Bearer {{connection:github}}, and Act for your users builds a whole app on it.
Address an account whose host differs per account
Some integrations have a different API host for each account, given when the account connects. Write that host as {{connection.host}}, the whole host of an https URL, written once:
{
"urlTemplate": "https://{{connection.host}}/api/v2/tickets",
"headers": { "Authorization": "{{connection:<integration>}}" }
}
The host is filled from the account the call resolves to, never from an input. The action must send exactly one such account. {{connection.host}} in a header or the body is refused.
Create a limit in that unit
A limit names the same unit. Choose who shares it:
scope: "environment"(the default): every key and agent in the environment draws from one allowance.scope: "end_user": each of your users gets the whole amount, counted on their own. A call made for no user draws from one shared allowance of the same amount.
// One allowance for the whole environment.
await ops.impactLimits.create({ name: 'daily emails', dimension: 'emails', period: 'day', amount: 500 });
// 20 emails a day for each of your users.
await ops.impactLimits.create({
name: 'emails per user per day',
dimension: 'emails',
period: 'day',
amount: 20,
actionName: 'send-email',
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, "actionName": "send-email", "scope": "end_user" }'ops.impact_limits.create(name="daily emails", dimension="emails", period="day", amount=500)
ops.impact_limits.create(
name="emails per user per day",
dimension="emails",
period="day",
amount=20,
action_name="send-email",
scope="end_user",
){ "dimension": "emails", "unit": "emails", "currency": null, "limit": 20, "available": 20 }
Creating a limit needs impact-limits:write, which no key receives by default. A period is day, month or total. A day is the UTC day. actionName scopes a limit to one action, and resourcePrefix to a path. The resource key of a declared action is http:<host><path>. A limit belongs to one environment: the same name in two environments is two limits.
Invoke the action
The agent names the action and passes input. It holds no URL, no header and no credential.
const agent = new Client({ apiKey: process.env.ANLYON_AGENT_KEY! });
const { data } = await agent.actions.invoke('send-email', {
emailId: 'welcome-1',
to: ['a@example.com'],
subject: 'Welcome',
});
console.log(data!.status, data!.grade, data!.effectId);curl -s -X POST https://api.anlyon.com/api/v2/actions/send-email/invoke \
-H "Authorization: Bearer $ANLYON_AGENT_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: welcome-1" \
-d '{ "input": { "emailId": "welcome-1", "to": ["a@example.com"], "subject": "Welcome" } }'agent = Client(api_key=os.environ["ANLYON_AGENT_KEY"])
result = agent.actions.invoke(
"send-email",
{"emailId": "welcome-1", "to": ["a@example.com"], "subject": "Welcome"},
)
print(result.data["status"], result.data["grade"], result.data["effectId"]){ "status": "succeeded", "grade": "confirmed" }
The destination receives two requests for this call, in this order: the PUT write, then the GET read-back.
Invoke it for one of your users
Your server names the user. The call then counts against that user’s end_user limits, waits for their approval when a policy says decidedBy: "end_user", and its receipt carries their id. A {{connection:<integration>}} reference resolves to their own account.
// session.user.id comes from your own session, never from the model.
const user = agent.forUser(session.user.id);
const { data } = await user.actions.invoke('send-email', {
emailId: 'welcome-2',
to: ['a@example.com'],
subject: 'Welcome',
});curl -s -X POST https://api.anlyon.com/api/v2/actions/send-email/invoke \
-H "Authorization: Bearer $ANLYON_AGENT_KEY" \
-H "Anlyon-End-User: user_123" \
-H "Content-Type: application/json" \
-d '{ "input": { "emailId": "welcome-2", "to": ["a@example.com"], "subject": "Welcome" } }'user = agent.for_user(session_user_id)
result = user.actions.invoke(
"send-email",
{"emailId": "welcome-2", "to": ["a@example.com"], "subject": "Welcome"},
)Review the exact request before it runs
Every governed invocation has a preview: the normalized request, the resolved target, the action and adapter versions, the preconditions and an expiry. Anlyon hashes those into a bindingDigest. An approval is stored with that digest. Dispatch recomputes it and refuses on any difference.
You can create the preview yourself and show it to a reviewer before invoking.
const input = { emailId: 'welcome-1', to: ['a@example.com'], subject: 'Welcome' };
const { data: preview } = await agent.actions.preview('send-email', input);
console.log(preview!.id, preview!.bindingDigest, preview!.expiresAt);
for (const block of preview!.blocks) console.log(block.type, block.title);
await agent.actions.invoke('send-email', input, { previewId: preview!.id });curl -s -X POST https://api.anlyon.com/api/v2/actions/send-email/previews \
-H "Authorization: Bearer $ANLYON_AGENT_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": { "emailId": "welcome-1", "to": ["a@example.com"], "subject": "Welcome" } }'
curl -s -X POST https://api.anlyon.com/api/v2/actions/send-email/invoke \
-H "Authorization: Bearer $ANLYON_AGENT_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": { "emailId": "welcome-1", "to": ["a@example.com"], "subject": "Welcome" }, "previewId": "prv_01JABCDEF" }'payload = {"emailId": "welcome-1", "to": ["a@example.com"], "subject": "Welcome"}
preview = agent.actions.preview("send-email", payload).data
print(preview["id"], preview["bindingDigest"], preview["expiresAt"])
for block in preview["blocks"]:
print(block["type"], block["title"])
agent.actions.invoke("send-email", payload, preview_id=preview["id"]){
"adapter": { "type": "http.declared" },
"impact": [{ "dimension": "emails", "amount": 1, "bound": "exact" }],
"request": { "headers": { "Authorization": "Bearer {{secret:MAILER_TOKEN}}" } },
"blocks": [{ "type": "impact", "title": "Expected impact: 1 emails" }]
}
- The stored request keeps the credential as a reference. No preview, effect or evidence holds the credential. The transport resolves the reference when it sends.
- Creating this preview sent nothing to
api.example.com. Anlyon cannot read an unknown API before the write, so the preview is the request itself. - The preview’s
limitationsblock lists what a declared action does not have. Show it to the reviewer.
What a previewId does. The invocation must match the reviewed request exactly. A different recipient list, subject or id returns 409 PREVIEW_MISMATCH at admission and creates no effect. A preview is used once: a second invocation with the same id returns 409 PREVIEW_ALREADY_USED. An expired one returns 409 PREVIEW_EXPIRED. A preview you create lasts one hour unless you pass ttlSeconds, from 60 seconds to 7 days. Without a previewId the invocation builds its own preview, which lasts as long as the approval window. The binding is the same either way.
Approve the bound request
When the action has requiresApproval: true, or an approval policy matches the call, the invocation parks and returns the approval. Nothing is sent.
{ "status": "pending_approval", "pendingApproval": true, "approvalId": "apr_01JABCDEF", "grade": "pending" }
The effect waits at stage: "awaiting_approval". Approving is what dispatches it. Who approves depends on the policy:
- Your team (
decidedBy: "team", the default): a workspace member in the console or Slack, or a key withapprovals:decide. A key can never decide an approval it requested. - The user the call acts for (
decidedBy: "end_user"): your server relays the user’s decision withendUsers.approvals.decide, which needsend-users:approvals. See the quickstart.
A team approval from code:
const { data: decided } = await ops.approvals.approve(data!.approvalId!, { note: 'Checked the recipient.' });
console.log(decided!.invocation?.status);
const { data: effect } = await ops.actions.effect(data!.effectId!);
console.log(effect!.grade, effect!.bindingDigest);curl -s -X POST https://api.anlyon.com/api/v2/approvals/apr_01JABCDEF/approve \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d '{ "note": "Checked the recipient." }'
curl -s https://api.anlyon.com/api/v2/actions/effects/eff_01JABCDEF \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY"decided = ops.approvals.approve(result.data["approvalId"], note="Checked the recipient.").data
print(decided["invocation"]["status"])
effect = ops.actions.effect(result.data["effectId"]).data
print(effect["grade"], effect["bindingDigest"])After the approval, the invocation comes back succeeded and the effect grades confirmed. The digest stored on the approval equals the effect’s bindingDigest, and the destination receives one write. See When approval expires or changes.
Read the grade
The invoke response carries the grade. The effect carries the evidence behind it.
const { data: effect } = await agent.actions.effect(data!.effectId!);
console.log(effect!.grade, effect!.verification);
for (const item of effect!.evidence) console.log(item.source, item.summary);
const { data: unread } = await ops.actions.effects({ grade: 'acknowledged', action: 'send-email' });curl -s https://api.anlyon.com/api/v2/actions/effects/eff_01JABCDEF \
-H "Authorization: Bearer $ANLYON_AGENT_KEY"
curl -s "https://api.anlyon.com/api/v2/actions/effects?grade=acknowledged&action=send-email" \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY"effect = agent.actions.effect(result.data["effectId"]).data
print(effect["grade"], effect["verification"])
for item in effect["evidence"]:
print(item["source"], item["summary"])
unread = ops.actions.effects(grade="acknowledged", action="send-email").data{
"stage": "settled",
"outcome": "succeeded",
"grade": "confirmed",
"verification": "provider",
"adapter": { "type": "http.declared", "version": "1" },
"attempts": [{ "kind": "dispatch", "status": "completed" }],
"evidence": [
{ "source": "preview" },
{ "source": "system" },
{ "source": "provider_response" },
{ "source": "provider_lookup" }
]
}
The last evidence entry is the read-back. Its summary says the read-back matched the declared verify rule. The same action with no verify rule answers { "outcome": "succeeded", "grade": "acknowledged" }.
| Grade | Meaning |
|---|---|
confirmed |
The outcome is succeeded and a read-back matched. |
acknowledged |
The provider accepted the request with a 2xx. No read-back has matched. An operator’s manual succeeded also grades here. |
unknown |
No usable response. Anlyon does not send it again. It stays unknown until a read-back or an operator settles it. The allowance stays held. |
failed |
The provider rejected the request, or the request provably never left Anlyon. |
refused |
Anlyon refused at dispatch, for example on an exhausted limit. |
denied |
The approval was denied. |
pending |
No receipt yet. The effect is waiting for approval or is being dispatched. |
A receipt is a database record with provider evidence. See Receipts and grades.
Change the declarations
declare sends a PATCH that carries the declarations and nothing else. update takes the same three fields beside the rest of the definition.
// Replace the impact. The verify rule is not named, so it is kept.
await ops.actions.declare('send-email', {
impact: { dimension: 'emails', amount: 'count(input.to) * 2', bound: 'upper_bound' },
});
await ops.actions.declare('send-email', { verify: null }); // remove the read-back
await ops.actions.declare('send-email', { governed: false }); // remove every declarationcurl -s -X PATCH https://api.anlyon.com/api/v2/actions/send-email \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d '{ "impact": { "dimension": "emails", "amount": "count(input.to) * 2", "bound": "upper_bound" } }'
curl -s -X PATCH https://api.anlyon.com/api/v2/actions/send-email \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d '{ "verify": null }'# Replace the impact. The verify rule is not named, so it is kept.
ops.actions.declare(
"send-email",
impact={"dimension": "emails", "amount": "count(input.to) * 2", "bound": "upper_bound"},
)
ops.actions.declare("send-email", verify=None) # remove the read-back
ops.actions.declare("send-email", governed=False) # remove every declarationnullremoves that one declaration. Omission keeps what the action already declares.governed: falseremoves all declarations. Sending it beside animpactor averifyis refused.- Setting an impact replaces the whole impact. The same holds for the verify rule.
- Each change is a new immutable action version. A pin or a rollback restores a version’s declarations with its definition.
Scopes. Declaring on an action that declares nothing needs actions:write. Changing or removing what a governed action already declares also needs actions:govern, which is not granted by default:
Changing what a governed action declares needs the "actions:govern" scope, which is not granted by default.
The agent a limit constrains should not be able to loosen the declaration that feeds it. A change to the description or another field that leaves the declarations alone does not need actions:govern.
Declare from the CLI
anlyon actions declare sets and removes the same declarations. A flag you leave out keeps what the action declares.
# One call sends count(input.to) emails.
anlyon actions declare send-email --dimension emails --amount 'count(input.to)' --bound exact --yes
# Money needs its currency.
anlyon actions declare refund-payment --dimension money --unit usd --amount input.amount --bound upper_bound --yes
# Read the write back after dispatch.
anlyon actions declare send-email \
--verify-url 'https://api.example.com/v1/emails/{{input.emailId}}' --verify-status 200 \
--verify-match 'subject={{input.subject}}' --yes
anlyon actions declare send-email --governed --yes # governed, nothing counted
anlyon actions declare send-email --no-verify --yes # remove the read-back
anlyon actions declare send-email --no-impact --yes # remove the impact
anlyon actions declare send-email --ungoverned --yes # remove every declaration
anlyon actions get send-email # shows governed, impact and verify
anlyon effects list --action send-email --grade refused
--verify-match may be repeated, up to 10 times. A value that reads as a number, true, false or null is sent as that. Quote it as JSON to send a string. Without --yes a non-interactive run sends nothing. No browser login grants actions:govern, so use an operator API key to change what a governed action declares.
Import actions from an OpenAPI spec
To declare many operations at once, import an OpenAPI 3.x spec. Every operation that is not a GET is imported governed, declaring one resource_mutations per call. Each imported action also carries a suggestion read from the spec (a risk class, whether to require approval, and an impact such as money or emails per recipient) and, where the spec has a matching GET, a proposedVerify rule. Neither is applied until you accept it. Operations Anlyon cannot express faithfully are skipped with a reason, never imported in a form that looks right and is not.
Import needs actions:write. Creating actions that send a secret named in auth also needs secrets:read. Run it with dryRun: true first: nothing is created.
const spec = await fetch('https://api.example.com/openapi.json').then((r) => r.json());
const auth = { headerName: 'Authorization', secretName: 'MAILER_TOKEN', valueTemplate: 'Bearer {{secret}}' };
const { data: dry } = await ops.actions.importFromOpenApi(spec, { auth, dryRun: true });
console.log(dry!.created.map((a) => [a.name, a.suggestion.risk, a.suggestion.impact]));
console.log(dry!.skipped); // [{ path, method, reason }]
console.log(dry!.suggestedAllowedHosts); // set these on the secret
// Accept the suggestions you checked, then import for real.
const operations = Object.fromEntries(
dry!.created
.filter((a) => a.governed && a.suggestion.impact?.unit !== null)
.map((a) => [`${a.method} ${a.path}`, { requiresApproval: a.suggestion.requiresApproval, impact: a.suggestion.impact }]),
);
await ops.actions.importFromOpenApi(spec, { auth, operations });curl -s -X POST https://api.anlyon.com/api/v2/actions/import \
-H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
-H "Content-Type: application/json" \
-d "{
\"spec\": $(cat openapi.json),
\"auth\": { \"headerName\": \"Authorization\", \"secretName\": \"MAILER_TOKEN\", \"valueTemplate\": \"Bearer {{secret}}\" },
\"dryRun\": true
}"import json
from pathlib import Path
spec = json.loads(Path("openapi.json").read_text())
auth = {"headerName": "Authorization", "secretName": "MAILER_TOKEN", "valueTemplate": "Bearer {{secret}}"}
dry = ops.actions.import_openapi(spec, auth=auth, dry_run=True).data
for action in dry["created"]:
print(action["name"], action["suggestion"]["risk"], action["suggestion"]["impact"])
print(dry["skipped"])
ops.actions.import_openapi(spec, auth=auth, operations={"POST /v1/emails": {"requiresApproval": True}})operations is keyed by operationId or "METHOD /path". impact: null imports that operation ungoverned. only limits the import to the operations you name. After checking a proposedVerify reads back what the write changed, add it with actions.declare(name, { verify }).
Fix a refused definition or call
| What you see | Why | What to do |
|---|---|---|
403 Referencing a secret requires the "secrets:read" scope |
The key saving the action cannot reference credentials. | Save the action with an operator key holding secrets:read. The agent key does not need it. |
400 on save: urlTemplate has an unrecognised placeholder |
A placeholder other than {{input.x}}, {{secret:NAME}}, {{connection:<integration>}} or {{connection.host}}. |
Fix the template. |
400 on save: a secret or connection may only be sent to … |
The URL’s host is not one the credential may reach. | Point the action at the credential’s host, or add the host to the secret’s allowedHosts. |
400 on save: an amount expression or a verify host refused |
The amount is outside the grammar, or the verify URL is on another host. | Use 1, input.x, count(input.x), optionally * n. Read back on the action’s own host. |
403 naming actions:govern |
The key is changing what a governed action declares. | Use an operator key with actions:govern. |
409 PREVIEW_MISMATCH |
The invocation differs from the reviewed preview. | Preview the new input and review it again. |
409 PREVIEW_ALREADY_USED or 409 PREVIEW_EXPIRED |
A preview runs once, and within its lifetime. | Create a new preview. |
200 with status: "failed", grade: "refused", impact_limit_exceeded in error |
A limit had no room. Nothing was sent. | Wait for the next period or raise the limit. See When the limit is hit. |
200 with grade: "refused", impact_unbounded in error |
The amount reads an input the caller left out, and a limit applies. | Make that input required in the schema. |
409 END_USER_NOT_CONNECTED |
The user the call acts for has not connected the integration. Nothing was sent. | Show the user a connect button with the connectUrl. See Workspace and end-user connections. |
400 END_USER_REQUIRED |
The key requires an end user and the call named none. | Build the client with forUser() on your server. |
grade: "acknowledged" where you expected confirmed |
No verify rule, or the read-back did not match. | Check the provider_lookup evidence and your match paths. |
grade: "unknown" |
The response was lost. Anlyon does not send the write again. | Do not retry. See When the outcome is unknown. |
Know what a declared action does not do
- The write is sent once. A declared action sends no idempotency key to the provider, so a lost response is recovered by the read-back or by an operator. A replay is refused before anything is sent.
- The approval binds the exact request. Provider state between review and dispatch is outside the binding.
- The amount is what you wrote. For an API you declare, you write what the action counts, and Anlyon enforces it before dispatch.
confirmedmeans your own verify rule matched.
When the limit is hit
What the caller sees when a limit refuses a call.
When approval expires or changes
Preview expiry, a changed request and a changed action.
When the outcome is unknown
A lost response, the held allowance and how it settles.
Act for your users
Users connect their accounts, approve in your app and stay under their own limits.
Install a pack
Ready-made declared actions for each integration.
Impact limits
How capacity is reserved, settled, released and held.

