Zum Hauptinhalt springen

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:
HeaderWert
X-Api-KeyIhr API-Schluessel
Content-Typeapplication/json

Textnachricht

Senden Sie eine einfache Textnachricht.
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": "[email protected]",
    "type": "text",
    "text": "Hello from Wappfy!"
  }'
Antwort:
{
  "data": {
    "message_id": "BAE5F2C4D3B2A1",
    "status": "sent"
  }
}

Bildnachricht

Senden Sie ein Bild mit optionaler Beschriftung.
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": "[email protected]",
    "type": "image",
    "media_url": "https://example.com/photo.jpg",
    "caption": "Check out this photo!"
  }'

Videonachricht

Senden Sie eine Videodatei mit optionaler Beschriftung.
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": "[email protected]",
    "type": "video",
    "media_url": "https://example.com/clip.mp4",
    "caption": "Watch this!"
  }'

Audionachricht

Senden Sie eine Audiodatei. Audionachrichten werden in WhatsApp als Sprachnachrichten angezeigt.
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": "[email protected]",
    "type": "audio",
    "media_url": "https://example.com/voice-note.ogg"
  }'
Fuer bestmoegliche Kompatibilitaet verwenden Sie .ogg-Dateien mit Opus-Codec fuer Sprachnachrichten.

Dokumentnachricht

Senden Sie eine Datei als Dokumentanhang.
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": "[email protected]",
    "type": "document",
    "media_url": "https://example.com/report.pdf",
    "filename": "Q1-Report.pdf",
    "caption": "Here is the quarterly report"
  }'

Standortnachricht

Senden Sie einen geografischen Standort-Pin.
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": "[email protected]",
    "type": "location",
    "latitude": -23.5505,
    "longitude": -46.6333,
    "name": "Sao Paulo",
    "address": "Sao Paulo, SP, Brazil"
  }'

Umfrage-Nachricht

Erstellen Sie eine interaktive Umfrage. Empfaenger koennen direkt in WhatsApp ueber die Optionen abstimmen.
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": "[email protected]",
    "type": "poll",
    "poll_name": "What day works best for the meeting?",
    "poll_options": ["Monday", "Wednesday", "Friday"],
    "poll_allow_multiple": false
  }'

Kontakt- / vCard-Nachricht

Teilen Sie eine Kontaktkarte.
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": "[email protected]",
    "type": "contact",
    "contact_name": "Maria Silva",
    "contact_phone": "+5511988887777"
  }'

Nachricht weiterleiten

Leiten Sie eine bestehende Nachricht an einen anderen Chat weiter.
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": "[email protected]",
    "type": "forward",
    "forward_message_id": "BAE5F2C4D3B2A1",
    "forward_chat_id": "[email protected]"
  }'

Reaktion

Reagieren Sie auf eine Nachricht mit einem Emoji.
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": "[email protected]",
    "type": "reaction",
    "reaction_message_id": "BAE5F2C4D3B2A1",
    "reaction": "\ud83d\udc4d"
  }'
Um eine Reaktion zu entfernen, senden Sie einen leeren String als reaction-Wert.

Erweiterte Funktionen

Auf eine Nachricht antworten

Zitieren Sie eine vorherige Nachricht, indem Sie quoted_message_id angeben. Dies funktioniert mit jedem Nachrichtentyp.
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": "[email protected]",
    "type": "text",
    "text": "Yes, I agree with this!",
    "quoted_message_id": "BAE5F2C4D3B2A1"
  }'

Gesendete Nachricht bearbeiten

Bearbeiten Sie eine zuvor gesendete Nachricht, indem Sie edit_message_id angeben.
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": "[email protected]",
    "type": "text",
    "text": "Updated message content",
    "edit_message_id": "BAE5F2C4D3B2A1"
  }'
Sie koennen nur Nachrichten bearbeiten, die Sie selbst gesendet haben. Die Bearbeitung unterliegt einer von WhatsApp auferlegten Zeitbeschraenkung (etwa 15 Minuten nach dem Senden).

Erwahnungen

Erwaehnen Sie bestimmte Kontakte in einer Gruppennachricht. Die erwaehnten Kontakte erhalten eine Benachrichtigung.
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": "[email protected]",
    "type": "text",
    "text": "Hey @Maria and @Carlos, please review this.",
    "mentions": [
      "[email protected]",
      "[email protected]"
    ]
  }'

Chat-ID-Formate

FormatBeschreibungBeispiel
{phone}@s.whatsapp.netEinzelchat[email protected]
{id}@g.usGruppenchat[email protected]

Brasilianische Telefonnummern

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.

Nachrichtentyp-Referenz

TypPflichtfelderOptionale Felder
texttextquoted_message_id, edit_message_id, mentions
imagemedia_urlcaption, quoted_message_id
videomedia_urlcaption, quoted_message_id
audiomedia_urlquoted_message_id
documentmedia_urlfilename, caption, quoted_message_id
locationlatitude, longitudename, address, quoted_message_id
pollpoll_name, poll_optionspoll_allow_multiple
contactcontact_name, contact_phonequoted_message_id
forwardforward_message_id, forward_chat_id
reactionreaction_message_id, reaction

Fehlerbehandlung

StatuscodeBeschreibung
400Ungueltiger Nachrichteninhalt (z.B. fehlende Pflichtfelder fuer den angegebenen Typ).
404Instanz nicht gefunden oder nicht verbunden.
422Nachrichtenvalidierung fehlgeschlagen (z.B. ungueltiges Telefonnummernformat).
429Ratenlimit ueberschritten. Siehe Ratenlimits.
502WhatsApp-Anbieter hat einen Fehler zurueckgegeben. Pruefen Sie die Fehlermeldung fuer Details.