Exchange agent login Polls the agent login request using deviceCode and, once approved, issues a reusable workspace-scoped API key. The secret is returned once at apiKey.key, should be saved immediately, and should be reused for future HTTP API calls instead of re-running login.
POST /api/v1/experimental/agent/auth/exchange
Test Polls the agent login request using deviceCode and, once approved, issues a reusable workspace-scoped API key. The secret is returned once at apiKey.key, should be saved immediately, and should be reused for future HTTP API calls instead of re-running login.
TypeScript Definitions
Use the request body type in TypeScript.
Copy
cURL
JavaScript
Go
Python
Java
C#curl -X POST "https://loading/api/v1/experimental/agent/auth/exchange" \ -H "Content-Type: application/json" \ -d '{ "deviceCode": "0blbPwylJ_5mAZGb29sz8Y-V3CGSHfZ0bj6c5zWd0M8" }'
200 400 500
{
"status" : "approved" ,
"workspace" : {
"handle" : "acme-growth-team" ,
"name" : "Acme Growth Team" ,
"createdAt" : "2026-03-05T18:00:00.000Z" ,
"updatedAt" : "2026-03-05T18:00:00.000Z" ,
"deletedAt" : null
},
"apiKey" : {
"key" : "andi_live_3x7X7uPKnd2m4WQNkfC2fZb3TW4nYJd1" ,
"apiKey" : {
"id" : "key_6ZW0qF8cXTWETrdFM3A7yv" ,
"name" : "Claude production key" ,
"start" : "andi_l" ,
"prefix" : "andi_" ,
"enabled" : true ,
"role" : "admin" ,
"permissions" : {
"sessionEvents" : [
"read"
]
},
"createdAt" : "2026-03-07T18:10:00.000Z" ,
"updatedAt" : "2026-03-07T18:10:00.000Z" ,
"expiresAt" : null ,
"lastRequest" : null
}
},
"usage" : {
"saveHint" : "Store this API key in a secrets manager or environment variable before continuing. Reuse the same key for future calls instead of re-running login. The secret is only returned once." ,
"recommendedEnvVar" : "ANDI_API_KEY" ,
"authorizationHeader" : "Authorization: Bearer <api-key>" ,
"secretField" : "apiKey.key" ,
"lifecycle" : "This key is persistent until revoked or until its configured expiration, if any."
}
} {
"issues" : [
{
"_tag" : "Pointer" ,
"path" : [
"string"
],
"message" : "string"
}
],
"message" : "string" ,
"_tag" : "HttpApiDecodeError"
} {
"code" : "internal_error" ,
"message" : "An unexpected server error occurred."
}