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

# Messaging API

> Send, receive, and manage messages across WhatsApp, Instagram, and Web Chat using the Visito Messaging API.

The Messaging API allows you to **send and receive messages** across multiple communication channels such as WhatsApp, Instagram or Visito Web Chat Widget.
Visito gives you a unified API that abstracts the complexity of each channel. Instead of handling four different Meta APIs, you get:

* One **message format**
* One **webhook structure**
* One **authentication model**
* One **place to automate with AI**

<Steps>
  <Step title="Set up your channel">
    Before you can send or receive messages, you must first connect a channel.\
    Start by choosing the channel you want to use — [add a channel](/product-guides/channels).

    The easiest way to get started is **Web Chat**, but you can also connect **WhatsApp** or **Instagram** whenever you're ready.
  </Step>

  <Step title="Set up a webhook">
    Use the `POST` **`/webhooks`**  endpoint to subscribe to **incoming WhatsApp messages**. The channel field should contain the channel ID, which you can retrieve by listing your channels using the GET /channels endpoint.

    ```json theme={null}
    {
      "channel": "68505cb92a11ea971d9df8bf",
      "events": ["messages"],
      "endpoint": "https://api.yourserver.com/webhooks/whatsapp"
    }
    ```

    **References**

    * [List Channels →](/api-docs/api-reference/channels/list-channels)
    * [Create Webhook →](/api-docs/api-reference/webhooks/create-webhook)
  </Step>

  <Step title="Receive incoming messages">
    Once your webhook is active, Visito will send a payload for every incoming message.

    ```json theme={null}
    {
      "channel": {
        "id": "68505cb92a11ea971d9df8bf",
        "type": "whastapp"
      },
      "conversation": {
        "id": "69238d37f3821dae1626709e",
        "fullName": "Sofia Martinez",
        ...Other channel specific fields
      },
      "message": {
        "id": "65e67b5c659c37d3734fa58a",
        "type": "text",
        "text": "Hello! I'd like to check my order status."
      }
    }
    ```
  </Step>

  <Step title="Send Messages">
    Use the `POST` **`/messages`** endpoint to send a WhatsApp new message.

    ```json theme={null}
    {
      "type": "text",
      "to": "69238d37f3821dae1626709e",
      "text": {
        "text": "Hi Sofia, how can I help you today?"
      }
    }
    ```

    **References**

    * [Send Message →](/api-docs/messages/send-message)

    <Info>
      Some channels — such as Instagram and WhatsApp — only allow **free-form messages** within a **24-hour window** after the user's last message.
      \
      If you need to send a message **outside this window**, or you want to **start a new outbound conversation**, WhatsApp requires the use of a **pre-approved template message**. This is the **only available solution** for WhatsApp; free-form messages cannot be sent outside the 24-hour window.
    </Info>
  </Step>
</Steps>
