Skip to main content

API Authentication

Aegis uses a dual header authentication system to secure all API requests. Every authenticated endpoint requires both a Bearer token and the agent’s registered email address.
Keep your API token secure! Your token can perform any API action on behalf of your agent, including spending USDC. Never share it publicly or commit it to version control.

How Authentication Works

Unlike traditional API key systems, Aegis enforces zero-trust dual-header validation. Both headers must be present and must match the same agent record in the database:
  1. Authorization: Your Bearer token issued during /v1/connect/complete
  2. X-Aegis-Email: The email address associated with that token
This prevents cross-agent impersonation. Even if a token is intercepted, it cannot be used with a different email address.

Getting Your API Token

Aegis does not use a dashboard for token management. Tokens are issued programmatically through the Connect API:
1

Start onboarding

2

Complete with OTP

Check your email for a 6-character hex code, then submit it:
3

Save the token

The response includes your token field. This is the only time you will see the plaintext token.

Token Format

Aegis API tokens follow a consistent prefix format:
  • Live Token: aegis_live_xxxxxxxxxxxxxxxx
Tokens are valid for 30 days from the date of issue. The tokenExpiresAt field in the connect response tells you the exact expiry timestamp.

Making Authenticated Requests

Include both headers on every request:

Request Headers

Every API request should include these headers:

Idempotency

To prevent duplicate transactions, all financial action endpoints (/transfer, /pay, /bridge, /swap, /yield/deposit, /yield/withdraw, /wealth/limitOrder, /wealth/dca, /wealth/multiYield, /wealth/yield/synthra/withdraw) require an Idempotency-Key header. This must be a valid UUID v4. If you send the same request twice with the same idempotency key, Aegis will return the original response without executing the action again.
Always use a fresh UUID for each new action. Reusing an idempotency key from a previous successful action will return the cached result, not execute a new one.

Nonce System

Aegis tracks an actionNonce for every agent. This counter increments on every successful financial action. You must pass the current nonce value in the X-Aegis-Nonce header for financial mutations. To check your agent’s current nonce:
Response:

Error Handling

Authentication Errors

If authentication fails, you’ll receive an error response:
Authentication error codes:

Token Revocation

To revoke all active tokens for an agent (e.g., in case of a token leak), call the revoke endpoint:
Response:
After revocation, the agent must go through /v1/connect/start and /v1/connect/complete again to receive a new token.

Rate Limiting

Aegis enforces the following rate limits: If you exceed the rate limit, you’ll receive a 429 Too Many Requests response.

Security Best Practices

  • Never hardcode tokens in your application source code
  • Use environment variables or a secrets manager
  • Rotate tokens by calling /v1/connect/revoke and Reonboarding
  • All API requests must use HTTPS, The API will reject plaintext HTTP connections
For multi-agent architectures, provision separate agents (e.g., research-agent@company.com, trading-agent@company.com) rather than sharing a single token. This gives you independent audit trails and spending policies per agent.
If you suspect a token has been leaked, immediately call POST /v1/connect/revoke. This invalidates all active tokens for that agent instantly.

Next Steps

Agent Connections

Deep dive into the onboarding lifecycle

Quickstart

Make your first payment in 5 minutes