> ## Documentation Index
> Fetch the complete documentation index at: https://developers.meet-oj.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List messages

> Returns the referral's messages, oldest first, one page at a time. Filter by `author` or `channel`, or use `after` to fetch only what is new since a message you already have.



## OpenAPI

````yaml /api-reference/openapi.yaml get /referrals/{referral_id}/messages
openapi: 3.1.0
info:
  title: O.J. Agent Development Kit (ADK)
  version: 0.5.1
  summary: >-
    Send O.J. a business. Get back named lender matches, what's needed, offers
    and funding status.
  description: >
    The O.J. ADK lets platforms with small-business customers offer financing
    without becoming a lender or a

    broker. You send a business as a **referral**. O.J. matches it to lender
    programs, collects documents,

    submits to lenders and tracks the deal to funding. You earn a share of the
    commission on every funded loan.


    Integrate with **O.J. Embed** (drop-in screens), the **REST API** with
    webhooks, or **MCP** for agents. All

    three read and write the same referral.


    Conventions: OAuth 2.0 client credentials, amounts in cents, prefixed ids,
    cursor pagination, an

    `Idempotency-Key` on every POST, RFC 9457 errors, and Standard Webhooks
    signatures.
  license:
    name: Proprietary — O.J. partner terms
    identifier: LicenseRef-OJ-Partner
  contact:
    name: O.J. Developer Support
    email: developers@meet-oj.com
servers:
  - url: https://sandbox.api.meet-oj.com/partner/v0
    description: Sandbox
  - url: https://api.meet-oj.com/partner/v0
    description: Production
security:
  - oauth2: []
tags:
  - name: Referrals
    description: >-
      A referral is one business you sent to O.J. Every other resource belongs
      to a referral.
  - name: Matches
    description: >-
      The lenders a business matches, named, with estimated limits. `POST
      /match_checks` screens raw numbers without creating a referral. A match is
      not a credit decision; the lender decides.
  - name: Documents
    description: >-
      Documents O.J. still needs, and uploads by API. Most integrations show the
      `next_action` button instead.
  - name: Offers
    description: >-
      Offers returned by lenders. Indicative terms computed before a lender
      replies are marked `binding: false`.
  - name: Sessions
    description: >-
      Create a session to open an O.J. screen: a `client_token` for Embed, or a
      hosted `url` to redirect to.
  - name: Events
    description: >-
      Every change to a referral is an event, delivered by webhook, streamed
      over SSE, and kept for 30 days at `GET /events`.
  - name: Payouts
    description: >-
      Your share of the commission on each funded referral. Match rows to your
      bank statement with `statement_descriptor`. Payout destinations are set
      during onboarding and cannot be changed by API.
  - name: Conversation
    description: >-
      The message thread between O.J., the borrower and your team on a referral,
      across every channel.
  - name: Channels
    description: >-
      Channel connectors let O.J. reach your borrowers through channels you own
      (in-app inbox, SMS, Apple Business Messages, email), in your brand.
  - name: Policy
    description: >-
      Account-level rules: send approval, allowed Embed origins, contact
      channels, default intent and reminder cadence.
  - name: Programs
    description: >-
      For lenders running a program on O.J.: receive submissions, record
      decisions and report funding.
  - name: Webhooks
    description: >-
      Register endpoints that receive signed events. Deliveries follow Standard
      Webhooks.
paths:
  /referrals/{referral_id}/messages:
    get:
      tags:
        - Conversation
      summary: List messages
      description: >-
        Returns the referral's messages, oldest first, one page at a time.
        Filter by `author` or `channel`, or use `after` to fetch only what is
        new since a message you already have.
      operationId: listMessages
      parameters:
        - $ref: '#/components/parameters/ReferralId'
        - name: author
          in: query
          description: Only return messages from this author.
          schema:
            type: string
            enum:
              - oj
              - borrower
              - partner
        - name: channel
          in: query
          description: Only return messages that went through this channel.
          schema:
            $ref: '#/components/schemas/Channel'
        - name: after
          in: query
          description: Only return messages created after the message with this id.
          schema:
            type: string
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/StartingAfter'
      responses:
        '200':
          description: A page of messages
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - has_more
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Message'
                  has_more:
                    type: boolean
components:
  parameters:
    ReferralId:
      name: referral_id
      in: path
      required: true
      schema:
        type: string
        examples:
          - ref_01K5X3K7Q2
    Limit:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 25
    StartingAfter:
      name: starting_after
      in: query
      description: Cursor — the id of the last object on the previous page.
      schema:
        type: string
  schemas:
    Channel:
      type: string
      description: >
        Where a message went through. `embed` is the O.J. Embed component inside
        your product. `hosted_page` is

        an O.J.-hosted page. `sms`, `imessage`, `email` and `voice` are O.J.'s
        own channels, used only when your

        policy allows them. `partner_channel` means O.J. delivered through one
        of your channel connectors, in your

        brand. `api` means the message was posted by your system, your agent, or
        an A2A client.
      enum:
        - embed
        - hosted_page
        - sms
        - imessage
        - email
        - voice
        - partner_channel
        - api
    Message:
      type: object
      description: >
        One turn in a referral's conversation. `author` is who said it: `oj`
        (O.J.'s agent or a reviewer),

        `borrower`, or `partner` (your staff or your system). `channel` is where
        it went through. `parts` is the

        content. `next_action_id` is set when the message is about a specific
        action, for example O.J. asking for

        statements, or the borrower's reply that satisfied the request.


        Messages from the borrower on O.J.'s own channels appear here too, so
        your product always has the whole

        thread. The message carries the medium, not the number or address the
        borrower used.
      required:
        - id
        - referral_id
        - conversation_id
        - author
        - channel
        - parts
        - created_at
      properties:
        id:
          type: string
          examples:
            - msg_01K5X6D2E8
        object:
          type: string
          const: message
        referral_id:
          type: string
        conversation_id:
          type: string
          examples:
            - conv_01K5X3K7Q2
        author:
          type: string
          enum:
            - oj
            - borrower
            - partner
        author_name:
          type: string
          description: >-
            Display name to show: "O.J.", the borrower's first name, or your
            staff member's name.
          examples:
            - O.J.
        channel:
          $ref: '#/components/schemas/Channel'
        direction:
          type: string
          enum:
            - inbound
            - outbound
          description: From O.J.'s point of view. Outbound messages were sent by O.J.
        parts:
          type: array
          items:
            $ref: '#/components/schemas/MessagePart'
        next_action_id:
          type: string
        in_reply_to:
          type: string
          description: The id of the message this answers, when known.
        external_id:
          type: string
          description: Your own id for the message, if you posted it.
        created_at:
          type: string
          format: date-time
        delivered_at:
          type: string
          format: date-time
          description: When the channel confirmed delivery, if it does.
        read_at:
          type: string
          format: date-time
          description: When the recipient opened it, if the channel reports that.
    MessagePart:
      type: object
      description: >
        One piece of a message, in the same shape A2A uses. Exactly one of
        `text`, `file` or `data` is set. A

        `file` part is a document that was uploaded with the message, or a
        reference to one already on the

        referral. A `data` part is structured content: the borrower's answers to
        a question, or, on the first

        message of a new referral, a `ReferralCreate` body.
      required:
        - kind
      properties:
        kind:
          type: string
          enum:
            - text
            - file
            - data
        text:
          type: string
        file:
          type: object
          properties:
            document_id:
              type: string
              description: Set once O.J. has stored the file.
            filename:
              type: string
            media_type:
              type: string
              examples:
                - application/pdf
            url:
              type: string
              format: uri
              description: >-
                Where to fetch the bytes. Requires your API token or a partner
                session.
            type:
              $ref: '#/components/schemas/DocumentType'
        data:
          type: object
          description: >-
            Structured content. When answering a question, the keys are the
            question's field names.
        media_type:
          type: string
    DocumentType:
      type: string
      description: >-
        The kinds of documents O.J. can request or accept. `cim` is a
        confidential information memorandum, the summary document a business
        broker prepares for a sale. `quality_of_earnings` is an accountant's
        review of reported earnings, required by the SBA for acquisitions of $3M
        or more. `funding_account_auth` is the funding account verified through
        Plaid; `voided_check` is the fallback when the bank can't be verified.
      enum:
        - bank_statement
        - processing_statement
        - voided_check
        - funding_account_auth
        - tax_return
        - profit_and_loss
        - balance_sheet
        - ar_aging
        - ap_aging
        - debt_schedule
        - business_license
        - government_id
        - lease
        - ownership_document
        - cim
        - purchase_agreement
        - quality_of_earnings
        - other
  securitySchemes:
    oauth2:
      type: oauth2
      description: >-
        One client per partner per environment. Access tokens expire after 15
        minutes. Scopes are granted per client. Sandbox clients use
        https://sandbox.api.meet-oj.com/oauth/token.
      flows:
        clientCredentials:
          tokenUrl: https://api.meet-oj.com/oauth/token
          scopes:
            referrals:write: Create referrals and upload documents
            referrals:read: Read referrals, matches, document requests, offers, events
            match_checks:write: Run identity-free match checks
            sessions:write: Mint hosted-session links
            webhooks:manage: Register and list webhook endpoints
            payouts:read: >-
              Read payouts (your statement). There is no payouts:write;
              destinations are managed in hosted onboarding by a person.
            messages:read: Read a referral's conversation
            messages:write: >-
              Send messages into a referral's conversation on behalf of the
              partner or the borrower
            channels:manage: Register and remove channel connectors
            policy:manage: Read and change the partner policy
            submissions:read: >-
              For banks running a program. List and read submissions awaiting
              review
            submissions:write: For banks running a program. Record decisions and report funding

````