API Key
Caller: your backend.
Header:
Authorization: ApiKey rk_...Agent HMAC
Caller: an agent at runtime.
Four headers, HMAC-SHA256 signed.
Session JWT
Caller: browser session in the Relayer dashboard.
Header:
Authorization: Bearer <jwt>1. API Key (backend → Relayer)
This is the primary mode for any server-side integration. Your backend authenticates to Relayer with a long-lived API key tied to your workspace.Key format
Making a request
Pass the key in theAuthorization header with the ApiKey scheme:
Scopes
API keys have scopes that limit what they can call:
If you receive
403 Forbidden — Insufficient permissions, your key’s scope doesn’t cover the endpoint you called.
2. Agent HMAC (agent SDK → Relayer)
Agents authenticate with a per-agent secret that is provisioned at agent-creation time. The Relayer Agent SDK (@relayerfi/agent-sdk) signs every request automatically — you should not handcraft these headers unless you’re writing your own client.
Headers
Every agent request must include:The agent’s UUID (issued by
POST /v1/agents/confirm-policies).The HMAC-SHA256 signature of the canonical request, hex-encoded.
Unix epoch seconds. Must be within ±60 seconds of server time.
Optional. SDK version string (e.g.
@relayerfi/agent-sdk@0.4.1) for telemetry.Signature payload
The signed string is:METHOD— uppercase HTTP method (POST,GET, …)path— request path including/v1prefix (e.g./v1/agents/{id}/x402-pay)timestamp— same value asx-request-timestampsha256(body)— hex-encoded SHA-256 of the JSON body. Usesha256('')for empty bodies.
x-agent-auth.
Reference implementation (for client authors)
Failure modes
3. Session JWT (browser → Relayer dashboard)
The Relayer dashboard (relayer.fi/app) authenticates browser sessions with a JWT in theAuthorization: Bearer header. This mode is for the dashboard product itself — you only need it if you’re building a UI that proxies the user’s session JWT.
Environments
Relayer provides two environments:
Both environments use the same auth scheme and endpoints. Workspace IDs, API keys, and agents are environment-scoped — a sandbox key won’t authenticate against production.
Response envelope
Every response — success or error — uses the same envelope:- Success
- Error
Common auth errors
See Error Reference for the full catalog.
Security best practices
1
Use environment variables
Store keys and agent secrets in
.env files or your platform’s secret manager (Vercel, AWS Secrets Manager, Doppler). Never hardcode them.2
Server-side only for ApiKey
Never include an
ApiKey in client-side JavaScript, mobile apps, or browser requests. For browser-side use, generate a short-lived client key from the dashboard with limited scope.3
Rotate regularly
Rotate API keys every 90 days, or immediately if a leak is suspected. Old keys can be revoked from the dashboard.
4
Pin an IP allowlist
Per-key IP allowlists are configurable from the dashboard. Restrict production keys to your backend’s egress IPs.
5
Rotate agent secrets too
Agent secrets can be rotated with
POST /v1/agents/{id}/rotate — the old secret is revoked instantly. Run this on a schedule for long-running agents.Next Steps
Quickstart
Make your first API call in under 5 minutes.
AI Assistants
Connect Relayer docs to Claude Code, Cursor, ChatGPT, and other AI tools via MCP.