agentrail init or agentrail agent create and are written to ~/.agentrail/agent.env.
Load credentials from the env file
The generated file looks like this:AGENTRAIL_API_KEY value stays the same.
The bearer token vs the key ID
Construct the client
- TypeScript
- Python
baseUrl is required by the constructor. Passing it explicitly avoids a hidden dependency on local defaults.Auth errors
Auth scopes
Agent keys are scoped. Assign only the scopes your harness needs.auth:admin is for bootstrap and administration only. Do not grant it to normal worker harnesses.Idempotency keys
Mutating calls —submitTask, shipTask, createApiKey, and subscription creation — require an idempotency key. Reusing the same key with the same request body is safe and will return the original response. Reusing a key with a different body returns a 409 Conflict.
Include the operation, task ID, and attempt identifier to keep keys unique:
.png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)