Skip to content
Workforce IdentityMarkdown

Register an agent

Give an AI agent its own identity, with an owner, a risk class and a status, and a client it gets tokens through with no secret to leak.

APIRFC 6749, RFC 7523

An AI agent or automation calling your APIs should be an identity you can see, govern and stop, not a shared password in a config file. Once registered, the agent has a named owner, a risk class and a status, and gets short-lived tokens on its own account with no password or shared secret. Each token tells every API that an agent is calling, which one, how risky it is, and who owns it. This guide is for the team putting an agent to work.

Before you start:

  • Who can do it: a realm administrator (a group holding RealmOwner).
  • Where: today this is done through the API, with your session in $CVYUH_SESSION (Call the API).
  • What you need: the user accountable for the agent, its business owner (here maya); and either the public half of a key the agent holds, or the intent to hand it a one-time bootstrap assertion instead. The client’s scopes must be ones the realm offers (scopes in oauth2Settings): add your API’s, such as invoices:read, first, as in Sign users in to a web app.
  1. Create the agent:

    Terminal window
    curl -X POST "https://foobar.cvyuh.com/api/v0/am/objects/v1/agent?id=invoice-agent" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{
    "uid": "invoice-agent",
    "displayName": "Invoice agent",
    "purpose": "Matches supplier invoices to purchase orders",
    "riskClass": "limited",
    "autonomyTier": 2,
    "status": "active",
    "expiresAt": "<RFC 3339 time>"
    }'

    To create it under another agent, add "parent": [{ "id": "<parent's id>" }]. The parent can never change later.

  2. Name maya as its business owner:

    Terminal window
    curl -X POST https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/relationships/businessOwner \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "targetId": "maya" }'
  3. Register its client. With a key of its own (registeredKey):

    Terminal window
    curl -X POST "https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=invoice-agent-client" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{
    "status": "active",
    "clientName": "Invoice agent",
    "tokenEndpointAuthMethod": "private_key_jwt",
    "assertionTrust": "registeredKey",
    "jwks": {
    "keys": [
    { "kty": "EC", "crv": "P-256", "kid": "agent-1", "x": "…", "y": "…",
    "exp": <unix time, at most 90 days ahead> }
    ]
    },
    "grantTypes": ["client_credentials"],
    "scopes": ["invoices:read"],
    "defaultScopes": ["invoices:read"],
    "allowedResources": ["https://app.example.com/api"],
    "defaultAudience": "https://app.example.com/api"
    }'

    For a bootstrap instead, set "assertionTrust": "amBootstrap" and leave out jwks.

  4. Link the client to the agent:

    Terminal window
    curl -X POST https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/invoice-agent-client/relationships/agent \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "targetId": "invoice-agent" }'

    Once linked, a client that names no securityProfile is written fapi2: every token request it makes carries a DPoP proof, and its tokens come back DPoP-bound. Set "securityProfile": "oauth2.1" in step 3 only if the agent can’t send proofs. An agent’s client that authenticates by attestation (attest_jwt_client_auth) is written oauth2.1 instead, since FAPI 2.0 takes no attestation.

  5. With a bootstrap only, mint the agent’s first assertion and hand its assertion to the agent:

    Terminal window
    curl -X POST https://foobar.cvyuh.com/api/v0/am/clients/v1/invoice-agent-client/bootstrap \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

    It’s signed by the realm, valid five minutes, and used once, for the agent’s first token. Use it to hand an agent its first credential without handling a key yourself.

The agent asks for a token with an assertion signed by its key (or the bootstrap assertion), and a DPoP proof:

Terminal window
curl https://foobar.cvyuh.com/oauth2/token \
-H "DPoP: <proof>" \
-d grant_type=client_credentials \
-d client_id=invoice-agent-client \
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
-d client_assertion=eyJ…

Its token carries:

ClaimValue
subthe agent’s permanent id
principal_typeagent
modeautonomous: no user behind this request
risk_class, autonomy_tierfrom the agent
business_ownerthe owner’s name, maya

If the request is refused invalid_client, see AI agents. Each request, issued or refused, is a TOKEN_ISSUED record on the agent’s trail (Follow what an agent did).

Once a key is past its end it authenticates nothing. To rotate, add the next key with a later exp and a new kid, then remove the old one: both work while both are current.

  • Keys are judged only when they change. A write is checked against key ages only when it changes the keys, or assertionTrust, or links the client to its agent. Any other write stands whatever the keys’ age, so you can always disable an agent’s client, even one whose key has ended.
  • Keys at a jwksUri need an exp too. An agent’s client that publishes its keys at a jwksUri is checked at its first assertion, since nothing is fetched when it’s written: a key there with no exp is refused then. Publish an exp on each key.

To stop an agent you registered by mistake, retire it ({ "status": "retired" }), as in Stop an agent: it gets no token again. To stop only its client, set the client’s status to inactive.