---
updatedAt: 2026-01-21T05:19:41.000Z
agentTools:
  projectIndex: https://developers.kaleyra.io/llms.txt
---

# Send a Media Message through WhatsApp

POST Method

1. Sign up for free

Before you get started, [Create an API Key](https://developers.kaleyra.io/docs/generating-an-api-key). To view the API Key and the SID, see [View API Key and SID](https://developers.kaleyra.io/docs/view-api-key-and-sid).

2. Pre-requisites

Below listed are the pre-requisites for using Kalyera WhatsApp APIs:

* A WhatsApp business number.
* An associated profile with the business number.
* A WhatsApp verified and approved profile.

For more details, read what [WhatsApp ](https://www.facebook.com/business/help/2087193751603668?id=2129163877102343) has to say about creating a business account.

3. Send a media message.

## Base URL

`https://<api_domain>/v1/<SID>`

## API Domain and Value

| api\_domain | Value             |
| :---------- | :---------------- |
| IN pod      | api.in.kaleyra.io |
| SG Pod      | api.ap.kaleyra.io |
| EU Pod      | api.eu.kaleyra.io |

You can use the below API’s to send a media message via WhatsApp account

## Request Format

The following is the request format to send Media Message through WhatsApp:

```curl
curl --location 'https://<api_domain>/v1/<sid>/messages' \
--header 'api-key: <api_Key>' \
--form 'to="<to_number>"' \
--form 'type="<type>"' \
--form 'channel="<channel_name>"' \
--form 'from="<from_number>"' \
--form 'callback_url="<callback_url>"' \
--form 'media="<media_file>"' \
--form 'media_url="<media_url>"' \
--form 'caption="<media_caption>"'
```

## Sample Request Format

The following is the sample request format to send Media Messages through WhatsApp:

```curl
curl --location 'https://api.in.kaleyra.io/v1/HXAP16XXXXXX97IN/messages' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--form 'to="+91XXXXXXXXXX"' \
--form 'type="media"' \
--form 'channel="whatsapp"' \
--form 'from="+91XXXXXXXXXX"' \
--form 'callback_url="https://callbacktesting2.free.beeceptor.com"' \
--form 'media="@/C:/Users/company_A/Downloads/videoplayback.mp4"' \
--form 'media_url="https://s3.ap-south-1.amazonaws.com/stage-hexa/docs/1614840334KLlogo.png"' \
--form 'caption="This is the capton"'
```

## Parameter and Data Types

The following is the list of parameters and data types supported for sending a media message through WhatsApp:

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Parameter
      </th>

      <th>
        Data Type
      </th>

      <th>
        Description
      </th>

      <th>
        Example
      </th>

      <th>
        Mandatory?
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `sid`
      </td>

      <td>
        String
      </td>

      <td>
        Account SID (Security Identifier). Generated by Kaleyra.io while creating an API key.
      </td>

      <td>
        HXXXXXXX071IN
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `api-key`
      </td>

      <td>
        String
      </td>

      <td>
        API key generated from kaleyra.io account.
      </td>

      <td>
        Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `to_number`
      </td>

      <td>
        String
      </td>

      <td>
        A valid WhatsApp number of the recipient. Ensure that the country code is prefixed to the number. (E164 format).  
        Note: You can add multiple recipients, separate each number using the comma (,) delimiter.
      </td>

      <td>
        +91XXXXXXXXXX
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `type`
      </td>

      <td>
        String
      </td>

      <td>
        The type of message you want to send.  
        For details on the formats supported, read [Messaging on WhatsApp Business](https://developers.kaleyra.io/docs/messaging-on-whatsapp) .
      </td>

      <td>
        media
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `channel`
      </td>

      <td>
        String
      </td>

      <td>
        Defines the channel name.
      </td>

      <td>
        whatsapp
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `from_number`
      </td>

      <td>
        String
      </td>

      <td>
        The number registered with WhatsApp business from which the message is to be sent.  Ensure that the country code is prefixed to the number. (E164 format).
      </td>

      <td>
        +91XXXXXXXXXX
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `callback_url`
      </td>

      <td>
        String
      </td>

      <td>
        The URL that Kaleyra.io should send information to when your number receives a response. This URL can be accessed publicly.  
        Click [here](https://developers.kaleyra.io/docs/whatsapp-callback-url)  for an example.
      </td>

      <td>
        [https://callbacktesting2.free.beeceptor.com](https://callbacktesting2.free.beeceptor.com)
      </td>

      <td>
        No
      </td>
    </tr>

    <tr>
      <td>
        `media_file`
      </td>

      <td>
        Media
      </td>

      <td>
        The location of the media file that will be embedded in the message.

        Ensure you upload only the formats supported. Refer to  
        [Messaging on WhatsApp Business](https://developers.kaleyra.io/docs/messaging-on-whatsapp)  for more details.
      </td>

      <td>
        @/C:/Users/company_A/Downloads/videoplayback.mp4
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `media_url`
      </td>

      <td>
        String
      </td>

      <td>
        The media URL should be public and have a file extension.  
        Note: URL path is supported for image/video/media instead of uploading it.  
        If both media and media_url are passed in API request, then only "media_url" will be considered.
      </td>

      <td>
        [https://www.kaleyra.com/wp-content/uploads/kaleyra.png](https://www.kaleyra.com/wp-content/uploads/kaleyra.png)
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `caption`
      </td>

      <td>
        String
      </td>

      <td>
        A caption for the media file.
      </td>

      <td>
        Heading [https://kaleyra.io](https://kaleyra.io)
      </td>

      <td>
        Yes
      </td>
    </tr>
  </tbody>
</Table>

## Sample Success Response

The following success message appears with the status 202 Accepted:

```json
{
    "id": "6e77bc24-fc4f-4c87-945f-12990d7342ef",
    "type": "media",
    "body": "Hey Welcome to kaleyra  Media Messaging Platform .",
    "createdDateTime": "2020-01-29 06:23:44+00:00",
    "totalCount": 1,
    "data": [
        {
            "message_id": "6e77bc24-fc4f-4c87-945f-12990d7342ef:0",
            "recipient": "1202XXXXXXX"
        }
    ],
    "error": {}
}
```

## Sample Failure Response

```json
{
"code": "E438",
"message": " For the type text you cannot send media URL.",
"data": [],
"error": {
"type": " For the type text you cannot send media URL."
}
}

{
"code": "E419",
"message": " For the type media, media/media_url field is mandatory"
"data": [],
"error": {
"type": " For the type media, media/media_url field is mandatory"
}
}
```

## Error Codes

The below table provides information about the error codes you would receive when executing the WhatsApp Media Message API.

| Error Code | Parameter      | Description                                         |
| :--------- | :------------- | :-------------------------------------------------- |
| E13008     | from\_invalid  | Invalid or in-correct input of the **From** number. |
| E13009     | to\_invalid    | Invalid or in-correct input of the **TO** number.   |
| E13012     | invalid\_media | Invalid Media Content                               |
| E13014     | Invalid\_media | Failed to upload the Media file.                    |