agentrail agent create, the CLI generates a scoped API key and writes it — along with your base URL — to ~/.agentrail/agent.env. You load that file before starting your coding agent, and it handles authentication automatically.
Where your credentials live
After runningagentrail init and agentrail agent create, your credentials are stored in ~/.agentrail/agent.env. The file looks like this:
AGENTRAIL_BASE_URL is the address of your local AgentRail API. AGENTRAIL_API_KEY is the bearer token your agent uses to authenticate.
Load credentials before starting an agent
Source the env file in the terminal where you launch your coding agent:agentrail server start loads these files automatically. Manual loading is only needed when you launch an agent outside the server-owned supervisor.
Pass the token in HTTP requests
When calling the AgentRail API directly, pass the token in theAuthorization header:
API key scopes
Each agent key is scoped to only the operations it needs. When you create an agent, the wizard selects appropriate scopes. If you need to change permissions later, useagentrail agent update:
Auth errors
403 insufficient_scope
403 insufficient_scope
Your token is valid but lacks the scope required for the route you called. Create a new key that includes the required scope, or update the agent’s permissions with:Each route in the API reference lists the minimum required scope.
.png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)