Why keypairs
Agent tokens (agent_*) are shared secrets. If one leaks, anyone with the string has the agent’s full authority until someone manually rotates it.
Ed25519 keypairs invert this: the agent holds a private key that never leaves its process; the Sly API holds only the public key. Each session is established by signing a server-issued nonce. Compromised sessions are revocable; compromised keys require a new keypair.
Provisioning
Two paths: At agent creation (recommended — you only see the private key once):Storing the private key
The private key is a base64-encoded 32-byte Ed25519 seed. Handle it like any high-value secret:- Secrets manager (AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager)
- Environment variable injected at boot, never logged
- Hardware-backed storage for high-value agents (YubiKey, AWS KMS, Google Titan)
- Commit to source control
- Log in any form
- Send through any external service for “help decoding”
- Store alongside the corresponding public key on the same system (defeats the air-gap)
Rotation
Self-rotation is the recommended discipline. Rotate:- Every N days (your risk tolerance — monthly is common for Tier 2+, weekly for Tier 3)
- On suspicion of compromise
- On staff changes (if an engineer who had access left)
- On platform-level alerts (
key_rotatedor abnormal-use SSE events)
- Old key marked
rotated - All active sessions under the old key are revoked
- New key pair generated
- New private key returned (once)
Revocation (kill-switch)
For confirmed compromise:- Auth key revoked
- All active
sess_*tokens invalidated - Agent cannot authenticate until a new key is provisioned
Recovery when you lose the private key
If you lost the private key and haven’t rotated yet:- Call
DELETE /v1/agents/:id/auth-keysusing an API key (not the lost agent creds) - Call
POST /v1/agents/:id/auth-keysto provision a fresh pair - Save the new private key carefully this time
- Update your agent deployment with the new key
Best practices
- One private key per agent per environment. Test and live keypairs are separate.
- Generate keys at agent creation, not later. Shrinks the window where the agent exists but can’t yet authenticate via Ed25519.
- Monitor the
key_rotatedwebhook / SSE event. If you see it unexpectedly, treat as incident. - Pre-provision replacement keys for critical agents. Standby keypair you can swap in fast during an incident.
- Rotate on a schedule. Don’t wait for incidents.
Endpoint reference
| Endpoint | Auth | Purpose |
|---|---|---|
POST /v1/agents/:id/auth-keys | API key | Provision new keypair |
GET /v1/agents/:id/auth-keys | API key | List current (public key only) |
POST /v1/agents/:id/auth-keys/rotate | Signed proof | Self-rotate |
DELETE /v1/agents/:id/auth-keys | API key | Revoke all keys |
POST /v1/agents/:id/challenge | Public | Handshake step 1 |
POST /v1/agents/:id/authenticate | Public | Handshake step 2 |
