Skip to main content

Sending Messages

All messages are sent through a single endpoint. The type field determines what kind of message is sent, and the remaining fields change accordingly. Endpoint:
POST https://api.wappfy.io/api/instances/{instanceId}/messages/send
Headers:
HeaderValue
X-Api-KeyYour API key
Content-Typeapplication/json

Text Message

Send a plain text message.
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!"
  }'
Response:
{
  "data": {
    "message_id": "BAE5F2C4D3B2A1",
    "status": "sent"
  }
}

Image Message

Send an image with an optional caption.
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!"
  }'

Video Message

Send a video file with an optional caption.
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!"
  }'

Audio Message

Send an audio file. Audio messages appear as voice messages in WhatsApp.
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"
  }'
For the best compatibility, use .ogg files encoded with the Opus codec for voice messages.

Document Message

Send a file as a document attachment.
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"
  }'

Location Message

Send a geographic location 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": "5511999998888@s.whatsapp.net",
    "type": "location",
    "latitude": -23.5505,
    "longitude": -46.6333,
    "name": "Sao Paulo",
    "address": "Sao Paulo, SP, Brazil"
  }'

Poll Message

Create an interactive poll. Recipients can vote on options directly in WhatsApp.
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
  }'

Contact / vCard Message

Share a contact card.
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"
  }'

Forward Message

Forward an existing message to another chat.
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"
  }'

Reaction

React to a message with an 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": "5511999998888@s.whatsapp.net",
    "type": "reaction",
    "reaction_message_id": "BAE5F2C4D3B2A1",
    "reaction": "\ud83d\udc4d"
  }'
To remove a reaction, send an empty string as the reaction value.

Advanced Features

Reply to a Message

Quote a previous message by including quoted_message_id. This works with any message type.
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"
  }'

Edit a Sent Message

Edit a message you previously sent by providing edit_message_id.
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"
  }'
You can only edit messages that you sent. Editing has a time window limitation imposed by WhatsApp (approximately 15 minutes after sending).

Mentions

Mention specific contacts in a group message. The mentioned contacts will receive a notification.
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"
    ]
  }'

Chat ID Formats

FormatDescriptionExample
{phone}@s.whatsapp.netIndividual chat5511999998888@s.whatsapp.net
{id}@g.usGroup chat120363012345678901@g.us

Brazilian Phone Numbers

Wappfy automatically handles the Brazilian 9th digit issue. If a message fails with a “no LID found” error, the system will automatically retry with the alternate format (adding or removing the 9th digit).For example, if 5511999998888 fails, it will retry with 551199998888, and vice versa. This happens transparently — you do not need to handle it yourself.

Message Type Reference

TypeRequired FieldsOptional Fields
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

Error Handling

Status CodeDescription
400Invalid message payload (e.g., missing required fields for the given type).
404Instance not found or not connected.
422Message validation failed (e.g., invalid phone number format).
429Rate limit exceeded. See Rate Limits.
502WhatsApp provider returned an error. Check the error message for details.