Sending Media

🔒 WhatsApp 24-Hour Session Rule

Before sending media, make sure the WhatsApp session with the user is active.

If the user has not messaged your business within the last 24 hours, WhatsApp requires the first message to be a template message.

After the customer replies, the 24-hour session opens and you may send media messages using this API. For sandbox testing, send your join code to the sandbox number to activate your session. Learn more

POST https://gateway.lipachat.com/api/v1/whatsapp/media

This API enables users to send Images, Videos, or Audio.

Headers

Name
Value

Content-Type

application/json

apiKey

Get apiKey from App portal settings tab https://app.lipachat.com/app/settings

Body

Name
Type
Description

messageId

string

A unique identifier for the message. This will be used to track the message status and for deduplication purposes.

mediaType

string

Pass value as IMAGE, VIDEO, AUDIO, DOCUMENT or STICKER

mediaUrl

string

URL of an image to be sent. Must be a valid URL starting with https://...

caption

string

Media caption. Optional.

filename

string

Optional, applies to Document.

from

string

Sandbox number +254110090747 or your own WABA phone number.

to

string

Receiver phone number. It should start with a country code.

curl --location 'https://gateway.lipachat.com/api/v1/whatsapp/media' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "messageId": "5d3f62c3-eb8f-4150-8941-bdceb0f429bb",
    "to": "254XXXXX",
    "from": "254110090747",
    "mediaType": "IMAGE",
    "mediaUrl": "https://picsum.photos/id/237/200/300",
    "caption": ""
}'
Sample Requests

Send Image

{
	"messageId": "{{$randomUUID}}",
	"to": "{{YOUR_PHONE_NUMBER}}",
	"from": "{{WA_PHONE_NUMBER}}",
	"mediaType": "IMAGE",
	"mediaUrl": "https://picsum.photos/id/237/200/300",
	"caption": "Test caption"
}

Send Video

{
	"messageId": "{{$randomUUID}}",
	"to": "{{YOUR_PHONE_NUMBER}}",
	"from": "{{WA_PHONE_NUMBER}}",
	"mediaType": "VIDEO",
	"mediaUrl": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4",
	"caption": "Test caption"
}

Send Audio

{
	"messageId": "{{$randomUUID}}",
	"to": "{{YOUR_PHONE_NUMBER}}",
	"from": "{{WA_PHONE_NUMBER}}",
	"mediaType": "AUDIO",
	"mediaUrl": "https://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav",
	"caption": "Optional Caption"
}

Send Document

{
    "messageId": "{{$randomUUID}}",
    "to": "{{YOUR_PHONE_NUMBER}}",
    "from": "{{YOUR_PHONE_NUMBER}}",
    "mediaType": "DOCUMENT",
    "mediaUrl": "https://media_url.pdf",
    "filename": "insurance_policy.pdf",
    "caption": "Please find attached"
}

Response

{
      "timestamp": "2023-08-06T01:27:56.825898971",
      "data": {
            "messageId": "7addc006-07db-4fae-aac5-b285903b41d4",
            "waId": "wamid.HBgMMjU0NzE3NzQ2NTY1FQIAEnRgSRjJGRkMzNkQ0QUVENTIxQ0NBAA==",
            "status": "SENT",
            "statusDesc": "Media sent successfully"
      },
      "status": "success",
      "message": "",
      "errors": null
}

Last updated