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

# Visualizar Mensagens of the Channel

> Visualizar prévia das messages of um channel antes of segui-lo

## Description

This endpoint allows you to preview messages of um channel without needing to follow it. It is useful to see the content of the channel before deciding whether to follow it.

## URL Parameters

<ParamField path="session" type="string" required>
  WhatsApp unique authenticated session ID
</ParamField>

<ParamField path="id" type="string" required>
  ID único of the channel que deis visualizar as messages
</ParamField>

## Parâmetros of Query

<ParamField query="invite" type="string" required>
  Code of invite of the channel
</ParamField>

<ParamField query="limit" type="number" default="10">
  Número maximum of messages a retornar (default: 10)
</ParamField>

## Response

<ResponseField name="messages" type="array">
  Array contendo as messages of the channel

  <Expandable title="Properties of the message">
    <ResponseField name="id" type="string">
      ID único of the message
    </ResponseField>

    <ResponseField name="content" type="string">
      Content of the message
    </ResponseField>

    <ResponseField name="timestamp" type="number">
      Timestamp of the message
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "messages": [
      {
        "id": "msg_123",
        "content": "Bem-vindo ao nosso channel!",
        "timestamp": 1672531200
      },
      {
        "id": "msg_124",
        "content": "Confira as novidades desta semana",
        "timestamp": 1672617600
      }
    ]
  }
  ```
</ResponseExample>

## Status Codes

* `200` - Prévia obtained successfully
* `400` - Invalid parameters or faltandthe code of invite
* `401` - Unauthorized
* `404` - Channel not found
* `500` - Internal server error

## Usage Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.wappfy.com.br/api/my-session/channels/123456789@newsletter/messages/preview?invite=ABC123&limit=10"
  ```

  ```javascript JavaScript theme={null}
  const session = 'my-session';
  const channelId = '123456789@newsletter';
  const invite = 'ABC123';
  const limit = 10;
  const response = await fetch(
    `https://api.wappfy.com.br/api/${session}/channels/${channelId}/messages/preview?invite=${invite}&limit=${limit}`
  );
  const data = await response.json();
  console.log(data.messages);
  ```

  ```python Python theme={null}
  import requests

  session = 'my-session'
  channel_id = '123456789@newsletter'
  invite = 'ABC123'
  limit = 10
  response = requests.get(
    f'https://api.wappfy.com.br/api/{session}/channels/{channel_id}/messages/preview',
    params={'invite': invite, 'limit': limit}
  )
  data = response.json()
  print(data['messages'])
  ```
</CodeGroup>


## OpenAPI

````yaml viewer-en.json get /api/{session}/channels/{id}/messages/preview
openapi: 3.1.0
info:
  title: Wappfy - WhatsApp HTTP API
  version: '2.0'
  contact: {}
servers:
  - url: https://{host}
    description: Customizable Server
    variables:
      host:
        default: api.wappfy.com.br
        description: Server URL (e.g., api.wappfy.com.br or your-server.com)
security:
  - api_key: []
tags:
  - name: 🖥️ Sessions
    description: Control WhatsApp sessions (accounts)
  - name: 🔑 Auth
    description: Authentication
  - name: 🆔 Profile
    description: Your profile information
  - name: 🖼️ Screenshot
    description: Get WhatsApp screenshot and display QR code
  - name: 📤 Chatting
    description: Conversation methods
  - name: 📢 Channels
    description: Channels (newsletters) methods
  - name: 🟢 Status
    description: Status (aka stories) methods
  - name: 💬 Chats
    description: Conversations methods
  - name: 👤 Contacts
    description: |-
      Contacts methods.<br>
                      Use phone number (without +) or phone number and `@c.us` at the end as `contactId`.<br>
                      E.g: `12312312310` OR `12312312310@c.us`<br>
  - name: 👥 Groups
    description: Groups methods.<br>
  - name: ✅ Presence
    description: Presence information
  - name: 📅 Events
    description: Event Message
  - name: 🏷️ Labels
    description: Labels - available only for WhatsApp Business accounts
  - name: 🔍 Observability
    description: Other methods
  - name: 🗄️ Storage
    description: Storage methods
externalDocs:
  description: Wappfy - WhatsApp API
  url: https://docs.wappfy.com.br/
paths:
  /api/{session}/channels/{id}/messages/preview:
    get:
      tags:
        - 📢 Channels
      summary: Preview channel messages
      description: >-
        You can use either invite code (https://www.whatsapp.com/channel/123) or
        (123) OR Channel ID (123@newsletter). The {session} parameter must be
        the session.
      operationId: ChannelsController_previewChannelMessages
      parameters:
        - name: session
          required: true
          in: path
          description: Session name (instanceName)
          example: my-session
          schema:
            type: string
        - name: id
          required: true
          in: path
          description: Channel ID or invite code
          schema:
            default: 0029Va4K0PZ5a245NkngBA2M
        - name: downloadMedia
          required: true
          in: query
          schema:
            type: boolean
            default: false
        - name: limit
          required: true
          in: query
          schema:
            default: 10
            type: number
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChannelMessage'
      security:
        - api_key: []
components:
  schemas:
    ChannelMessage:
      type: object
      properties:
        reactions:
          type: object
          example:
            👍: 10
            ❤️: 5
          additionalProperties:
            type: number
        message:
          $ref: '#/components/schemas/WAMessage'
        viewCount:
          type: number
      required:
        - reactions
        - message
        - viewCount
    WAMessage:
      type: object
      properties:
        id:
          type: string
          description: Message ID
          example: false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA
        timestamp:
          type: number
          description: Unix timestamp of when the message was created
          example: 1666943582
        from:
          type: string
          description: Chat ID to which this message was sent
          example: 5511999999999@c.us
        fromMe:
          type: boolean
          description: Indicates if the message was sent by the current user
        source:
          enum:
            - api
            - app
          type: string
          description: >-
            The device that sent the message - either API or APP. Available in
            events (webhooks/websockets) only and only "fromMe: true" messages.
          example: api
        to:
          type: string
          description: >-
            * ID for who this message is for.

            * If the message is sent by the current user, it will be the Chat to
            which the message is being sent.

            * If the message is sent by another user, it will be the ID for the
            current user.
          example: 5511999999999@c.us
        participant:
          type: string
          description: For groups - participant who sent the message
        body:
          type: string
          description: Message content
        hasMedia:
          type: boolean
          description: Indicates if the message has media available for download
        media:
          description: Message media object, if any and downloaded
          allOf:
            - $ref: '#/components/schemas/WAMedia'
        ack:
          enum:
            - -1
            - 0
            - 1
            - 2
            - 3
            - 4
          type: number
          description: Message acknowledgement (ACK) status
        ackName:
          type: string
          description: Message acknowledgement status name
        author:
          type: string
          description: >-
            If the message was sent to a group, this field will contain the user
            who sent the message
        location:
          description: Location information contained in the message
          allOf:
            - $ref: '#/components/schemas/WALocation'
        vCards:
          description: List of vCards contained in the message
          type: array
          items:
            type: string
        _data:
          type: object
          description: >-
            Message in raw WhatsApp format. May change at any time, use with
            caution!
        replyTo:
          $ref: '#/components/schemas/ReplyToMessage'
      required:
        - id
        - timestamp
        - from
        - fromMe
        - source
        - to
        - participant
        - body
        - hasMedia
        - mediaUrl
        - ack
        - ackName
    WAMedia:
      type: object
      properties:
        url:
          type: string
          description: Media URL in the message, if any
          example: >-
            http://localhost:3000/api/files/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga
        mimetype:
          type: string
          description: Media MIME type in the message
          example: audio/jpeg
        filename:
          type: string
          description: Original media file name
          example: example.pdf
        s3:
          description: Media S3 attributes if you are using S3 storage
          allOf:
            - $ref: '#/components/schemas/S3MediaData'
        error:
          type: object
          description: Error message when downloading media
          example: null
    WALocation:
      type: object
      properties:
        description:
          type: string
        latitude:
          type: string
        longitude:
          type: string
      required:
        - latitude
        - longitude
    ReplyToMessage:
      type: object
      properties:
        id:
          type: string
          description: Message ID
          example: AAAAAAAAAAAAAAAAAAAA
        participant:
          type: string
          example: 5511999999999@c.us
        body:
          type: string
          example: Hello!
        _data:
          type: object
          description: Raw data from reply's message
      required:
        - id
    S3MediaData:
      type: object
      properties:
        Bucket:
          type: string
          description: Nome do bucket S3
          example: my-bucket
        Key:
          type: string
          description: S3 bucket object key
          example: default/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga
      required:
        - Bucket
        - Key
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: apikey
      description: Your Wappfy API key (get it at dash.wappfy.com.br)

````