> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ryzeapi.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Audio Call

> Calls the number and plays an audio file once the call is answered

**Auth:** `TokenAccount` or `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotent:** no

## Description

Starts a voice call and, when the recipient **answers**, plays an audio file. The audio is converted automatically (via ffmpeg) to the format required by WhatsApp voice calls. Provide the media in **exactly one** field: `mediaUrl` (accepts a public URL **or** base64/data URI) **or** `mediaBase64` (base64 only). Sending both, or neither, is an error.

## Examples

### Audio from a URL

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/call/audio/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number":   "5511999999999",
      "mediaUrl": "https://example.com/message.mp3"
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/call/audio/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number:   "5511999999999",
      mediaUrl: "https://example.com/message.mp3"
    })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      f"https://ryzeapi.cloud/api/call/audio/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number":   "5511999999999",
          "mediaUrl": "https://example.com/message.mp3"
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number":   "5511999999999",
          "mediaUrl": "https://example.com/message.mp3"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/call/audio/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

### Audio as base64

Use `mediaBase64` when you already have the file bytes (no public URL).

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/call/audio/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number":      "5511999999999",
      "mediaBase64": "SUQzBAAAAAAA...="
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/call/audio/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number:      "5511999999999",
      mediaBase64: "SUQzBAAAAAAA...="
    })
  });
  ```

  ```python Python theme={null}
  import os, base64, requests

  with open("message.mp3", "rb") as f:
      audio_b64 = base64.b64encode(f.read()).decode()

  requests.post(
      f"https://ryzeapi.cloud/api/call/audio/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number":      "5511999999999",
          "mediaBase64": audio_b64
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number":      "5511999999999",
          "mediaBase64": "SUQzBAAAAAAA...="
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/call/audio/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Success response

```json 200 OK theme={null}
{
  "success": true,
  "message": "Audio call placed",
  "callId":  "3EB08FCF27E532F1D3D3",
  "number":  "5511999999999"
}
```

<Note>
  The audio only plays if the recipient **answers** the call. Conversion to WhatsApp's voice format is done automatically on the server.
</Note>

## Path parameters

<ParamField path="instance" type="string" required>
  Instance name (e.g., `$Instance_Name`).
</ParamField>

## Headers

<ParamField header="token" type="string" required>
  `TokenAccount` or `TokenInstance`.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Request body

<ParamField body="number" type="string" required>
  Destination: phone (`5511999999999`) or JID (`@s.whatsapp.net`).
</ParamField>

<ParamField body="mediaUrl" type="string">
  Audio source: accepts a **public URL** (`http(s)://…`) **or** the file contents as **base64** — raw base64 or a data URI (`data:audio/mpeg;base64,…`). The server auto-detects which one you sent. Provide **this or** `mediaBase64`, never both.
</ParamField>

<ParamField body="mediaBase64" type="string">
  Audio file contents as base64. Provide **this or** `mediaUrl`, never both.
</ParamField>

## Notes

<Note>
  * Provide **exactly one** media source: `mediaUrl` **or** `mediaBase64`. Sending both (or neither) returns `400`.
  * The server uses ffmpeg to convert the audio to the codec required by WhatsApp voice calls; common formats (mp3, ogg, wav, m4a) are accepted.
</Note>

## Errors

| HTTP | Message                                          |
| ---- | ------------------------------------------------ |
| 400  | `Instance name is required`                      |
| 400  | `Invalid request body: <detail>`                 |
| 400  | `Number is required`                             |
| 400  | `Provide exactly one of mediaUrl or mediaBase64` |
| 404  | `instance not found`                             |
| 500  | `<failure reason>`                               |

Error envelope:

```json theme={null}
{
  "success": false,
  "error": { "message": "Provide exactly one of mediaUrl or mediaBase64" }
}
```
