# Media Messages

{% hint style="info" %}
You can only send a text message up until 24 hours after receiving a message from the user. If you have not received a message from the user within this time, you will need to start a new conversation by sending a [Template Message](/apidocs/quick-start.md).
{% endhint %}

Use the `messages` node to send messages containing audio, documents, images, stickers, or videos to your customers.

In essence, when you send a message that includes media, you must provide the link to the media in the request body. You must also specify the type of media that you are sending: `audio`, `document`, `image`, `sticker`, or `video`. When the request is received, the media is uploaded to the WhatsApp server and sent to the user indicated in the `to_contact` field.

{% hint style="info" %}
**Links** - To use a link, you supply an HTTP(S) link from which the application will download the media, saving you the step of uploading media yourself. Please make sure you are using a mp4 direct link.
{% endhint %}

{% hint style="info" %}
You can provide a `link` parameter pointing to the media you want to send. Currently only HTTP/HTTPS links are supported. **You will need to use a link that directs to the mp4 file itself**, which might not be available if using basic video platforms. Some suggested platforms that offer this type of link are Google Cloud Storage Bucket, AWS S3 Bucket, Streamable.
{% endhint %}

## Send a media message

<mark style="color:green;">`POST`</mark> `https://api.qikchat.in/v1/messages`

To send a media message, use the request URL and the following body parameters.

#### Headers

| Name                                              | Type   | Description   |
| ------------------------------------------------- | ------ | ------------- |
| QIKCHAT-API-KEY<mark style="color:red;">\*</mark> | string | place API key |

#### Request Body

| Name                                              | Type   | Description                                       |
| ------------------------------------------------- | ------ | ------------------------------------------------- |
| to\_contact<mark style="color:red;">\*</mark>     | string | customer whatsapp number you want to send message |
| type<mark style="color:red;">\*</mark>            | string | audio \| document \| image \| video \| sticker    |
| SPECIFIC OBJECT<mark style="color:red;">\*</mark> | object |                                                   |

{% tabs %}
{% tab title="200: OK " %}
A successful response includes a `data object` with an ID for the message sent.

The relevant object (dictionary with “id”) is nested in array which itself is in other dict.

```json
{
    "status": true,
    "message": "Messages queued successfully",
    "data": [
        {
            "id": "52JH6WmuSruAVyXvBBYemd0Ia",
            "channel": "whatsapp",
            "from": "919099999916",
            "recipient": "+917904903575",
            "created_at": "2023-02-19T12:52:25.222Z",
            "status": "queued"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

**Example**

The sample below shows multiple different objects such as `audio`, `document`, `image`, `sticker`, and `video` for illustration purposes only. A valid request body contains only one of them.

```
POST /v1/messages
{
  "to_contact": "whatsapp-id",
  "type": "audio" | "document" | "image" | "sticker" | "video",
  
  "audio": {
    "link": "http(s)://the-url",
  }
  
  "document": {
    "link": "http(s)://the-url.pdf",
    "caption": "your-document-caption",
    "filename": "your-document-filename"
  }
  
  "video": {
    "link": "http(s)://the-url",
    "caption": "your-video-caption"    
  }
  
  "image": {
    "link": "http(s)://the-url",
    "caption": "your-image-caption"
  }
  
  "sticker": {
    "link": "http(s)://the-url",
  }
}
```

#### Post-Processing Media Size <a href="#post-processing" id="post-processing"></a>

| Media Type | Size   |
| ---------- | ------ |
| audio      | 16 MB  |
| document   | 100 MB |
| image      | 5 MB   |
| sticker    | 100 KB |
| video      | 16 MB  |

#### Supported Content-Types

| Media    | Supported Content-Types                                                                                                                                               |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| audio    | <p>audio/aac, audio/mp4, audio/amr, audio/mpeg, audio/ogg; codecs=opus </p><p></p><p>Note: The base audio/ogg type is not supported.</p>                              |
| document | Any valid MIME-type.                                                                                                                                                  |
| image    | <p>image/jpeg, image/png                                   </p><p><br>Images with transparent backgrounds won't support.</p>                                          |
| sticker  | image/webp                                                                                                                                                            |
| video    | <p>video/mp4, video/3gpp</p><p></p><p>Notes:</p><p>Only H.264 video codec and AAC audio codec is supported. Only videos with a single audio stream are supported.</p> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qikchat.gitbook.io/apidocs/reference/api-reference/media-messages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
