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.
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]"
]
}'
| Format | Beschreibung | Beispiel |
|---|
{phone}@s.whatsapp.net | Einzelchat | [email protected] |
{id}@g.us | Gruppenchat | [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
| 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. |
502 | WhatsApp-Anbieter hat einen Fehler zurueckgegeben. Pruefen Sie die Fehlermeldung fuer Details. |