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

# Poll Device Auth Token

> Poll until the user approves; the approved response carries the API key exactly once.



## OpenAPI

````yaml /openapi.json post /api/v1/device/auth/token
openapi: 3.1.0
info:
  title: Trajectory API
  version: 0.1.0
  x-trajectory-api-version: '2026-10-14'
  description: >-
    This contract is API version 2026-10-14. The optional Trajectory-API-Version
    header pins it, and tmp-contract is accepted as an alias. Requests without
    the header get this version. Version 2026-10-07 and the pre-launch legacy
    response formats are retired.
servers:
  - url: https://api.trajectory.ai
security: []
tags:
  - name: agents
    x-group: Agents
  - name: benchmarks
    x-group: Specs (benchmarks)
  - name: diagnostics
    x-group: Diagnostics
  - name: benchmark-ingestion
    x-group: Spec (benchmark) submissions
  - name: eval
    x-group: Evaluations
  - name: training
    x-group: Training
  - name: deployments
    x-group: Deployments
  - name: model-endpoints
    x-group: Model endpoints
  - name: inference
    x-group: Inference
  - name: trajectories
    x-group: Trajectories
  - name: artifacts
    x-group: Artifacts
  - name: telemetry
    x-group: Telemetry
  - name: supported-models
    x-group: Supported models
  - name: organizations
    x-group: Organizations
  - name: secrets
    x-group: Secrets
paths:
  /api/v1/device/auth/token:
    post:
      tags:
        - device-auth
      summary: Poll Device Auth Token
      description: >-
        Poll until the user approves; the approved response carries the API key
        exactly once.
      operationId: pollDeviceAuthToken
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PollDeviceAuthTokenRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/DeviceAuthTokenPending'
                  - $ref: '#/components/schemas/DeviceAuthTokenApproved'
                  - $ref: '#/components/schemas/DeviceAuthTokenDenied'
                  - $ref: '#/components/schemas/DeviceAuthTokenExpired'
                title: Response Polldeviceauthtoken
                discriminator:
                  propertyName: status
                  mapping:
                    pending: '#/components/schemas/DeviceAuthTokenPending'
                    approved: '#/components/schemas/DeviceAuthTokenApproved'
                    denied: '#/components/schemas/DeviceAuthTokenDenied'
                    expired: '#/components/schemas/DeviceAuthTokenExpired'
        default:
          $ref: '#/components/responses/ApiErrorResponse'
components:
  schemas:
    PollDeviceAuthTokenRequest:
      properties:
        device_code:
          type: string
          maxLength: 128
          minLength: 1
          title: Device Code
          description: Code from session start.
      type: object
      required:
        - device_code
      title: PollDeviceAuthTokenRequest
    DeviceAuthTokenPending:
      properties:
        status:
          type: string
          const: pending
          title: Status
          description: The user has not approved the device yet.
        poll_interval_seconds:
          type: integer
          title: Poll Interval Seconds
          description: Minimum seconds before the next poll.
      type: object
      required:
        - status
        - poll_interval_seconds
      title: DeviceAuthTokenPending
    DeviceAuthTokenApproved:
      properties:
        status:
          type: string
          const: approved
          title: Status
          description: The user approved the device.
        api_key:
          type: string
          title: Api Key
          description: >-
            Plaintext API key. Returned exactly once; later polls return
            `expired`.
        api_key_prefix:
          type: string
          title: Api Key Prefix
          description: Non-secret prefix shown to identify the key.
        organization:
          $ref: '#/components/schemas/DeviceAuthOrganization'
          description: Organization the key belongs to.
        user_email:
          type: string
          title: User Email
          description: Email of the user who approved the device.
      type: object
      required:
        - status
        - api_key
        - api_key_prefix
        - organization
        - user_email
      title: DeviceAuthTokenApproved
    DeviceAuthTokenDenied:
      properties:
        status:
          type: string
          const: denied
          title: Status
          description: The user denied the device.
      type: object
      required:
        - status
      title: DeviceAuthTokenDenied
    DeviceAuthTokenExpired:
      properties:
        status:
          type: string
          const: expired
          title: Status
          description: The session expired, was already redeemed, or does not exist.
      type: object
      required:
        - status
      title: DeviceAuthTokenExpired
    DeviceAuthOrganization:
      properties:
        id:
          type: string
          title: Id
          description: Opaque `org_*` identifier.
        key:
          type: string
          title: Key
          description: URL slug prefixing the organization's platform paths.
        name:
          type: string
          title: Name
          description: Display name for the organization.
      type: object
      required:
        - id
        - key
        - name
      title: DeviceAuthOrganization
    ApiErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ApiErrorBody'
      required:
        - error
      title: ApiErrorEnvelope
      type: object
    ApiErrorBody:
      properties:
        type:
          $ref: '#/components/schemas/ErrorType'
        code:
          type: string
          title: Code
        message:
          type: string
          title: Message
        param:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Param
        doc_url:
          type: string
          title: Doc Url
        context:
          additionalProperties: true
          title: Context
          type: object
      required:
        - type
        - code
        - message
        - doc_url
        - context
      title: ApiErrorBody
      type: object
    ErrorType:
      enum:
        - invalid_request_error
        - authentication_error
        - permission_error
        - conflict_error
        - billing_error
        - rate_limit_error
        - dependency_error
        - api_error
      title: ErrorType
      type: string
  responses:
    ApiErrorResponse:
      description: >-
        Common API error. Possible codes: `authentication_required`,
        `permission_denied`, `validation_error`, `rate_limited`,
        `internal_error`, `service_unavailable`.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Trajectory-Should-Retry:
          $ref: '#/components/headers/TrajectoryShouldRetry'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorEnvelope'
  headers:
    RequestId:
      schema:
        type: string
    TrajectoryShouldRetry:
      schema:
        type: boolean
    RetryAfter:
      schema:
        type: string

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.