---
title: "Exchange a one-time dashboard connection code for an API key"
method: POST
path: "/v1/agent_auth/exchange_grant"
tags: ["Authentication"]
---

# Exchange a one-time dashboard connection code for an API key

`POST /v1/agent_auth/exchange_grant`

## Request

- Base URL: `https://api.revdoku.com`
- URL: `https://api.revdoku.com/v1/agent_auth/exchange_grant`
- Auth: none required

The dashboard creates the one-time code when a signed-in administrator copies a connection prompt.

## Request body

- object
  - `grant_token` string, required
  - `label` string
  - `account_id` string: Select another granted account for this request.
  - `reason` string, nullable: Optional purpose for this action. AI agents should explain intentional reads and changes when known; omit when unknown. Do not include secrets, file contents, or transcripts.

## Response `201`

Created

- object
  - `success` true, required
  - `data` AgentConnection, required: A new API key for an AI agent or the CLI. Store api_key securely; it is shown only once.
    - `api_key` string, required
    - `account_id` string, required
    - `account_name` string
    - `scope` 'mailbox_read' | 'mailbox_write' | 'mailbox_admin', required
    - `mailbox_access` 'all' | 'selected'
    - `mailbox_ids` string[]
    - `mailbox_permissions` object
    - `account_connection_limits` object
    - `expires_at` string, date-time, nullable
    - `manage_access` object
    - `mailboxes` object[]
    - `guidance` string

## Other responses

- `default`: Request failed. See error.code. Any 429 or 503 response with Retry-After (for example 503 EMAIL_LABELING_PENDING or 503 EMAIL_INDEX_BUILDING): wait that many seconds, then try the read again. 429 EMAIL_SEND_RATE_LIMITED has no Retry-After. Never retry EMAIL_LOOP_DETECTED.

---

[API](https://skmtc.dev/revdoku/apis/revdoku-api.md) · [All operations](https://skmtc.dev/revdoku/apis/revdoku-api/llms.txt) · [OpenAPI document](https://skmtc.dev/revdoku/apis/revdoku-api/revisions/3ff4e2540a8b?raw)
