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

# Create a pairing

> Start device-code pairing from a terminal. No authentication; the source IP is rate-limited. Show the returned `code` (and a QR of `url`) to the user, then long-poll the pairing with `poll_token` until the Relay app claims it. Codes are single-use and expire after `expires_in` seconds. If a JSON body is present it must be an object containing only the documented fields.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/pairings
openapi: 3.1.0
info:
  title: Relay developer API
  version: '0.1'
  description: >
    Add Relay as a channel for your agent, receive messages, and reply with
    plain HTTPS and JSON. Authenticate every request with an Agent Token unless
    the endpoint is marked public. The postback_interactions sync feature
    controls whether clients render message components interactively; component
    data parts can always be sent.
  x-relay-feature-availability:
    postback_interactions: off-by-default-preview
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.relayapp.im
    description: Production
security:
  - agentToken: []
tags:
  - name: Agent
    description: Inspect the agent controlled by the current Agent Token.
  - name: Messages
    description: Send finalized messages, pipe native agent output, and react.
  - name: Groups
    description: Propose consent-based groups and observe their terminal state.
  - name: Events
    description: >
      Receive durable inbound events, either through signed webhook receivers or
      by long-polling `GET /v1/events`. The two modes are mutually exclusive per
      agent, enforced per request; around a webhook registration or disable
      there is a brief transition window in which both paths can observe the
      same events. Delivery is at least once everywhere — always deduplicate by
      `event_id`.
  - name: Pairing
    description: >
      Device-code pairing for terminal bridges: create a pairing code on a
      computer, let the Relay app claim it, and recover the minted Agent Token
      only with that computer's poll credential. The token never travels to the
      phone.
  - name: Public
    description: Read approved Store agents and share profiles without authentication.
paths:
  /v1/pairings:
    post:
      tags:
        - Pairing
      summary: Create a pairing
      description: >
        Start device-code pairing from a terminal. No authentication; the source
        IP is rate-limited. Show the returned `code` (and a QR of `url`) to the
        user, then long-poll the pairing with `poll_token` until the Relay app
        claims it. Codes are single-use and expire after `expires_in` seconds.
        If a JSON body is present it must be an object containing only the
        documented fields.
      operationId: createPairing
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                device_name:
                  type: string
                  minLength: 1
                  maxLength: 80
                  pattern: .*\S.*
                  description: >-
                    Shown on the phone's claim sheet, e.g. the computer's
                    hostname.
                  example: Advait's MacBook Pro
                engine:
                  type: string
                  pattern: ^[a-z0-9][a-z0-9._-]{0,39}$
                  description: Bridge engine identifier shown on the claim sheet.
                  example: claude
      responses:
        '201':
          description: Pairing created; poll it until claimed.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                  - pairing_id
                  - code
                  - url
                  - poll_token
                  - expires_in
                properties:
                  pairing_id:
                    type: string
                    pattern: ^pair_
                    example: pair_01jz9x2m8ktqv4
                  code:
                    type: string
                    pattern: ^[A-Z]+-[A-Z]+-[A-Z]+-[0-9]{4}$
                    description: >-
                      Human-typable single-use code the user enters in the Relay
                      app.
                    example: AMBER-KITE-ROYAL-0472
                  url:
                    type: string
                    format: uri
                    description: Universal link that opens the claim sheet directly.
                    example: https://relayapp.im/pair/AMBER-KITE-ROYAL-0472
                  poll_token:
                    type: string
                    pattern: ^rlyp_
                    description: >
                      Bearer credential for `GET /v1/pairings/{pairing_id}`
                      only. It never authorizes the platform API.
                  expires_in:
                    type: integer
                    const: 600
                    description: Seconds until the code stops being claimable.
                    example: 600
        '422':
          description: Invalid device_name or engine.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many pairings created from this address.
          headers:
            Retry-After:
              description: Whole seconds until another pairing may be created.
              schema:
                type: integer
                minimum: 1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security: []
components:
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: invalid_request
            message:
              type: string
              example: conversation_id is required
  securitySchemes:
    agentToken:
      type: http
      scheme: bearer
      description: Agent Token (`rly_live_…`), shown once at agent creation.

````