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

# Get chat history

> One contact's WhatsApp messages in the authorized channel, newest first, one page at a time: incoming and outgoing, with who sent it, type, text, media link, delivery status and any delivery error. For outgoing messages, sentBy.kind says who sent it and is one of a fixed set: ai_agent (the AI agent), team, admin or owner (a person sending from the inbox, by their role; sentBy.name is that person's name), automation, api (sent through the API), campaign, webhook, system (reminders and follow-ups) or other. We tell API users before this list changes. sentBy.type is the raw internal label (for example mastra, agent, API) and can hold other values, so build on sentBy.kind; sentBy.name is the agent, person, automation or API reference. Incoming messages have sentBy null. The contact is found by phone (country code first) or WhatsApp BSUID, the same way the send endpoints find it.

Authentication: API key via X-API-Key header (or Authorization: Bearer).
Permissions: User API key
Rate limit: api_read — 120 requests/min per API user.



## OpenAPI

````yaml /api-reference/workspace.openapi.json post /api/workspace/v1/whatsapp/message/history
openapi: 3.1.0
info:
  title: Workspace API
  version: 1.0.0
  description: >-
    Manage contacts, labels, custom fields, WhatsApp messaging, and automations
    for your workspace.


    Generate your API key in the Developer Portal (profile menu → Developer) and
    send it in the `X-API-Key` header, or as `Authorization: Bearer <key>`.
    Never put the key in the URL.


    Every endpoint accepts POST with a JSON body, and also accepts GET with the
    same parameters as query-string values. All responses use the envelope `{
    success, data?, message?, error? }`.
servers:
  - url: https://YOUR_DOMAIN
    description: Your deployment, for example https://app.example.com
security: []
tags:
  - name: Channels
    description: Workspace API — Channels
  - name: Contacts
    description: Workspace API — Contacts
  - name: Custom Fields
    description: Workspace API — Custom Fields
  - name: Labels
    description: Workspace API — Labels
  - name: WhatsApp
    description: Workspace API — WhatsApp
  - name: Email
    description: Workspace API — Email
  - name: Automations
    description: Workspace API — Automations
paths:
  /api/workspace/v1/whatsapp/message/history:
    post:
      tags:
        - WhatsApp
      summary: Get chat history
      description: >-
        One contact's WhatsApp messages in the authorized channel, newest first,
        one page at a time: incoming and outgoing, with who sent it, type, text,
        media link, delivery status and any delivery error. For outgoing
        messages, sentBy.kind says who sent it and is one of a fixed set:
        ai_agent (the AI agent), team, admin or owner (a person sending from the
        inbox, by their role; sentBy.name is that person's name), automation,
        api (sent through the API), campaign, webhook, system (reminders and
        follow-ups) or other. We tell API users before this list changes.
        sentBy.type is the raw internal label (for example mastra, agent, API)
        and can hold other values, so build on sentBy.kind; sentBy.name is the
        agent, person, automation or API reference. Incoming messages have
        sentBy null. The contact is found by phone (country code first) or
        WhatsApp BSUID, the same way the send endpoints find it.


        Authentication: API key via X-API-Key header (or Authorization: Bearer).

        Permissions: User API key

        Rate limit: api_read — 120 requests/min per API user.
      parameters:
        - name: channelId
          in: query
          required: false
          description: >-
            Channel id. Auto-selects when omitted; pass it when the workspace
            has more than one channel.
          schema:
            type: string
            example: ch_123
        - name: phone
          in: query
          required: false
          description: >-
            Contact phone with country code (e.g. 919876543210) or WhatsApp
            BSUID. Also accepted as phone_number or to.
          schema:
            type: string
            example: YOUR_PHONE
        - name: limit
          in: query
          required: false
          description: Messages per page, 1 to 50. Default 20.
          schema:
            type: number
            example: 50
        - name: page
          in: query
          required: false
          description: >-
            Page number, 1 = newest messages. Default 1. Also accepted as
            offset.
          schema:
            type: number
            example: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - phone
              properties:
                channelId:
                  type: string
                  description: >-
                    Channel id. Auto-selects when omitted; pass it when the
                    workspace has more than one channel.
                  example: ch_123
                phone:
                  type: string
                  description: >-
                    Contact phone with country code (e.g. 919876543210) or
                    WhatsApp BSUID. Also accepted as phone_number or to.
                  example: YOUR_PHONE
                limit:
                  type: number
                  description: Messages per page, 1 to 50. Default 20.
                  example: 50
                page:
                  type: number
                  description: >-
                    Page number, 1 = newest messages. Default 1. Also accepted
                    as offset.
                  example: 1
            example:
              channelId: ch_123
              phone: '919876543210'
              limit: 20
              page: 1
      responses:
        '200':
          description: 'Success. Envelope: { success:true, data, message? }.'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                properties:
                  success:
                    type: boolean
                    example: true
                  data: {}
                  message:
                    type: string
                  pagination:
                    type: object
                  total:
                    type: number
              example:
                success: true
                data:
                  channelId: ch_123
                  contact:
                    id: ct_1
                    name: Priya
                    phone: '919876543210'
                  page: 1
                  limit: 20
                  nextPage: 2
                  messages:
                    - id: msg_1
                      wamid: wamid.xxx
                      direction: outbound
                      sender: automation
                      sentBy:
                        kind: automation
                        type: automation
                        name: Order flow
                      type: interactive
                      interactiveType: button
                      content: How would you like to pay?
                      mediaUrl: null
                      mediaMimeType: null
                      replyToWamid: null
                      status: read
                      error: null
                      timestamp: '2026-11-26T10:21:03.000Z'
                      deliveredAt: '2026-11-26T10:21:04.000Z'
                      readAt: '2026-11-26T10:22:10.000Z'
                      createdAt: '2026-11-26T10:21:03.000Z'
        '400':
          description: >-
            Missing/invalid parameters. Body has success:false plus error and
            message.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '401':
          description: >-
            Missing or invalid API key (or session expired for session
            endpoints).
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '403':
          description: >-
            Authenticated but not authorized — wrong permissions or cross-tenant
            resource.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '404':
          description: No WhatsApp contact with this phone in this channel.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '429':
          description: >-
            Rate limited. Retry after the Retry-After seconds; see RateLimit-*
            headers.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '500':
          description: >-
            Unexpected server error. Body has success:false plus error and
            message.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
      security:
        - apiKeyHeader: []
        - bearerAuth: []
components:
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: Preferred. API key value directly.
    bearerAuth:
      type: http
      scheme: bearer
      description: Alternative. API key as the bearer token.

````

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