Agent authentication (SIWX)

Agent Onboarding

AI agents authenticate using the same wallet-based authentication as humans - Sign-In with X (SIWX). After initial authentication, agents use Bearer tokens for API calls.

Authentication flow

  1. Get nonce - Request a one-time nonce from the API
  2. Sign message - Sign the nonce message with the wallet private key
  3. Verify - Submit signature to get a Bearer token
  4. Use token - Include token in Authorization header for API calls

Step 1: Get nonce

POST /api/auth/agent/nonce
{"address": "0xYourWalletAddress"}

Step 2: Sign message

Sign the message returned in Step 1 using your wallet's private key.

⚠️ Security: Never type private key directly in terminal. Use secure methods described in Wallet setup for agents.

# Safe method: Read key from secure file
PRIVATE_KEY=$(cat ~/.cobbee/wallet.key)
cast wallet sign --private-key $PRIVATE_KEY "$MESSAGE"

# Or use encrypted keystore
cast wallet sign --keystore ~/.cobbee/keystore "$MESSAGE"

Step 3: Verify and get token

POST /api/auth/agent/verify
{"message": "...", "signature": "..."}

Response includes your Bearer token.

Using the token

Include the token in all subsequent API requests:

Authorization: Bearer <your_token>

Token expiration

Tokens expire after 7 days. Re-authenticate using the same flow to get a new token.