Skip to content
1Claw Academy
Curriculum/Transactions & Treasury3 minAdvanced · Lesson 14 of 16

Bankr dynamic key vending

Lease short-lived partner API keys instead of storing a static one, and keep the key out of agent output entirely.

Some partner credentials should never sit in a vault as a static secret. Bankr key vending is a secret engine: you store one partner key server-side, and 1Claw mints scoped, TTL-bound user keys on demand.

  • The partner key (bk_ptr_) is held server-side as BANKR_PARTNER_KEY.
  • The Vault issues short-lived bk_usr_ keys scoped to a single agent.
  • Recommended TTL is 5-15 minutes; the agent default is 15 minutes and the hard maximum is 24 hours.
  • This is preferred over storing a Bankr credential with put_secret.
Watch out

Deny-by-default: an agent needs an explicit policy on agents/{id}/bankr/* inside the __agent-keys vault before it can lease anything.

  1. 1

    Grant the agent leasing rights with a policy on its Bankr path.

    bash
    curl -s -X POST https://api.1claw.co/v1/vaults/$AGENT_KEYS_VAULT/policies \
      -H "Authorization: Bearer $ONECLAW_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "principal_type": "agent", "principal_id": "'$AGENT_ID'",
        "path_pattern": "agents/'$AGENT_ID'/bankr/*",
        "permissions": ["read"]
      }'
  2. 2

    Lease a key with a short TTL.

    bash
    curl -s -X POST https://api.1claw.co/v1/agents/$AGENT_ID/bankr-keys \
      -H "Authorization: Bearer $AGENT_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"ttl_seconds": 600}'
  3. 3

    Note what comes back to an agent caller: metadata, but no api_key field.

    json
    { "lease_id": "...", "expires_at": "...", "scope": "bankr:wallet" }
  4. 4

    List and revoke active leases.

    bash
    curl -s https://api.1claw.co/v1/agents/$AGENT_ID/bankr-keys \
      -H "Authorization: Bearer $ONECLAW_TOKEN"
Tip

Agent lease responses omit api_key on purpose, and the MCP lease_bankr_key tool never returns the key in its output. Shroud resolves the real key at request time, so it never enters the model's context.

The pattern generalises: when a credential can be minted on demand, leasing beats storing. There is nothing long-lived to leak, and expiry is the default rather than something you have to remember to do.

Where this goes wrong in practice. Vending removes the static credential and introduces a lifecycle, which is a smaller problem that still has to be managed.

  • TTLs drift upward. Each extension is justified by one long job, and the ceiling becomes the default, at which point leasing has recreated the static key it replaced.
  • Leases are never revoked. Expiry eventually handles it, but an incident needs immediate revocation, and teams discover the endpoint exists while trying to use it.
  • The lease response is logged. It omits api_key by design, and a service that logs whole responses can still capture surrounding metadata useful to an attacker.
  • The path policy is written broadly. Vending is deny-by-default and a glob written as agents/** grants far more than the one agent's Bankr path.
Concept

The general rule this illustrates: when a credential can be minted on demand, leasing beats storing. There is nothing long-lived to leak and expiry is the default rather than an operational chore.

Decide

An agent needs a Bankr key for a long-running job that may take up to six hours. A developer requests a lease with a 24-hour TTL so the job cannot fail partway through on an expired credential.

What is the better design?

Check your understanding

3 questions
1

Why does an agent's Bankr lease response omit the api_key field?

2

What must exist before an agent can lease a Bankr key?

3

What is the recommended TTL for a leased Bankr key?