Send messages
Send image
Send an image with an optional caption over WhatsApp, Instagram or Messenger.
Send an image with POST /v1/messages and type: "image". Fields shared by every type (to, reply_to, typing, delay_ms, the 24 h window) are in Common fields.
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": "image", "image": { "link": "https://cdn.exemplo.com/foto.jpg", "caption": "Your order is out for delivery" }}'import { Messajo } from "@messajo/sdk";
const messajo = new Messajo({ apiKey: process.env.MESSAJO_API_KEY! });
const message = await messajo.messages.send({ connection_id: "con_123", to: "5511999990000", type: "image", image: { link: "https://cdn.exemplo.com/foto.jpg", caption: "Your order is out for delivery" },});console.log(message.id, message.status);n8n HTTP Request node settings
- Method:
POST - URL:
https://api.messajo.com/v1/messages - Authentication: Generic Credential Type, then Header Auth. Name:
Authorization; Value:Bearer mj_... - Headers: turn on Send Headers and add
Idempotency-Key(a unique value per item) - Body: turn on Send Body; Body Content Type: JSON; Specify Body: Using JSON
{ "connection_id": "con_123", "to": "5511999990000", "type": "image", "image": { "link": "https://cdn.exemplo.com/foto.jpg", "caption": "Your order is out for delivery" }}Replace mj_... with your API key.
The response is 201 with id (msg_…), status: "queued" and conversation_id. The final state arrives by webhook.
Link or upload
Section titled “Link or upload”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 image.media_id(med_…): comes fromPOST /v1/media, amultipart/form-datarequest withfile(andconnection_id, unless the key is amjc_…connection key). Requires thesendpermission. The type is read from the file bytes, not from the extension.
curl -X POST https://api.messajo.com/v1/media \ -H "Authorization: Bearer $MESSAJO_API_KEY" \ -F connection_id=con_123 \import { readFile } from "node:fs/promises";
const media = await messajo.media.upload({ file: new Blob([await readFile("foto.jpg")]), connection_id: "con_123",});
await messajo.messages.send({ connection_id: "con_123", to: "5511999990000", type: "image", image: { media_id: media.id },});The upload returns the media id (med_…), which you pass as image.media_id.
image.caption: caption up to 1024 characters.- Upload: up to 5 MiB, JPEG or PNG.
Instagram and Messenger
Section titled “Instagram and Messenger”The body is the same, with two differences:
linkmust behttps.- There is no
caption. Sending one returns422 type_not_supported_by_channelpointing atimage.caption. Send the caption as a separate text message.
| Channel | Max size | Formats |
|---|---|---|
| 8 MiB | image/jpeg, image/png, image/gif |
|
| Messenger | 25 MiB | image/jpeg, image/png, image/gif |
Several images (Instagram only)
Section titled “Several images (Instagram only)”type: "images" sends 2 to 10 images in a single message. Each item takes a link or a media_id.
{ "connection_id": "con_123", "to": "17841400000000000", "type": "images", "images": { "items": [ { "link": "https://cdn.exemplo.com/a.jpg" }, { "link": "https://cdn.exemplo.com/b.jpg" } ] }}Errors
Section titled “Errors”| Code | Status | When |
|---|---|---|
validation_failed |
400 | link and media_id together, or neither |
media_too_large |
413 | File above the limit |
media_type_not_supported |
415 | Format the channel does not accept |
media_error |
422 | Meta could not process the media |
type_not_supported_by_channel |
422 | caption on Instagram or Messenger |
outside_service_window |
422 | Free-form message outside the 24 h window |
Details for each code are in the error catalog.