Skip to content

Send messages

Send document

Send a PDF or another document with a file name and caption over WhatsApp, Instagram or Messenger.

Send a document with POST /v1/messages and type: "document". Fields shared by every type (to, reply_to, typing, delay_ms, the 24 h window) are in Common fields.

Janela do terminal
curl -X POST https://api.messajo.com/v1/messages \
-H "Authorization: Bearer $MESSAJO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"connection_id": "con_123",
"to": "5511999990000",
"type": "document",
"document": {
"link": "https://cdn.example.com/invoice-november.pdf",
"filename": "invoice-november.pdf",
"caption": "Your November invoice"
}
}'

The response is 201 with id (msg_…), status: "queued" and conversation_id. The final state arrives by webhook.

Provide exactly one of link and media_id. Sending both, or neither, returns 400 validation_failed with exactly one of media_id or link is required.

  • link: URL of the document.
  • media_id (med_…): comes from POST /v1/media, a multipart/form-data request with file (and connection_id, except with a connection key mjc_…). Requires the send permission. The type is read from the file bytes, not the extension.
Janela do terminal
curl -X POST https://api.messajo.com/v1/media \
-H "Authorization: Bearer $MESSAJO_API_KEY" \
-F connection_id=con_123 \

The upload returns the media id (med_…), which you use in document.media_id.

  • document.caption: caption of up to 1024 characters.
  • document.filename: name shown to the contact, up to 240 characters. Always send it, with the extension (invoice-november.pdf), so the contact sees a readable name.
  • Upload: up to 100 MiB.

The upload recognises these formats:

Format Extensions
PDF .pdf
Legacy Office .doc, .xls, .ppt
Office .docx, .xlsx, .pptx
Plain text .txt

Office files are identified by their bytes and by the extension in the file name. Other formats return 415 media_type_not_supported.

The body is just link or media_id, with two differences:

  • link must be https.
  • There is no caption or filename. Send the caption as a separate text message.
Channel Max size Formats
Instagram 25 MB application/pdf
Messenger 25 MB application/pdf
Code Status When
validation_failed 400 link and media_id together, or neither
media_too_large 413 File above the channel limit
media_type_not_supported 415 Format the channel does not accept
media_error 422 Meta could not process the file
outside_service_window 422 Free-form message outside the 24 h window