Images and files

Works on
  • iMessage
  • WhatsApp

Send photos, video, audio and documents by link, with optional text

Put a public https link to each file in a media message. Mapier or the channel fetches the file, so keep the link working until the result arrives.

You wantSend
One photo or filemedia with one link
Several photos as one messagemultipart with several photo parts, on iMessage
Photos with textmultipart with photo and text parts, on iMessage
A contact cardcontact, or a .vcf file in media
A stickersticker
ChannelWords with a fileFiles in one message
iMessageA text part in a multipartUp to 10 photos, in a multipart
WhatsAppA caption, up to 1,024 charactersOne

Send a photo with text

This reply goes into a conversation the person started. To write to someone new, check who can write first.

curl -X POST https://api.mapier.ai/v1/commands/message.send \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-4821-photo" \
  -H "x-mapier-version: 2026-12-01" \
  -d '{
    "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" },
    "payload": {
      "kind": "multipart",
      "parts": [
        { "kind": "media", "url": "https://example.com/orders/4821/table.jpg" },
        { "kind": "text", "text": "Yes, by the window." }
      ]
    }
  }'
202 Accepted
{
  "commandId": "0192b3e1-…",
  "status": "queued",
  "repeated": false,
  "lineId": "0192a7b0-…",
  "lineSelection": "reused_active_chat",
  "channel": "imessage"
}

Keep commandId. Its result on the stream says whether the file went out.

On WhatsApp, the same photo with text is one media message with a caption:

{
  "kind": "media",
  "url": "https://example.com/orders/4821/table.jpg",
  "caption": "Yes, by the window."
}

A single photo or file is media with one url. On iMessage, nothing else goes beside it:

{ "kind": "media", "url": "https://example.com/orders/4821/receipt.pdf" }

A multipart holds 2 to 20 parts in the order you list them, at most 10 of them photos, and no link twice. Mapier fetches every link before the message goes out. If one link fails, nothing is sent and the error names the part.

Limits

Send a message › Files lists the largest file and the most files per message on each channel.

ChannelWho fetches the linkWhat it takes
iMessageMapier, before it sendshttps only, at most 8 MiB: an image, a PDF, common audio or video, or a vCard (.vcf) whose declared type matches its bytes

On iMessage, a photo or file goes only into a conversation the person has written in, or a group chat.

When a file fails after sending

A file the channel cannot use ends as a failed result:

Stream output
id: 0192…
event: command
data: {"commandId":"0192b3f7-…","type":"message.send","status":"failed","failureClass":"content","errorCode":"…","messageId":null,"conversationId":"a0000000-…","lineId":"0192a7b0-…"}

failureClass: content means the file or text was refused. Fix the file, then send it again. errorCode is the channel's own word, for your logs.

Results and delivery lists every class.

Receive a file

An incoming message.received event lists each file in attachments. Download any file with GET /v1/attachments/{id}.

message.received data, with one file
{
  "messageId": "0192d0a1-…",
  "conversationId": "a0000000-0000-4000-8000-000000000001",
  "lineId": "0192a7b0-…",
  "channel": "imessage",
  "from": "+15550100100",
  "text": "Here is my receipt.",
  "attachments": [
    { "id": "0192e4f2-…", "mimeType": "image/jpeg", "filename": "receipt.jpg", "byteSize": 482113 }
  ]
}

mimeType, filename and byteSize are what the person's device declared, or null. A voice note adds "kind": "voice_note", and a sticker adds "isSticker": true.

Errors you may see

Each of these comes back at once, and nothing is sent. A problem Mapier cannot check up front ends as a failed result instead.

ErrorMeansFix
403 recipient_not_allowedThis person cannot get files from you yetCheck who can write first
404 unsupported_command, not_on_channelA multipart on a line whose channel takes one file per messageSend one file per message
422 validation_failed, conversation_not_confirmedThe person has not written in this conversation yetSend a text first
422 validation_failed, media_too_largeThe file is too largeSend a smaller file
422 validation_failed, unsupported_media_typeThe file type is not supportedConvert the file
422 validation_failed, media_fetch_failedMapier could not fetch the linkCheck the link, then retry
422 validation_failed, media_fetch_refusedThe link is not https, or points inside a private networkHost the file at a public https link
503 service_busyMapier is busy fetching many filesWait retryAfter seconds, then retry

Next