> ## 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 or reuse a human direct conversation

> Creates the single direct conversation for the authenticated Relay user and a verified target user, or reuses the existing conversation for that normalized pair.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/conversations/direct
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/conversations/direct:
    post:
      tags:
        - Conversations
      summary: Create or reuse a human direct conversation
      description: >
        Creates the single direct conversation for the authenticated Relay user
        and a verified target user, or reuses the existing conversation for that
        normalized pair.
      operationId: createDirectConversation
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - user_id
              properties:
                user_id:
                  type: string
                  pattern: ^usr_
                  description: Verified Relay user to message.
      responses:
        '200':
          description: Existing conversation for this user pair.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectConversationResponse'
        '201':
          description: New conversation for this user pair.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectConversationResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: >-
            The feature is unavailable or the verified target user does not
            exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Idempotency-Key or a valid non-self user_id is missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - userSession: []
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        minLength: 8
        maxLength: 255
      description: Deriving it from the triggering `event_id` makes a retry safe.
  schemas:
    DirectConversationResponse:
      type: object
      additionalProperties: false
      required:
        - conversation
      properties:
        conversation:
          $ref: '#/components/schemas/DirectConversationSnapshot'
    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
    DirectConversationSnapshot:
      type: object
      additionalProperties: false
      required:
        - id
        - kind
        - title
        - avatar_url
        - membership_version
        - participants
        - contact_id
        - counterpart_user
        - created_at
        - last_message_at
        - last_message_preview
        - last_sequence
        - unread
        - messages
      properties:
        id:
          type: string
          pattern: ^cnv_
        kind:
          type: string
          const: direct
        title:
          type:
            - string
            - 'null'
        avatar_url:
          type:
            - string
            - 'null'
          format: uri
        membership_version:
          type: integer
          minimum: 1
        participants:
          type: array
          maxItems: 0
        contact_id:
          type:
            - string
            - 'null'
          pattern: ^agt_
        counterpart_user:
          oneOf:
            - $ref: '#/components/schemas/CounterpartUser'
            - type: 'null'
        created_at:
          type: string
          format: date-time
        last_message_at:
          type:
            - string
            - 'null'
          format: date-time
        last_message_preview:
          type: string
        last_sequence:
          type: integer
          minimum: 0
        unread:
          type: integer
          minimum: 0
        messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
    CounterpartUser:
      type: object
      additionalProperties: false
      required:
        - id
        - display_name
        - avatar_url
      properties:
        id:
          type: string
          pattern: ^usr_
        display_name:
          type: string
        avatar_url:
          type:
            - string
            - 'null'
          format: uri
    Message:
      oneOf:
        - $ref: '#/components/schemas/VisibleMessage'
        - $ref: '#/components/schemas/DeletedMessageTombstone'
    VisibleMessage:
      type: object
      additionalProperties: false
      required:
        - id
        - conversation_id
        - sequence
        - sender
        - parts
        - fallback_text
        - status
        - created_at
      properties:
        id:
          type: string
          example: msg_01JZM3T8AH
        conversation_id:
          type: string
          example: cnv_01JZC7K4RQ
        sequence:
          type: integer
          description: Order inside the conversation. It is unrelated to webhook event IDs.
        sender:
          $ref: '#/components/schemas/Sender'
        parts:
          type: array
          items:
            $ref: '#/components/schemas/Part'
        reply_to:
          $ref: '#/components/schemas/ReplyRef'
        invoked_agents:
          type: array
          uniqueItems: true
          items:
            type: string
          description: Agents explicitly invoked by this human group message.
        suggestions:
          type: array
          maxItems: 8
          description: >
            Agent-attached quick-reply chips. Clients render them only while
            this message is the newest in the conversation.
          items:
            $ref: '#/components/schemas/Suggestion'
        reactions:
          type: array
          description: >-
            Current reactions. History and bootstrap projections include this
            array.
          items:
            $ref: '#/components/schemas/ProjectedReaction'
        fallback_text:
          type: string
          description: Plain-language representation used by notifications and search.
        status:
          type: string
          enum:
            - sent
            - delivered
            - read
            - completed
            - failed
          example: sent
        delivered_at:
          type: string
          format: date-time
        read_at:
          type: string
          format: date-time
        edited_at:
          type: string
          format: date-time
          description: >-
            Time of the latest edit. Omitted when the message has never been
            edited.
        revisions:
          type: array
          maxItems: 5
          description: >
            Prior canonical parts and fallback text, ordered from oldest to
            newest. History and bootstrap projections include an empty array for
            unedited messages.
          items:
            $ref: '#/components/schemas/MessageRevision'
        created_at:
          type: string
          format: date-time
    DeletedMessageTombstone:
      type: object
      additionalProperties: false
      required:
        - id
        - conversation_id
        - sequence
        - sender
        - status
        - created_at
      properties:
        id:
          type: string
          example: msg_01JZM3T8AH
        conversation_id:
          type: string
          example: cnv_01JZC7K4RQ
        sequence:
          type: integer
          minimum: 1
        sender:
          $ref: '#/components/schemas/Sender'
        status:
          type: string
          const: deleted
        created_at:
          type: string
          format: date-time
    Sender:
      type: object
      required:
        - kind
        - id
      properties:
        kind:
          type: string
          enum:
            - user
            - agent
            - system
        id:
          type: string
          example: usr_01JZU1F0BD
    Part:
      oneOf:
        - $ref: '#/components/schemas/TextPart'
        - $ref: '#/components/schemas/MediaPart'
        - $ref: '#/components/schemas/VoiceMemoPart'
        - $ref: '#/components/schemas/LinkPreviewPart'
        - $ref: '#/components/schemas/DataPart'
      discriminator:
        propertyName: type
    ReplyRef:
      type:
        - object
        - 'null'
      properties:
        message_id:
          type: string
          example: msg_01JZM3T8AH
        part_index:
          type: integer
          example: 0
    Suggestion:
      type: object
      additionalProperties: false
      required:
        - text
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 96
          description: Chip label; also the exact text sent when the user taps it.
          example: Everyone
    ProjectedReaction:
      type: object
      additionalProperties: false
      required:
        - part_index
        - emoji
        - actor_kind
        - actor_id
      properties:
        part_index:
          type:
            - integer
            - 'null'
          minimum: 0
        emoji:
          type: string
        actor_kind:
          type: string
          enum:
            - user
            - contact
        actor_id:
          type: string
          pattern: ^(usr|agt)_
    MessageRevision:
      type: object
      additionalProperties: false
      required:
        - parts
        - fallback_text
        - replaced_at
      properties:
        parts:
          type: array
          items:
            $ref: '#/components/schemas/Part'
        fallback_text:
          type: string
        replaced_at:
          type: string
          format: date-time
          description: Time this snapshot stopped being the canonical content.
    TextPart:
      type: object
      additionalProperties: false
      required:
        - part_index
        - type
        - text
      properties:
        part_index:
          type: integer
          minimum: 0
        type:
          type: string
          const: text
        text:
          type: string
    MediaPart:
      type: object
      additionalProperties: false
      required:
        - part_index
        - type
        - url
      properties:
        part_index:
          type: integer
          minimum: 0
        type:
          type: string
          const: media
        url:
          type: string
          format: uri
        attachment_id:
          type: string
          pattern: ^att_
    VoiceMemoPart:
      type: object
      additionalProperties: false
      required:
        - part_index
        - type
        - url
      properties:
        part_index:
          type: integer
          minimum: 0
        type:
          type: string
          const: voice_memo
        url:
          type: string
          format: uri
        attachment_id:
          type: string
          pattern: ^att_
        duration_ms:
          type: integer
          minimum: 0
    LinkPreviewPart:
      type: object
      additionalProperties: false
      required:
        - part_index
        - type
        - url
      properties:
        part_index:
          type: integer
          minimum: 0
        type:
          type: string
          const: link_preview
        url:
          type: string
          format: uri
          maxLength: 2048
    DataPart:
      type: object
      additionalProperties: false
      required:
        - part_index
        - type
        - data
      properties:
        part_index:
          type: integer
          minimum: 0
        type:
          type: string
          const: data
        data:
          anyOf:
            - $ref: '#/components/schemas/GroupInviteComponentData'
            - description: Other integration-defined JSON data.
    GroupInviteComponentData:
      type: object
      additionalProperties: false
      description: >
        Internal consent card committed by POST /v1/groups/invites. Ordinary
        agent message sends cannot supply this component.
      required:
        - type
        - invite_id
        - title
        - expires_at
        - members
      properties:
        type:
          type: string
          const: group_invite
        invite_id:
          type: string
          pattern: ^inv_
        title:
          type: string
          minLength: 1
          maxLength: 100
        reason:
          type: string
          minLength: 1
          maxLength: 200
        expires_at:
          type: string
          format: date-time
        conversation:
          type: object
          additionalProperties: false
          required:
            - id
            - title
          properties:
            id:
              type: string
              pattern: ^cnv_
            title:
              type: string
              minLength: 1
              maxLength: 100
        members:
          type: array
          minItems: 1
          maxItems: 24
          items:
            $ref: '#/components/schemas/GroupInviteMember'
    GroupInviteMember:
      type: object
      additionalProperties: false
      required:
        - user_id
        - display_name
        - avatar_url
        - state
      properties:
        user_id:
          type: string
          pattern: ^usr_
        display_name:
          type: string
        avatar_url:
          type:
            - string
            - 'null'
        state:
          type: string
          enum:
            - invited
            - accepted
            - declined
          description: >
            invited has not answered yet, accepted is in the live conversation,
            and declined answered no.
  responses:
    Unauthorized:
      description: Token is absent or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    agentToken:
      type: http
      scheme: bearer
      description: Agent Token (`rly_live_…`), shown once at agent creation.
    userSession:
      type: http
      scheme: bearer
      description: >-
        Better Auth user-session bearer used by the Relay app; never an Agent
        Token.

````