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

# OAuth 2.0 Device Authorization Request (RFC 8628 §3.1-3.2)

> Starts a device-code flow with PKCE. Returns a `device_code` the client polls
`/v1/oauth/token` with (grant_type=urn:ietf:params:oauth:grant-type:device_code)
and a short `user_code` the user approves at `verification_uri`. No HQ session
is required here - the user authenticates later, on the verification page.



## OpenAPI

````yaml POST /v1/oauth/device_authorization
openapi: 3.1.0
info:
  title: HQ API
  description: >-
    Public HTTP API for HQ. Authenticate with a Personal Access Token
    (`Authorization: Bearer hq_pat_...`) for server-side integrations, or an
    OAuth 2.1 authorization-code + PKCE flow for browser apps acting on a user's
    behalf. Both grant from the same resource:action scope vocabulary; an
    endpoint's required scope is listed under its `security`.
  license:
    name: Apache-2.0
    identifier: Apache-2.0
  version: 1.0.0
servers:
  - url: https://api.hq.zone
    description: HQ API (production)
security: []
tags:
  - name: me
    description: The signed-in user's own account
  - name: conversations
    description: Conversations and their messages
  - name: documents
    description: The content-addressed documents library
  - name: schedules
    description: Scheduled prompts and recurring tasks
  - name: agents
    description: Agents, their skills and integrations
  - name: memory
    description: What the assistant remembers (L5 governance)
  - name: tokens
    description: Personal Access Token management
  - name: billing
    description: Usage and billing
  - name: notifications
    description: In-app notification center
  - name: admin
    description: Workspace administration
  - name: integrations
    description: Workspace integrations (Slack, MCP, skills)
  - name: onboarding
    description: New-workspace onboarding wizard
  - name: auth
    description: Sign-in, sessions, and OAuth
paths:
  /v1/oauth/device_authorization:
    post:
      tags:
        - auth
      summary: OAuth 2.0 Device Authorization Request (RFC 8628 §3.1-3.2)
      description: >-
        Starts a device-code flow with PKCE. Returns a `device_code` the client
        polls

        `/v1/oauth/token` with
        (grant_type=urn:ietf:params:oauth:grant-type:device_code)

        and a short `user_code` the user approves at `verification_uri`. No HQ
        session

        is required here - the user authenticates later, on the verification
        page.
      operationId: oauth_device_authorization
      requestBody:
        description: >-
          Device authorization request. application/json or
          application/x-www-form-urlencoded.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeviceAuthzReq'
        required: true
      responses:
        '200':
          description: device_code + user_code + verification URIs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceAuthzResp'
        '400':
          description: invalid_request / unknown client_id / invalid_scope
        '429':
          description: Too many requests (per-IP rate limit)
components:
  schemas:
    DeviceAuthzReq:
      type: object
      required:
        - client_id
        - code_challenge
      properties:
        client_id:
          type: string
        code_challenge:
          type: string
        code_challenge_method:
          type:
            - string
            - 'null'
        scope:
          type:
            - string
            - 'null'
    DeviceAuthzResp:
      type: object
      required:
        - device_code
        - user_code
        - verification_uri
        - verification_uri_complete
        - expires_in
        - interval
      properties:
        device_code:
          type: string
        expires_in:
          type: integer
          format: int64
        interval:
          type: integer
          format: int64
        user_code:
          type: string
        verification_uri:
          type: string
        verification_uri_complete:
          type: string

````