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

Secrets

Store an API credential in Anlyon's write-only vault, bind it to the hosts and request parts it may reach, and reference it from actions so the key never enters your agent's process or the model's context.

A secret is a credential Anlyon keeps for you, such as a Stripe or GitHub key. An action references it as {{secret:NAME}}. Anlyon decrypts it at the moment of dispatch, puts it in the request it is about to send, and sends it. The value is never returned to anyone, never written to a log, and never present in the context the model reads.

Why keep credentials in the vault

A key in your agent’s environment is a key the model can be talked into using: printed into a reply, sent to an attacker’s host, or used for a call nobody intended.

  • Risk. There is no endpoint that returns a secret’s value, so a leaked agent key cannot read your Stripe key. A secret can be bound to the hosts it may be sent to and the part of the request it may appear in, and the binding is checked again on every call.
  • Cost. A rotation is one write. Every action that references the name uses the new value on its next call, with no redeploy of your agents.
  • Effort. You do not build encryption, rotation, redaction of echoed keys or per-host rules. Responses and errors are scrubbed of every secret value before Anlyon stores them.

Store a secret

Writing a secret needs secrets:write. Referencing one needs secrets:read, because a reference is a use: a key that can put {{secret:STRIPE_KEY}} into an action can cause that secret to be sent somewhere. Neither scope is in a key’s default set, so give them to an operator key, never to the agent’s.

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

// An operator key with secrets:read and secrets:write.
const ops = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });

await ops.secrets.put('STRIPE_KEY', {
  value: process.env.STRIPE_KEY!,
  description: 'Restricted key: refunds and customers',
  allowedHosts: ['api.stripe.com'],
  allowedPlacements: ['header'],
});

// Metadata only. No method returns a value, because no endpoint does.
const { data: secrets } = await ops.secrets.list();
curl -X PUT https://api.anlyon.com/api/v2/secrets/STRIPE_KEY \
  -H "Authorization: Bearer $ANLYON_OPERATOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "'"$STRIPE_KEY"'",
    "description": "Restricted key: refunds and customers",
    "allowedHosts": ["api.stripe.com"],
    "allowedPlacements": ["header"]
  }'
import os
from anlyon import Client

# An operator key with secrets:read and secrets:write.
ops = Client(api_key=os.environ["ANLYON_OPERATOR_KEY"])

ops.secrets.put(
    "STRIPE_KEY",
    value=os.environ["STRIPE_KEY"],
    description="Restricted key: refunds and customers",
    allowed_hosts=["api.stripe.com"],
    allowed_placements=["header"],
)

# Metadata only.
secrets = ops.secrets.list().data

PUT /api/v2/secrets/{name} creates the secret or rotates it, and answers with metadata:

{
  "success": true,
  "data": {
    "id": "sec_01JABCDEF",
    "name": "STRIPE_KEY",
    "description": "Restricted key: refunds and customers",
    "kind": "static",
    "allowedHosts": ["api.stripe.com"],
    "allowedPlacements": ["header"],
    "connection": null,
    "integrationId": null,
    "health": null,
    "external": null,
    "lastUsedAt": null,
    "createdAt": "2026-10-27T09:00:00.000Z",
    "updatedAt": "2026-10-27T09:00:00.000Z"
  }
}

The rules:

  • A name is 1 to 100 characters of A-Z 0-9 _, such as STRIPE_KEY.
  • A value is 1 to 8,192 characters.
  • Secrets belong to one environment. A staging key cannot see or use a production secret. See Environments.
  • Each secret counts toward your plan’s secret limit. Past it, a new secret answers 402 QUOTA_EXCEEDED.

secrets.get(name) returns the name, the description, the bindings described below, kind, health and when it was last used. It never returns the value, and neither does any other operation on any surface. This is not an access rule you could misconfigure: the endpoint does not exist.

The operations: list, get, create or rotate and delete.

Reference a secret from an action

{
  "urlTemplate": "https://api.stripe.com/v1/refunds",
  "headers": { "Authorization": "Bearer {{secret:STRIPE_KEY}}" }
}

Saving that action needs secrets:read on the key that saves it. The agent that invokes it needs only actions:invoke. See Actions.

A connected account is a secret too, with kind: "connection", or kind: "static" with integrationId set when it was connected with an API key. On a call made for one of your users, a secret bound to an integration resolves to that user’s account for the integration, not your workspace’s. A secret with no integration, such as STRIPE_KEY above, is always your workspace’s. See Workspace connections and end-user connections.

Limit where a secret may go

Two constraints apply: one always, and one when you set it.

A secret-bearing action always has a fixed destination

An action that references a secret must have a fixed scheme and host. You cannot put {{input.*}} in the host of a URL that carries a credential, because the invoker would then choose the recipient of your key. A secret in the URL’s authority (https://{{secret:X}}@host) is refused outright: it would be handed to DNS resolution before the request was made.

This holds for every secret-bearing action with no configuration on your part.

Bind the secret to hosts and placements

A secret can carry its own policy, independent of any action:

Field Meaning
allowedHosts Up to 20 hosts this secret may be sent to. A leading dot matches subdomains, so .stripe.com admits api.stripe.com. Required when you create a stored value: a write that would leave a secret with no hosts is refused, because a secret with none could be sent to any host. Omit it on a rotation to keep the hosts it has. A secret stored before this rule with no hosts keeps working, shows allowedHosts: null, and must name its hosts on its next write. A secret read from your own secret store must also name at least one host when it is created.
allowedPlacements Where in the request it may appear: url, header or body. Null or omitted means anywhere for a stored value, and header for a secret read from your own store. A credential in a header is the intended use. The same value in a URL is usually a mistake or an exfiltration.

Both are checked when an action is saved, and again at dispatch on every call: allowedHosts against the host actually being called, allowedPlacements against where the action puts the secret.

  • When you save an action that breaks a binding, the request answers 400 VALIDATION_ERROR with a message such as Secret STRIPE_KEY may only be sent to api.stripe.com, and this action addresses example.com.
  • When an older action breaks a tightened binding, its next call fails before anything is sent, and the invocation’s error names the secret and the rule. You do not have to edit the action for the new binding to apply.
  • Omitting allowedHosts on a rotation leaves the existing value alone, so rotating a secret never widens where it may go.

In the console, Secrets asks for the hosts every time you store a secret, and allows it only in a header unless you also tick URL or Body. To rotate a secret there, use the rotate button on its row: the form starts from its current hosts and placements. A secret stored before the console asked for hosts shows Any public host, and rotating it asks you to name them.

Rotate or delete a secret

secrets.put() on an existing name rotates it. The next dispatch resolves the new value.

A call already waiting for approval resolves whatever is current when it finally runs, not what was current when the person clicked approve. An approval freezes the request that was reviewed. It does not keep a credential that has since been rotated or removed.

Delete a secret with secrets.delete(name) or DELETE /api/v2/secrets/{name}. Calls to actions that reference it fail before anything is sent, with Secret not found: NAME in the invocation’s error, until a secret with that name exists again. Deleting a connected account also revokes its access first; see Disconnect an account.

How secrets work in a governed action

A governed action persists the request it will send, shows it to the reviewer and hashes it into the approval’s digest. None of those holds a credential.

  • A declared action keeps every {{secret:NAME}} reference as a placeholder in the stored request. The reviewer sees Authorization: Bearer {{secret:MAILER_TOKEN}}, and the digest covers that text.
  • Anlyon resolves the placeholders at dispatch, when the request is sent. The host and placement bindings of each secret are checked again at that point.
  • The read-back of a verify rule goes out with the action’s own headers, so it uses the same secret under the same bindings.
  • An input that spells a secret reference is refused. An input can never cause a secret to be resolved.
  • An adapter action names one vault secret as credentialSecret. The adapter checks the key’s shape. The secret must exist in the environment’s vault even when the action is only called for end users: a call made for an end user then uses that user’s own connection for the secret’s integration, or the stored value when the secret has no integration.

A binding tightened after review is enforced at dispatch. The approved effect is refused, and nothing is sent:

{ "stage": "rejected", "rejectionReason": "credential_unavailable", "grade": "refused" }

Read secrets from your own secret store

A secret can point into your own secret manager instead of holding a value. Anlyon reads the value when an action calls it, uses it for that one request, and does not write it to its own storage. Two stores are supported:

Store type Sign-in A secret points at
AWS Secrets Manager aws_secrets_manager Access keys, or access keys that assume a role (with an optional external id) A secret name or ARN, optionally one key of its JSON and a version id or staging label
HashiCorp Vault, KV version 2 hashicorp_vault A token, or AppRole A path under the mount, one key of its data, optionally a version number

Adding or changing a store needs the Team plan; a store added earlier keeps serving its secrets after a plan change, and you can always remove it. Otherwise the request answers 403 PLAN_FEATURE_REQUIRED. See Billing.

Add a store to an environment once, with a key holding secret-stores:write. The same key, with secrets:write, points secrets into it. Anlyon signs in to the store before saving it, and refuses the store if that fails. The store’s own credential is encrypted like a secret’s value and is never returned.

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

// An operator key with secret-stores:write and secrets:write.
const ops = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });

await ops.secretStores.create({
  name: 'prod-vault',
  type: 'hashicorp_vault',
  config: { address: 'https://vault.example.com:8200', auth: 'approle' },
  credential: { roleId: process.env.VAULT_ROLE_ID!, secretId: process.env.VAULT_SECRET_ID! },
  allowedPaths: ['payments'],
});

await ops.secrets.putExternal('STRIPE_KEY', {
  external: { store: 'prod-vault', path: 'payments/stripe', key: 'apiKey' },
  allowedHosts: ['api.stripe.com'],
  allowedPlacements: ['header'],
});
import os
from anlyon import Client

# An operator key with secret-stores:write and secrets:write.
ops = Client(api_key=os.environ["ANLYON_OPERATOR_KEY"])

ops.secret_stores.create(
    name="prod-vault",
    type="hashicorp_vault",
    config={"address": "https://vault.example.com:8200", "auth": "approle"},
    credential={"roleId": os.environ["VAULT_ROLE_ID"], "secretId": os.environ["VAULT_SECRET_ID"]},
    allowed_paths=["payments"],
)

ops.secrets.put_external(
    "STRIPE_KEY", store="prod-vault", path="payments/stripe", key="apiKey",
    allowed_hosts=["api.stripe.com"], allowed_placements=["header"],
)

An action references it as {{secret:STRIPE_KEY}}, like any other secret. The host and placement bindings apply in the same way, and so does redaction: the value is scrubbed from responses and errors before they are stored.

  • Reads are cached briefly, in memory only. A value read from the store is kept in memory for the store’s cacheTtlSeconds (30 by default, at most 300), so a rotation in your store reaches Anlyon within that time. Set it to 0 to read the store at every call. Changing the store’s settings or credential drops what was cached. A change to where the credential is sent, such as a Vault store’s address or an AWS store’s region or roleArn, needs the credential again in the same request.
  • A secret can be saved before your store holds it. Anlyon reads the value once when the secret is saved, and drops it. If the store cannot produce it yet, the secret is still saved, its health is unreachable with the reason, and the response carries a warning (EXTERNAL_SECRET_UNREADABLE). A reference that is wrong in itself, such as an unknown store or a path outside the store’s allowedPaths, is refused with 400.
  • A store that cannot produce the value stops the call before anything is sent. A template action records the invocation as failed, and its error says which secret and store could not be read and why. A governed action is refused with credential_unavailable, graded refused. The secret’s health records the reason: store_unreachable, store_denied or reference_not_found.
  • Health shows reachability. The secret’s health is active, or unreachable with the same reason. Anlyon records it at each read, on secrets.check(name) (POST /api/v2/secrets/{name}/check), and once a day on its own.
  • Your store’s policy is the boundary. Anlyon can read whatever the store’s credential can read. Give that credential read access only to the secrets Anlyon should use. allowedPaths on the store adds a second limit inside Anlyon, checked when a secret is saved and again at each read.
  • Requests to the store pass the same address checks as an action call. A store must be reachable at a public address. Private, link-local and cloud metadata addresses are refused.
  • Managing stores needs secret-stores:read or secret-stores:write, privileged scopes no key receives by default and no OAuth consent screen offers. In the console, changing a store needs the admin role. Creating or repointing a secret that points into a store needs secret-stores:write as well as secrets:write, and the admin role in the console, because the reference chooses which of the store’s secrets Anlyon reads and where the value may be sent. Reading and referencing such a secret uses secrets:read like any other.

Handle secret errors

Status and code When What to do
400 VALIDATION_ERROR An action you save breaks a secret’s host or placement binding, or puts a secret in a URL’s authority. Change the action, or the secret’s binding.
402 QUOTA_EXCEEDED A new secret would pass your plan’s secret limit. Delete an unused secret, or change plan.
403 The key lacks secrets:write, secrets:read (to reference), or secret-stores:write (to point into a store). Use an operator key with the scope.
403 PLAN_FEATURE_REQUIRED Adding or changing a secret store on a plan without Team features. See Billing.
Invocation failed, error Secret not found: NAME An action references a secret that does not exist in the environment. Nothing was sent. Store it under that name in the same environment as the action.
409 SECRET_KIND_MISMATCH PUT on a connected account, which cannot hold a stored value. Reconnect the account instead, or delete it first.
Invocation failed, or effect refused with credential_unavailable A binding was tightened after the action was saved, or your secret store could not produce the value. Nothing was sent. The invocation’s error names the secret and the rule or the store. Fix the action, the binding or the store.

Know what the vault covers

  • The vault covers credentials stored in it, used by actions Anlyon dispatches. A key your own process holds stays in your process, including behind the local approval gate.
  • A limit, an approval and a receipt apply to calls routed through an action. Keep the key in the vault and out of the agent’s process.
  • A credential is resolved at dispatch. A secret rotated, removed or rebound after review is resolved as it stands then.
  • Your users’ own accounts are connections, not secrets you store. See Workspace connections and end-user connections.
  • Environments are logical isolation. Secrets belong to an environment through an enforced column in shared storage.

Was this page helpful?