Agent Auth
Register AI agents, approve capabilities, and call the Commerce API via the Agent Auth Protocol.
The Commerce API implements Better Auth Agent Auth on top of the same OpenAPI contract documented at Commerce API.
AI agents can discover, register, request capabilities, and call commerce operations with delegated user authority.
What the merchant decides
With Agent Auth, an AI agent starts with nothing until you approve it for your store. After that it keeps the public catalog, and anything else needs your approval. You see every capability the agent asks for and approve or deny the request as a whole. Approved access ends after an hour idle, or 24 hours at most. Then the agent asks again.
An API key isn't Agent Auth: anything holding an admin key can do what the key allows, without asking.
Agent Auth is coming with Grow. Free keys reach the 21 storefront tools.
Discovery
Agents load the provider configuration from:
GET https://<api-host>/.well-known/agent-configurationResponse includes:
{
"version": "1.0-draft",
"provider_name": "Prood Commerce API",
"description": "Multi-tenant commerce HTTP API. ...",
"issuer": "http://localhost:3005/api/auth",
"default_location": "http://localhost:3005/api/auth/capability/execute",
"algorithms": ["Ed25519"],
"modes": ["delegated", "autonomous"],
"approval_methods": ["ciba", "device_authorization"],
"endpoints": {
"register": "http://localhost:3005/api/auth/agent/register",
"capabilities": "http://localhost:3005/api/auth/capability/list",
"describe_capability": "http://localhost:3005/api/auth/capability/describe",
"execute": "http://localhost:3005/api/auth/capability/execute",
"request_capability": "http://localhost:3005/api/auth/agent/request-capability",
"status": "http://localhost:3005/api/auth/agent/status",
"reactivate": "http://localhost:3005/api/auth/agent/reactivate",
"revoke": "http://localhost:3005/api/auth/agent/revoke",
"revoke_host": "http://localhost:3005/api/auth/host/revoke",
"rotate_key": "http://localhost:3005/api/auth/agent/rotate-key",
"rotate_host_key": "http://localhost:3005/api/auth/host/rotate-key",
"introspect": "http://localhost:3005/api/auth/agent/introspect"
}
}Better Auth routes (registration, capability execute, device approval) are mounted at /api/auth/* on the API app (port 3005 in local dev).
Capabilities from OpenAPI
Every REST operation with an operationId in the OpenAPI spec becomes an agent capability:
| Capability | Method | Scope required |
|---|---|---|
listProducts | GET | storefront (default, once the agent has a store) |
getProduct | GET | storefront (default, once the agent has a store) |
addCartItem | POST | storefront (requires approval) |
placeOrder | POST | storefront (requires approval) |
adminCreateProduct | POST | admin (requires approval) |
adminRefundOrder | POST | admin (requires approval) |
An agent starts with nothing it can use. resolveAgentAccess refuses an agent with no store: one with no user behind it, or one whose user has several stores and hasn't approved it for one. Once the agent has a store it keeps the public catalog reads (listProducts, getProduct, getProductBySlug, listCategories, getStore, listCountries), the default grants for an agent host. Everything else, including other GET operations and every admin* operation, requires approval on the dashboard's device authorization page. All the capabilities in a request are approved or denied together. Only store owners and admins can approve a request that includes an admin* capability. Approving also binds the agent to the active store. On a Free store, Agent Auth is refused.
When the session ends, after an hour idle (agentSessionTTL: 3600) or 24 hours at most (agentMaxLifetime: 86400), it reactivates with the catalog defaults only, and the agent has to ask again.
Agent registration flow
Drag to pan · Scroll to zoom
Calling the REST API directly
When an agent calls /v1/* with an Authorization: Bearer agent JWT:
- API validates the JWT signature and expiry
- Resolves the store: the one the agent was approved for, or the user's only store. A user with several stores must approve the agent for one
- Checks the agent holds the capability for this exact operation. Holding one
admin*capability doesn't unlock other admin routes - Executes the operation scoped to that store
curl -H "Authorization: Bearer eyJ..." \
"https://api.prood.com/v1/products?perPage=5"OpenAPI proxy execution
When capabilities run through the default execute endpoint, the plugin proxies HTTP to the public API base URL:
Drag to pan · Scroll to zoom
Required environment variables
| Variable | Purpose |
|---|---|
API_PUBLIC_URL | Public API origin used in OpenAPI + proxy. Required |
AGENT_PROXY_API_KEYS_BY_ORG | JSON object mapping organization IDs to org-scoped API keys for proxied capability execution |
TRUST_PROXY | Set true behind a reverse proxy for JWT aud validation |
Database tables
The Agent Auth tables are defined in packages/auth/src/schema.ts and created by pnpm db:migrate:
| Table | Purpose |
|---|---|
agentHost | Registered agent host applications |
agent | Individual agent instances |
agentCapabilityGrant | Approved capabilities per agent |
approvalRequest | Pending user approval requests |
Security considerations
- Agents operate with delegated user authority — they can only access data the approving user can access
- An agent can do nothing until it's approved for a store. After that, everything past the six public catalog capabilities needs explicit approval on the device authorization page
- Agent JWTs are short-lived and scoped to granted capabilities. Access ends after an hour idle, or 24 hours at most
- Tenant isolation applies — agents cannot cross organization boundaries
- Proxied capability execution requires agent metadata with
organizationIdand a matching key inAGENT_PROXY_API_KEYS_BY_ORG
Example: agent shopping assistant
An AI shopping assistant agent might request these capabilities:
| Capability | Purpose | Auto-grant? |
|---|---|---|
listProducts | Search catalog | Yes |
getProduct | View product details | Yes |
createCart | Start a cart | No — requires approval |
addCartItem | Add to cart | No — requires approval |
placeOrder | Complete purchase | No — requires approval |
The merchant sees all five on the device authorization page and approves or denies the request as a whole. The two catalog reads were already granted, so the agent cannot start a cart or place an order without that approval.