Skip to main content

Register an agent

Give an agent its own identity in the registry, choose how it proves that identity, and say what it may do.

RecipeReadyView source
Works with
lumo CLIPlain HTTP

What it shows​

  1. The script looks for an agent with the name "Invoice intake agent". A name is a label, so LumoAuth accepts the same name twice.
  2. It registers the agent with the identity type client_secret and two capabilities, invoices:read and invoices:propose.
  3. 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.
  4. The script reads the agent back and prints its state.
  5. 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:

ValueThe agent proves its identity with
api_keyAn API key (agk_…). This is the default.
client_secretIts agent ID as the client ID, and a secret.
private_key_jwtAn assertion that it signs with its own private key. See An agent that signs in with a key.
workloadA token from the platform that runs it. See An agent in GitHub Actions with no secret.
aauthA signature on each request. See Sign every request with AAuth.
customA 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:read and admin:agents:write. Create it in the portal under Applications & developer tools, API keys.
  • curl and jq. The CLI version also needs the lumo CLI.
VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYAn API key with the scopes admin:agents:read and admin:agents:write.
AGENT_FILEOptional. 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.

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

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 registered with 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_FILE names holds the answer of the registration. The member clientSecret is the secret, and agentId is 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 identityType does not change it.
  • LumoAuth stores a capability in lower case: Invoices:Read becomes invoices: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.