Key Recovery

Recover or replace your CueAPI API key without a browser

Key Recovery

If your API key stops working (revoked, rotated, or lost), you can recover without opening a browser.

When You Need Key Recovery

  • Your worker logs show 401 Unauthorized errors
  • You regenerated your key from the dashboard but forgot to update the worker config
  • Your key was rotated by a team member
  • You lost the config file containing your key

Option A: Regenerate Key (Current Key Still Valid)

If your current key is still valid but you want a fresh one:

bash
cueapi-worker regenerate-key --config cueapi-worker.yaml

This calls the API with your current key, generates a new one, and writes it back to the config file. The old key is instantly revoked.

Output:

Key regenerated. Worker config updated. Restart the worker.

Warning

This instantly revokes your old key. Any other workers or scripts using the old key will stop working.


Option B: Login via Email (No Valid Key Needed)

If your key is already invalid, use the email login flow:

bash
cueapi-worker login --email [email protected] --config cueapi-worker.yaml

This sends a magic link to your email. Click the link, and the CLI automatically saves the new key to your config.

Output:

Magic link sent to [email protected]. Click the link in your email.
Waiting for verification....
Authenticated. Key saved to config. Restart the worker.

No browser needed to run the command. Just click the link in your email from any device.


Option C: API Directly (Device Code Flow)

If you prefer raw API calls:

bash
# 1. Create a device code
curl -X POST https://api.cueapi.ai/v1/auth/device-code \
  -H "Content-Type: application/json" \
  -d '{"device_code": "mycode01"}'
 
# 2. Submit your email
curl -X POST https://api.cueapi.ai/v1/auth/device-code/submit-email \
  -H "Content-Type: application/json" \
  -d '{"device_code": "mycode01", "email": "[email protected]"}'
 
# 3. Click the magic link in your email, then poll for the key
curl -X POST https://api.cueapi.ai/v1/auth/device-code/poll \
  -H "Content-Type: application/json" \
  -d '{"device_code": "mycode01"}'

The poll response includes your API key once verified:

json
{
  "status": "approved",
  "api_key": "cue_sk_...",
  "email": "[email protected]"
}

After Recovery

After getting a new key, restart your worker:

bash
cueapi-worker start --config cueapi-worker.yaml

If installed as a system service:

bash
# macOS
launchctl kickstart -k gui/$(id -u)/ai.cueapi.worker
 
# Linux
sudo systemctl restart cueapi-worker
How do I know if my agent ran successfully?
Ctrl+K