> For the complete documentation index, see [llms.txt](https://wadocs.pepipost.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wadocs.pepipost.com/sending-message/send-message-api/send-media-message.md).

# Send Media message

**URL:​** ​<https://waapi.pepipost.com/api/v2/message/>&#x20;

**Method:** POST&#x20;

***Please note:** We can only send a media message if the recipient has initiated the conversation.*

### Parameters:

| Parameter           | Description                                                                                                                                                                                                                                                                                       | Data Type | Required                                                                                              |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------- |
| recipient\_whatsapp | Recipient’s phone number. Must be a valid number. Phone number must include a country code otherwise message might not get delivered.                                                                                                                                                             | String    | Yes                                                                                                   |
| recipient\_type     | <p>Indicate whether the recipient is an <code>individual</code>or a <code>group</code>.</p><p> Specifying <code>recipient\_type</code> in the request is optional when the value is <code>individual</code>. However, <code>recipient\_type</code> is required when using <code>group</code>.</p> | String    | No                                                                                                    |
| message\_type       | Pass `media` as the type of the message.                                                                                                                                                                                                                                                          | String    | Yes                                                                                                   |
| source              | Source id of the origin. Source id must be valid and obtained from source creation API.                                                                                                                                                                                                           | String    | Yes                                                                                                   |
| attachment\_id      | id of the media. Media id must be valid and obtained from Media API.                                                                                                                                                                                                                              | String    | Yes​ when sending media message without uploading media and using already uploaded media otherwise No |
| caption             | The caption to be given for attachment                                                                                                                                                                                                                                                            | String    | No                                                                                                    |
| x-apiheader         | Any custom data which user needs to send. ​ X-apiheader can be used instead of message id for mapping messages.                                                                                                                                                                                   | String    | No                                                                                                    |

### Request Body

```
{ 
  "message": [
  { 
    "recipient_whatsapp": "919833078369", 
    "message_type": "media", 
    "recipient_type": "individual", 
    "source": "fa9d647a-c8d7-423e-bd27-7d2ca2875dc1",
    "x-apiheader": "Your_unique_identifier", 
    "type_media": [
      { 
      "attachments": [
          { 
          "attachment_id": "1fc380aa-6953-4e95-aef9-f220a22d51a3", 
          "caption": "yourdocumentcaption" 
          }
      ] 
      }
    ] 
  }
  ] 
} 
  
```

### Responses for message API

#### In case of success

```
{ 
   "status": "success", 
   "message": "Request received successfully.", 
   "data": { 
       "id": "6929d4af-490d-454a-8cf3-0502a3506f09" 
   } 
} 
```

This id in response is message id for future response. All the message status updates on webhook will be mapped to this id. So store this message id at your side.

#### In case of failure

```
{ 
   "status": "failure", 
   "error": { 
       "code": "8006", 
       "message": " type is required." 
   } 
} 
```

According to error code and message will change.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://wadocs.pepipost.com/sending-message/send-message-api/send-media-message.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
