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 (scopesinoauth2Settings): add your API’s, such asinvoices:read, first, as in Sign users in to a web app.
Register it
Section titled “Register it”-
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. -
Name
mayaas 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" }' -
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 outjwks. -
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
securityProfileis writtenfapi2: 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 writtenoauth2.1instead, since FAPI 2.0 takes no attestation. -
With a bootstrap only, mint the agent’s first assertion and hand its
assertionto 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.
Check it worked
Section titled “Check it worked”The agent asks for a token with an assertion signed by its key (or the bootstrap assertion), and a DPoP proof:
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:
| Claim | Value |
|---|---|
sub | the agent’s permanent id |
principal_type | agent |
mode | autonomous: no user behind this request |
risk_class, autonomy_tier | from the agent |
business_owner | the 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).
Rotate its key
Section titled “Rotate its key”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
jwksUrineed anexptoo. An agent’s client that publishes its keys at ajwksUriis checked at its first assertion, since nothing is fetched when it’s written: a key there with noexpis refused then. Publish anexpon each key.
Undo it
Section titled “Undo it”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.
Related
Section titled “Related”- AI agents: every field an agent has, and what the realm holds to.
- Client authentication and Client credentials: how the client proves itself and gets tokens.
- Stop an agent: pause it or stop it for good.
- Let an agent act for a user: delegated tokens in a user’s name.