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

# Messages भेजना

> Wappfy API के माध्यम से text, media, locations, polls, contacts, reactions, और बहुत कुछ भेजें।

# Messages भेजना

सभी messages एक single endpoint के माध्यम से भेजे जाते हैं। `type` field निर्धारित करता है कि किस प्रकार का message भेजा जाएगा, और शेष fields तदनुसार बदलते हैं।

**Endpoint:**

```
POST https://api.wappfy.io/api/instances/{instanceId}/messages/send
```

**Headers:**

| Header         | Value              |
| -------------- | ------------------ |
| `X-Api-Key`    | आपकी API key       |
| `Content-Type` | `application/json` |

***

## Text Message

एक plain text message भेजें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "text",
      "text": "Hello from Wappfy!"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "text",
        text: "Hello from Wappfy!",
      }),
    }
  );

  const result = await response.json();
  console.log(result.data.message_id);
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "data": {
    "message_id": "BAE5F2C4D3B2A1",
    "status": "sent"
  }
}
```

***

## Image Message

एक optional caption के साथ image भेजें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "image",
      "media_url": "https://example.com/photo.jpg",
      "caption": "Check out this photo!"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "image",
        media_url: "https://example.com/photo.jpg",
        caption: "Check out this photo!",
      }),
    }
  );
  ```
</CodeGroup>

***

## Video Message

एक optional caption के साथ video file भेजें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "video",
      "media_url": "https://example.com/clip.mp4",
      "caption": "Watch this!"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "video",
        media_url: "https://example.com/clip.mp4",
        caption: "Watch this!",
      }),
    }
  );
  ```
</CodeGroup>

***

## Audio Message

एक audio file भेजें। Audio messages WhatsApp में voice messages के रूप में दिखाई देते हैं।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "audio",
      "media_url": "https://example.com/voice-note.ogg"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "audio",
        media_url: "https://example.com/voice-note.ogg",
      }),
    }
  );
  ```
</CodeGroup>

<Note>
  सर्वोत्तम compatibility के लिए, voice messages के लिए Opus codec से encoded `.ogg` files का उपयोग करें।
</Note>

***

## Document Message

एक file को document attachment के रूप में भेजें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "document",
      "media_url": "https://example.com/report.pdf",
      "filename": "Q1-Report.pdf",
      "caption": "Here is the quarterly report"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "document",
        media_url: "https://example.com/report.pdf",
        filename: "Q1-Report.pdf",
        caption: "Here is the quarterly report",
      }),
    }
  );
  ```
</CodeGroup>

***

## Location Message

एक geographic location pin भेजें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "location",
      "latitude": -23.5505,
      "longitude": -46.6333,
      "name": "Sao Paulo",
      "address": "Sao Paulo, SP, Brazil"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "location",
        latitude: -23.5505,
        longitude: -46.6333,
        name: "Sao Paulo",
        address: "Sao Paulo, SP, Brazil",
      }),
    }
  );
  ```
</CodeGroup>

***

## Poll Message

एक interactive poll बनाएं। प्राप्तकर्ता WhatsApp में सीधे options पर vote कर सकते हैं।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "poll",
      "poll_name": "What day works best for the meeting?",
      "poll_options": ["Monday", "Wednesday", "Friday"],
      "poll_allow_multiple": false
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "poll",
        poll_name: "What day works best for the meeting?",
        poll_options: ["Monday", "Wednesday", "Friday"],
        poll_allow_multiple: false,
      }),
    }
  );
  ```
</CodeGroup>

***

## Contact / vCard Message

एक contact card share करें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "contact",
      "contact_name": "Maria Silva",
      "contact_phone": "+5511988887777"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "contact",
        contact_name: "Maria Silva",
        contact_phone: "+5511988887777",
      }),
    }
  );
  ```
</CodeGroup>

***

## Forward Message

किसी मौजूदा message को दूसरी chat में forward करें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511888887777@s.whatsapp.net",
      "type": "forward",
      "forward_message_id": "BAE5F2C4D3B2A1",
      "forward_chat_id": "5511999998888@s.whatsapp.net"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511888887777@s.whatsapp.net",
        type: "forward",
        forward_message_id: "BAE5F2C4D3B2A1",
        forward_chat_id: "5511999998888@s.whatsapp.net",
      }),
    }
  );
  ```
</CodeGroup>

***

## Reaction

किसी message पर emoji से react करें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "reaction",
      "reaction_message_id": "BAE5F2C4D3B2A1",
      "reaction": "\ud83d\udc4d"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "reaction",
        reaction_message_id: "BAE5F2C4D3B2A1",
        reaction: "\ud83d\udc4d",
      }),
    }
  );
  ```
</CodeGroup>

<Tip>
  Reaction हटाने के लिए, `reaction` value के रूप में एक empty string भेजें।
</Tip>

***

## उन्नत सुविधाएं

### किसी Message का Reply

`quoted_message_id` शामिल करके पिछले message को quote करें। यह किसी भी message type के साथ काम करता है।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "text",
      "text": "Yes, I agree with this!",
      "quoted_message_id": "BAE5F2C4D3B2A1"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "text",
        text: "Yes, I agree with this!",
        quoted_message_id: "BAE5F2C4D3B2A1",
      }),
    }
  );
  ```
</CodeGroup>

### भेजे गए Message को Edit करें

`edit_message_id` देकर अपने पहले भेजे गए message को edit करें।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "5511999998888@s.whatsapp.net",
      "type": "text",
      "text": "Updated message content",
      "edit_message_id": "BAE5F2C4D3B2A1"
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "5511999998888@s.whatsapp.net",
        type: "text",
        text: "Updated message content",
        edit_message_id: "BAE5F2C4D3B2A1",
      }),
    }
  );
  ```
</CodeGroup>

<Warning>
  आप केवल अपने भेजे हुए messages को edit कर सकते हैं। WhatsApp द्वारा editing पर एक समय सीमा लगाई गई है (भेजने के बाद लगभग 15 मिनट)।
</Warning>

### Mentions

Group message में specific contacts को mention करें। Mentioned contacts को notification प्राप्त होगा।

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "chat_id": "120363012345678901@g.us",
      "type": "text",
      "text": "Hey @Maria and @Carlos, please review this.",
      "mentions": [
        "5511999998888@s.whatsapp.net",
        "5511888887777@s.whatsapp.net"
      ]
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/messages/send",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        chat_id: "120363012345678901@g.us",
        type: "text",
        text: "Hey @Maria and @Carlos, please review this.",
        mentions: [
          "5511999998888@s.whatsapp.net",
          "5511888887777@s.whatsapp.net",
        ],
      }),
    }
  );
  ```
</CodeGroup>

***

## Chat ID Formats

| Format                   | विवरण          | उदाहरण                         |
| ------------------------ | -------------- | ------------------------------ |
| `{phone}@s.whatsapp.net` | व्यक्तिगत chat | `5511999998888@s.whatsapp.net` |
| `{id}@g.us`              | Group chat     | `120363012345678901@g.us`      |

***

## ब्राज़ीलियन Phone Numbers

<Note>
  Wappfy स्वचालित रूप से ब्राज़ीलियन 9वें अंक की समस्या को handle करता है। यदि कोई message "no LID found" error के साथ विफल होता है, तो system स्वचालित रूप से वैकल्पिक format (9वां अंक जोड़कर या हटाकर) के साथ retry करेगा।

  उदाहरण के लिए, यदि `5511999998888` विफल होता है, तो यह `551199998888` के साथ retry करेगा, और इसके विपरीत। यह पारदर्शी रूप से होता है -- आपको इसे स्वयं handle करने की आवश्यकता नहीं है।
</Note>

***

## Message Type Reference

| Type       | आवश्यक Fields                           | वैकल्पिक Fields                                    |
| ---------- | --------------------------------------- | -------------------------------------------------- |
| `text`     | `text`                                  | `quoted_message_id`, `edit_message_id`, `mentions` |
| `image`    | `media_url`                             | `caption`, `quoted_message_id`                     |
| `video`    | `media_url`                             | `caption`, `quoted_message_id`                     |
| `audio`    | `media_url`                             | `quoted_message_id`                                |
| `document` | `media_url`                             | `filename`, `caption`, `quoted_message_id`         |
| `location` | `latitude`, `longitude`                 | `name`, `address`, `quoted_message_id`             |
| `poll`     | `poll_name`, `poll_options`             | `poll_allow_multiple`                              |
| `contact`  | `contact_name`, `contact_phone`         | `quoted_message_id`                                |
| `forward`  | `forward_message_id`, `forward_chat_id` | --                                                 |
| `reaction` | `reaction_message_id`, `reaction`       | --                                                 |

***

## Error Handling

| Status Code | विवरण                                                                     |
| ----------- | ------------------------------------------------------------------------- |
| `400`       | अमान्य message payload (जैसे, दिए गए type के लिए आवश्यक fields गायब हैं)। |
| `404`       | Instance नहीं मिला या connected नहीं है।                                  |
| `422`       | Message validation विफल (जैसे, अमान्य phone number format)।               |
| `429`       | Rate limit पार हो गई। [Rate Limits](/hi/rate-limits) देखें।               |
| `502`       | WhatsApp provider ने error लौटाया। विवरण के लिए error message जांचें।     |
