> ## 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.

# Nachrichten senden

> Senden Sie Text, Medien, Standorte, Umfragen, Kontakte, Reaktionen und mehr ueber die Wappfy API.

# Nachrichten senden

Alle Nachrichten werden ueber einen einzigen Endpunkt gesendet. Das Feld `type` bestimmt, welche Art von Nachricht gesendet wird, und die uebrigen Felder aendern sich entsprechend.

**Endpunkt:**

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

**Header:**

| Header         | Wert               |
| -------------- | ------------------ |
| `X-Api-Key`    | Ihr API-Schluessel |
| `Content-Type` | `application/json` |

***

## Textnachricht

Senden Sie eine einfache Textnachricht.

<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>

**Antwort:**

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

***

## Bildnachricht

Senden Sie ein Bild mit optionaler Beschriftung.

<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>

***

## Videonachricht

Senden Sie eine Videodatei mit optionaler Beschriftung.

<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>

***

## Audionachricht

Senden Sie eine Audiodatei. Audionachrichten werden in WhatsApp als Sprachnachrichten angezeigt.

<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>
  Fuer bestmoegliche Kompatibilitaet verwenden Sie `.ogg`-Dateien mit Opus-Codec fuer Sprachnachrichten.
</Note>

***

## Dokumentnachricht

Senden Sie eine Datei als Dokumentanhang.

<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>

***

## Standortnachricht

Senden Sie einen geografischen Standort-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>

***

## Umfrage-Nachricht

Erstellen Sie eine interaktive Umfrage. Empfaenger koennen direkt in WhatsApp ueber die Optionen abstimmen.

<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>

***

## Kontakt- / vCard-Nachricht

Teilen Sie eine Kontaktkarte.

<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>

***

## Nachricht weiterleiten

Leiten Sie eine bestehende Nachricht an einen anderen Chat weiter.

<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>

***

## Reaktion

Reagieren Sie auf eine Nachricht mit einem Emoji.

<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>
  Um eine Reaktion zu entfernen, senden Sie einen leeren String als `reaction`-Wert.
</Tip>

***

## Erweiterte Funktionen

### Auf eine Nachricht antworten

Zitieren Sie eine vorherige Nachricht, indem Sie `quoted_message_id` angeben. Dies funktioniert mit jedem Nachrichtentyp.

<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>

### Gesendete Nachricht bearbeiten

Bearbeiten Sie eine zuvor gesendete Nachricht, indem Sie `edit_message_id` angeben.

<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>
  Sie koennen nur Nachrichten bearbeiten, die Sie selbst gesendet haben. Die Bearbeitung unterliegt einer von WhatsApp auferlegten Zeitbeschraenkung (etwa 15 Minuten nach dem Senden).
</Warning>

### Erwahnungen

Erwaehnen Sie bestimmte Kontakte in einer Gruppennachricht. Die erwaehnten Kontakte erhalten eine Benachrichtigung.

<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-Formate

| Format                   | Beschreibung | Beispiel                       |
| ------------------------ | ------------ | ------------------------------ |
| `{phone}@s.whatsapp.net` | Einzelchat   | `5511999998888@s.whatsapp.net` |
| `{id}@g.us`              | Gruppenchat  | `120363012345678901@g.us`      |

***

## Brasilianische Telefonnummern

<Note>
  Wappfy behandelt das Problem der brasilianischen 9. Stelle automatisch. Wenn eine Nachricht mit dem Fehler "no LID found" fehlschlaegt, versucht das System automatisch erneut mit dem alternativen Format (Hinzufuegen oder Entfernen der 9. Stelle).

  Wenn beispielsweise `5511999998888` fehlschlaegt, wird mit `551199998888` erneut versucht und umgekehrt. Dies geschieht transparent -- Sie muessen sich nicht selbst darum kuemmern.
</Note>

***

## Nachrichtentyp-Referenz

| Typ        | Pflichtfelder                           | Optionale Felder                                   |
| ---------- | --------------------------------------- | -------------------------------------------------- |
| `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`       | --                                                 |

***

## Fehlerbehandlung

| Statuscode | Beschreibung                                                                                   |
| ---------- | ---------------------------------------------------------------------------------------------- |
| `400`      | Ungueltiger Nachrichteninhalt (z.B. fehlende Pflichtfelder fuer den angegebenen Typ).          |
| `404`      | Instanz nicht gefunden oder nicht verbunden.                                                   |
| `422`      | Nachrichtenvalidierung fehlgeschlagen (z.B. ungueltiges Telefonnummernformat).                 |
| `429`      | Ratenlimit ueberschritten. Siehe [Ratenlimits](/de/rate-limits).                               |
| `502`      | WhatsApp-Anbieter hat einen Fehler zurueckgegeben. Pruefen Sie die Fehlermeldung fuer Details. |
