Register an agent
Give an agent its own identity in the registry, choose how it proves that identity, and say what it may do.
What it shows
- The script looks for an agent with the name "Invoice intake agent". A name is a label, so LumoAuth accepts the same name twice.
- It registers the agent with the identity type
client_secretand two capabilities,invoices:readandinvoices:propose. - LumoAuth answers with the agent ID (
agt_…) and the client secret. The script saves the answer in a file, because the secret is shown once. - The script reads the agent back and prints its state.
- It tries to add
invoices.pay, a capability in the dot form. LumoAuth refuses the request with 400 and stores nothing.
The identity type says how the agent proves who it is. The Admin API and the CLI take six values:
| Value | The agent proves its identity with |
|---|---|
api_key | An API key (agk_…). This is the default. |
client_secret | Its agent ID as the client ID, and a secret. |
private_key_jwt | An assertion that it signs with its own private key. See An agent that signs in with a key. |
workload | A token from the platform that runs it. See An agent in GitHub Actions with no secret. |
aauth | A signature on each request. See Sign every request with AAuth. |
custom | A method of your own. LumoAuth stores the agent and issues no credential. |
You can also register an agent in the portal. Open AI Agents, then Agents, and select Register agent. The three steps of the form ask for the same values: Who is this agent, How it proves its identity and What it may do.
Before you start
- An API key with the scopes
admin:agents:readandadmin:agents:write. Create it in the portal under Applications & developer tools, API keys. curlandjq. The CLI version also needs the lumo CLI.
| Variable | Value |
|---|---|
LUMOAUTH_URL | The address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region. |
LUMOAUTH_ORG_ID | Your organization, for example acme-corp. |
LUMOAUTH_API_KEY | An API key with the scopes admin:agents:read and admin:agents:write. |
AGENT_FILE | Optional. The file that receives the answer of the registration, with the client secret. Default: invoice-intake-agent.json in your home folder. |
Code
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization.
- lumo CLI
- curl
agents/register-an-agent/cli/register.sh
#!/bin/sh
# Register an agent with the lumo CLI, read it back, and try to add a
# capability in the wrong form.
#
# sh agents/register-an-agent/cli/register.sh
#
# The script needs the lumo CLI and jq.
set -eu
# The CLI has its own names for the three values of the recipes.
export LUMO_BASE_URL="$LUMOAUTH_URL" LUMO_ORG="$LUMOAUTH_ORG_ID" LUMO_API_KEY="$LUMOAUTH_API_KEY"
NAME="Invoice intake agent"
# The answer of the registration holds the client secret, and LumoAuth shows
# it once. Keep the file outside the repository.
AGENT_FILE="${AGENT_FILE:-$HOME/invoice-intake-agent.json}"
# 1. Register the agent. A name is a label, not a key: a second registration
# with the same name creates a second agent, so look for the name first.
AGENT_ID=$(lumo agents list --search "Invoice intake" -o json |
jq -r --arg name "$NAME" '[.data[] | select(.name == $name) | .agentId][0] // empty')
if [ -z "$AGENT_ID" ]; then
# 2. The identity type says how the agent proves who it is. It is fixed from
# here on. Each capability has the form <resource>:<action>.
(umask 077 && lumo agents create -o json \
--name "$NAME" \
--description "Reads incoming invoices and proposes them for approval." \
--type client_secret \
--capabilities invoices:read,invoices:propose > "$AGENT_FILE")
AGENT_ID=$(jq -r '.data.agentId' "$AGENT_FILE")
echo "registered: $AGENT_ID"
echo "client secret: saved in $AGENT_FILE"
else
echo "already registered: $AGENT_ID"
fi
# 3. Read the agent back.
lumo agents get "$AGENT_ID" -o json | jq -r '.data |
"status: \(.status)",
"identity type: \(.identityType)",
"capabilities: \(.capabilities | join(" "))"'
# 4. A capability in the dot form is refused, and the stored list stays as it
# is. The CLI prints the error as JSON and exits with a status that is not 0.
STATUS=$(lumo agents update "$AGENT_ID" -o json \
--capabilities invoices:read,invoices:propose,invoices.pay | jq -r '.status // 200')
echo "add invoices.pay: $STATUS"
sh agents/register-an-agent/cli/register.sh
agents/register-an-agent/http/register.sh
#!/bin/sh
# Register an agent through the Admin API, read it back, and try to add a
# capability in the wrong form.
#
# sh agents/register-an-agent/http/register.sh
#
# The script needs curl and jq.
set -eu
AGENTS="$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1/admin/agents"
NAME="Invoice intake agent"
# The answer of the registration holds the client secret, and LumoAuth shows
# it once. Keep the file outside the repository.
AGENT_FILE="${AGENT_FILE:-$HOME/invoice-intake-agent.json}"
api() { # method, address, body
curl --silent --show-error --fail-with-body --request "$1" "$2" \
--header "X-API-Key: $LUMOAUTH_API_KEY" \
--header "Content-Type: application/json" ${3:+--data "$3"}
}
# 1. Register the agent. A name is a label, not a key: a second registration
# with the same name creates a second agent, so look for the name first.
AGENT_ID=$(api GET "$AGENTS?search=Invoice%20intake" |
jq -r --arg name "$NAME" '[.data[] | select(.name == $name) | .agentId][0] // empty')
if [ -z "$AGENT_ID" ]; then
# 2. The identity type says how the agent proves who it is. It is fixed from
# here on. Each capability has the form <resource>:<action>.
(umask 077 && api POST "$AGENTS" '{
"name": "Invoice intake agent",
"description": "Reads incoming invoices and proposes them for approval.",
"identityType": "client_secret",
"capabilities": ["invoices:read", "invoices:propose"]
}' > "$AGENT_FILE")
AGENT_ID=$(jq -r '.data.agentId' "$AGENT_FILE")
echo "registered: $AGENT_ID"
echo "client secret: saved in $AGENT_FILE"
else
echo "already registered: $AGENT_ID"
fi
# 3. Read the agent back.
api GET "$AGENTS/$AGENT_ID" | jq -r '.data |
"status: \(.status)",
"identity type: \(.identityType)",
"capabilities: \(.capabilities | join(" "))"'
# 4. A capability in the dot form is refused, and the stored list stays as it is.
STATUS=$(curl --silent --output /dev/null --write-out '%{http_code}' --request PUT "$AGENTS/$AGENT_ID/scopes" \
--header "X-API-Key: $LUMOAUTH_API_KEY" \
--header "Content-Type: application/json" \
--data '{"scopes": ["invoices:read", "invoices:propose", "invoices.pay"]}')
echo "add invoices.pay: $STATUS"
sh agents/register-an-agent/http/register.sh
Check the result
Output
registered: agt_3f9a51c07be24d18
client secret: saved in /home/maya/invoice-intake-agent.json
status: active
identity type: client_secret
capabilities: invoices:read invoices:propose
add invoices.pay: 400
- Run the script again. It finds the agent and prints
already registeredwith the same agent ID. - In the portal, open AI Agents, then Agents. The list shows the agent with its identity type and its status.
- The file that
AGENT_FILEnames holds the answer of the registration. The memberclientSecretis the secret, andagentIdis the client ID. An agent gets its first token uses both.
Limits
- The identity type of an agent is fixed at registration. An update that sends another
identityTypedoes not change it. - LumoAuth stores a capability in lower case:
Invoices:Readbecomesinvoices:read. - The secret cannot be read again. When you lose it, rotate the credential with
lumo agents rotate-credentials, which ends the old secret at once. - Two settings of an agent exist in the portal only: who may use the agent for just-in-time requests, and its A2A agent card.