What is an Agent Account?
An Agent Account is a registered client application that can:- Authenticate programmatically using OAuth 2.0 client credentials
- Call MCP tools through the Runlayer proxy
- Act on behalf of users when delegated permissions
- Operate autonomously with its own policies
Token Types
Agent accounts can obtain two types of access tokens depending on their use case:M2M Token (Machine-to-Machine)
Use M2M tokens when your agent account operates autonomously without a specific user context.- Agent account operates independently
- Only agent account-level policies are enforced
- Ideal for background jobs, scheduled tasks, or autonomous AI agents
OBO Token (On-Behalf-Of)
Use OBO tokens when your agent account acts on behalf of a specific user.- Agent account operates in the context of a delegating user
- Intersection of agent account and user policies are enforced
- Requires an active delegation from the user to the agent account
- Ideal for user-facing AI assistants or copilots
Authentication
Agent accounts authenticate using the OAuth 2.0 Client Credentials flow. The token endpoint returns a JWT that you include in theAuthorization header of all API requests.
Getting an M2M Token
Getting an OBO Token
To get an OBO token, you need either:- A user UUID from an active delegation (simplified flow)
- A WorkOS user access token (RFC 8693 compliant)
Calling MCP Tools
Once authenticated, you can call MCP tools through the Runlayer proxy using your access token.Delegations
Delegations allow users to grant agent accounts permission to act on their behalf. When a user creates a delegation to an agent account, the agent account can request OBO tokens for that user.Key Concepts
- Delegator: The user granting permission
- Delegatee: The agent account receiving permission
- Server Sessions: Which MCP servers the agent account can access on behalf of the user
- Expiration: Delegations can have optional expiration times
- Revocation: Users can revoke delegations at any time
Delegation Flow
- User navigates to the agent account in the Runlayer UI
- User creates a delegation, selecting which server sessions to include
- Agent account requests an OBO token using the user’s ID
- Agent account calls MCP tools with the user’s permissions applied
Server Session Configuration
Each delegation includes per-server session configuration that determines how the agent account authenticates to MCP servers on behalf of the user. Two Authentication Modes:| Mode | Description | When to Use |
|---|---|---|
| User’s OAuth Session | Agent account uses the delegating user’s existing OAuth credentials | MCP servers requiring OAuth authentication |
| No Authentication | Agent account accesses server without credentials | MCP servers that don’t require authentication |
- When creating a delegation, you configure each MCP server the agent account can access
- For OAuth-enabled servers, select the user’s existing OAuth session
- For servers without authentication requirements, mark as “No auth required”
- At runtime, Runlayer resolves the appropriate credentials based on this configuration
If a user’s OAuth session expires, the agent account will receive an authentication error until the user re-authorizes the server.
Policies
Both agent accounts and users can have policies that control what actions they can perform. When an agent account uses an OBO token, the effective permissions are the intersection of:- The agent account’s policies
- The user’s policies
- Any server-level policies
Best Practices
Secure your client secret
Secure your client secret
Store your agent account’s client secret securely (e.g., environment variables, secrets manager). Never commit it to version control or expose it in client-side code.
Use OBO tokens when appropriate
Use OBO tokens when appropriate
If your agent account is acting on behalf of a specific user, always use OBO tokens rather than M2M tokens. This ensures proper audit trails and policy enforcement.
Handle token expiration
Handle token expiration
Access tokens are valid for 1 hour. Implement token refresh logic in your application to request new tokens before expiration.
Apply least privilege
Apply least privilege
Configure your agent account’s policies to only allow the minimum permissions required for its function. Avoid granting broad access.
Managing Agent Accounts
Agent accounts are managed through the Admin section of the Runlayer UI:- Navigate to Admin → Agent Accounts
- Create new agent accounts with the Add Agent Account button
- Configure agent account settings, policies, and delegations
- View agent account activity in the audit logs
Only administrators can create and manage agent accounts. Users can view agent accounts and create delegations to agent accounts they have access to.
Credential Rotation
Agent account credentials should be rotated periodically or after security events to maintain security.When to Rotate
- Scheduled rotation: Rotate credentials every 90 days as a best practice
- Security incident: Immediately rotate if credentials may have been exposed
- Personnel changes: Rotate when team members with access leave the organization
- Suspicious activity: Rotate if you detect unusual API usage patterns
How to Rotate
- Navigate to Admin → Agent Accounts
- Select the agent account to rotate
- Click Rotate Credentials
- Confirm the rotation
- Save the new client secret immediately (shown only once)
- Update your application with the new credentials
Impact of Rotation
When you rotate credentials:- Old credentials are immediately invalidated - Existing tokens stop working
- Active sessions are terminated - The agent account must re-authenticate
- Delegations remain intact - No need to recreate delegations
- Policies are unchanged - Access rules continue to apply
Error Handling
When authenticating or making API calls, you may encounter these common errors:Authentication Errors
| Error Code | Error | Cause | Remediation |
|---|---|---|---|
| 400 | unsupported_grant_type | Wrong grant type used | Use client_credentials for agent account tokens |
| 401 | invalid_client | Invalid client ID or secret | Verify credentials are correct and not rotated |
| 401 | invalid_grant | Invalid or expired token | Re-authenticate to get a new token |
| 403 | invalid_grant | User deactivated | Contact admin to reactivate user account |
| 403 | invalid_grant | No valid delegation | Create a delegation in the Runlayer UI |
OBO Token Exchange Errors
| Error Code | Error | Cause | Remediation |
|---|---|---|---|
| 400 | invalid_request | Invalid actor_token format | Use valid user UUID or WorkOS token |
| 403 | invalid_grant | Delegation expired or revoked | Create a new delegation |
| 403 | invalid_grant | Agent account disabled | Contact admin to re-enable agent account |
Proxy Call Errors
| Error Code | Error | Cause | Remediation |
|---|---|---|---|
| 400 | MISSING_SERVER_AUTH_CONFIG | Server not configured in delegation | Add server to delegation with session config |
| 401 | OAuth session not found | User’s OAuth session missing | User needs to authorize the MCP server |
| 401 | OAuth session expired | User’s OAuth session expired | User needs to re-authorize the MCP server |
| 403 | Policy denied | PBAC policy blocked the request | Review agent account and user policies |