> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peel.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Exchange a completed CLI browser-login session

> Polls a pending device-auth session and returns an API key after approval in the signed-in browser.



## OpenAPI

````yaml /openapi.json post /public/device/exchange
openapi: 3.1.0
info:
  title: Peel API
  version: '2026-03-21'
  description: >-
    Public Peel API for creating APIs from URLs, inspecting them, calling
    generated endpoints, revising builds, and exporting OpenAPI or MCP
    definitions.
servers:
  - url: https://api.peel.sh
security: []
tags:
  - name: APIs
    description: Create, list, inspect, revise, rebuild, and export APIs.
  - name: Account
    description: Credits and account usage surfaces used by CLI, REST, and MCP clients.
  - name: Device Auth
    description: CLI browser-login device flow helpers.
  - name: Endpoint Execution
    description: Execute generated endpoints through a stable API resource.
  - name: OAuth
    description: OAuth discovery and token flows for hosted MCP clients.
  - name: MCP
    description: Hosted MCP transport and discovery surface.
paths:
  /public/device/exchange:
    post:
      tags:
        - Device Auth
      summary: Exchange a completed CLI browser-login session
      description: >-
        Polls a pending device-auth session and returns an API key after
        approval in the signed-in browser.
      operationId: exchangeDeviceAuth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeviceAuthExchangeRequest'
      responses:
        '200':
          description: Completed device-auth session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceAuthExchangeSuccess'
        '400':
          description: Session is not ready yet or the request is malformed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceAuthExchangePending'
        '404':
          $ref: '#/components/responses/NotFound'
        '410':
          description: Device-auth session expired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceAuthExchangePending'
components:
  schemas:
    DeviceAuthExchangeRequest:
      type: object
      required:
        - session_id
        - user_code
      properties:
        session_id:
          type: string
          format: uuid
        user_code:
          type: string
      additionalProperties: false
    DeviceAuthExchangeSuccess:
      type: object
      required:
        - api_key
      properties:
        api_key:
          type: string
      additionalProperties: false
    DeviceAuthExchangePending:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
      additionalProperties: false
  responses:
    NotFound:
      description: Requested API or endpoint was not found.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            additionalProperties: true

````