> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/EvolutionAPI/evolution-api/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Audio Message

> Send WhatsApp voice messages (PTT) via Evolution API

## Send Audio Message

Send audio messages that appear as voice notes in WhatsApp. These are different from regular audio files and display as playable voice messages (PTT - Push-to-Talk) in the chat.

### Endpoint

```
POST /message/sendWhatsAppAudio/:instanceName
```

### Path Parameters

<ParamField path="instanceName" type="string" required>
  The name of your WhatsApp instance that you created
</ParamField>

### Request Body

<Note>
  This endpoint supports three methods for sending audio:

  1. **URL**: Provide a direct link to the audio file
  2. **Base64**: Provide the base64-encoded audio content
  3. **File Upload**: Use `multipart/form-data` to upload an audio file
</Note>

<ParamField body="number" type="string" required>
  The recipient's WhatsApp number in international format (without + symbol)

  Example: `5511999999999` for a Brazilian number
</ParamField>

<ParamField body="audio" type="string" required>
  The audio content as a URL or base64 string (not required when using file upload)

  Examples:

  * URL: `https://example.com/audio.mp3`
  * Base64: `data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAA...`
</ParamField>

<ParamField body="delay" type="integer" optional>
  Delay before sending the message in milliseconds

  Example: `1000` for 1 second delay
</ParamField>

<ParamField body="quoted" type="object" optional>
  Quote a previous message by providing its key and message object

  <expandable title="quoted properties">
    <ParamField body="quoted.key" type="object" required>
      <expandable title="key properties">
        <ParamField body="quoted.key.id" type="string" required>
          The message ID to quote
        </ParamField>

        <ParamField body="quoted.key.remoteJid" type="string" optional>
          The JID of the chat where the message was sent
        </ParamField>

        <ParamField body="quoted.key.fromMe" type="boolean" optional>
          Whether the quoted message was sent by you
        </ParamField>
      </expandable>
    </ParamField>

    <ParamField body="quoted.message" type="object" required>
      The original message object being quoted
    </ParamField>
  </expandable>
</ParamField>

<ParamField body="encoding" type="boolean" optional>
  Enable audio encoding for better compatibility

  Default: `false`
</ParamField>

### Response

<ResponseField name="key" type="object">
  Message key information

  <expandable title="key properties">
    <ResponseField name="key.remoteJid" type="string">
      The JID of the recipient
    </ResponseField>

    <ResponseField name="key.fromMe" type="boolean">
      Always true for sent messages
    </ResponseField>

    <ResponseField name="key.id" type="string">
      Unique message identifier
    </ResponseField>
  </expandable>
</ResponseField>

<ResponseField name="message" type="object">
  The sent message object containing the audio message data
</ResponseField>

<ResponseField name="messageTimestamp" type="string">
  Unix timestamp when the message was sent
</ResponseField>

<ResponseField name="status" type="string">
  Message status (e.g., "PENDING", "SENT")
</ResponseField>

### Code Examples

<CodeGroup>
  ```bash cURL - URL theme={null}
  curl -X POST https://your-api-url.com/message/sendWhatsAppAudio/my-instance \
    -H "Content-Type: application/json" \
    -H "apikey: YOUR_API_KEY" \
    -d '{
      "number": "5511999999999",
      "audio": "https://example.com/voice-note.mp3"
    }'
  ```

  ```bash cURL - File Upload theme={null}
  curl -X POST https://your-api-url.com/message/sendWhatsAppAudio/my-instance \
    -H "apikey: YOUR_API_KEY" \
    -F "number=5511999999999" \
    -F "file=@/path/to/audio.mp3"
  ```

  ```javascript JavaScript - URL theme={null}
  const response = await fetch('https://your-api-url.com/message/sendWhatsAppAudio/my-instance', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'apikey': 'YOUR_API_KEY'
    },
    body: JSON.stringify({
      number: '5511999999999',
      audio: 'https://example.com/voice-note.mp3'
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```javascript JavaScript - File Upload theme={null}
  const formData = new FormData();
  formData.append('number', '5511999999999');
  formData.append('file', audioFileInput.files[0]);

  const response = await fetch('https://your-api-url.com/message/sendWhatsAppAudio/my-instance', {
    method: 'POST',
    headers: {
      'apikey': 'YOUR_API_KEY'
    },
    body: formData
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python - URL theme={null}
  import requests

  url = 'https://your-api-url.com/message/sendWhatsAppAudio/my-instance'
  headers = {
      'Content-Type': 'application/json',
      'apikey': 'YOUR_API_KEY'
  }
  payload = {
      'number': '5511999999999',
      'audio': 'https://example.com/voice-note.mp3'
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```python Python - File Upload theme={null}
  import requests

  url = 'https://your-api-url.com/message/sendWhatsAppAudio/my-instance'
  headers = {
      'apikey': 'YOUR_API_KEY'
  }
  data = {
      'number': '5511999999999'
  }
  files = {
      'file': open('/path/to/audio.mp3', 'rb')
  }

  response = requests.post(url, data=data, files=files, headers=headers)
  print(response.json())
  ```

  ```php PHP - URL theme={null}
  <?php
  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => 'https://your-api-url.com/message/sendWhatsAppAudio/my-instance',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => json_encode([
      'number' => '5511999999999',
      'audio' => 'https://example.com/voice-note.mp3'
    ]),
    CURLOPT_HTTPHEADER => [
      'Content-Type: application/json',
      'apikey: YOUR_API_KEY'
    ],
  ]);

  $response = curl_exec($curl);
  curl_close($curl);
  echo $response;
  ?>
  ```
</CodeGroup>

### Advanced Examples

<Accordion title="Send audio from URL">
  ```json theme={null}
  {
    "number": "5511999999999",
    "audio": "https://example.com/voice-message.mp3"
  }
  ```
</Accordion>

<Accordion title="Send audio with base64 encoding">
  ```json theme={null}
  {
    "number": "5511999999999",
    "audio": "data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAA...",
    "encoding": true
  }
  ```
</Accordion>

<Accordion title="Send audio as reply to message">
  ```json theme={null}
  {
    "number": "5511999999999",
    "audio": "https://example.com/voice-note.mp3",
    "quoted": {
      "key": {
        "id": "BAE5F2D3E4F5A6B7",
        "remoteJid": "5511999999999@s.whatsapp.net",
        "fromMe": false
      },
      "message": {
        "conversation": "Original message"
      }
    }
  }
  ```
</Accordion>

## Audio Format Guidelines

<Note>
  For best compatibility with WhatsApp voice messages, use the following formats:
</Note>

### Recommended Formats

* **Format**: MP3, OGG (Opus codec), AAC
* **Sample rate**: 16kHz or 48kHz
* **Bitrate**: 64kbps - 128kbps
* **Channels**: Mono (1 channel)
* **Maximum duration**: No hard limit, but shorter is better for voice notes
* **Maximum size**: 16MB

### Supported Audio Formats

* MP3 (audio/mpeg)
* OGG with Opus codec (audio/ogg)
* M4A/AAC (audio/mp4, audio/aac)
* WAV (audio/wav) - will be converted

<Warning>
  Audio files sent via this endpoint will appear as voice messages (PTT) in WhatsApp, displayed with a play button and waveform. To send regular audio files as documents, use the [Send Media](/api/messages/send-media) endpoint with `mediatype: "audio"`.
</Warning>

## PTT vs Regular Audio

### Voice Message (PTT) - This Endpoint

* Appears as a voice message with waveform
* Plays automatically in sequence
* Designed for quick voice communication
* Maximum 16MB file size

### Regular Audio File - Send Media Endpoint

* Appears as an audio file attachment
* Requires manual play
* Suitable for music, podcasts, etc.
* Can be larger files

## Error Responses

<ResponseField name="status" type="number">
  HTTP status code
</ResponseField>

<ResponseField name="message" type="string">
  Error description
</ResponseField>

### Common Errors

| Status Code | Error Message                                                  | Solution                                                |
| ----------- | -------------------------------------------------------------- | ------------------------------------------------------- |
| 400         | "Owned media must be a url, base64, or valid file with buffer" | Ensure audio is provided as URL, base64, or file upload |
| 401         | Unauthorized                                                   | Check your API key                                      |
| 404         | Not Found                                                      | Verify instance exists and is connected                 |
| 500         | Internal Server Error                                          | Check audio file format and size                        |

<Note>
  The audio URL must be publicly accessible. If you're getting errors, verify that the URL can be accessed without authentication.
</Note>
