> ## 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.

# Media as base64

> Retrieves the content of a locally stored media item in base64

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

## Description

Reads media already stored locally (after ingestion) and returns the content in base64. Works for images, videos, audio, documents, and stickers.

<Info>
  Only messages whose media has already been downloaded and persisted by the ingestion pipeline return data here. If the media does not yet exist in storage, the response is `404`.
</Info>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://ryzeapi.cloud/api/chat/base64/$Instance_Name?messageId=3EB08FCF27E532F1B0F5" \
    -H "token: $Token_Instance"
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/chat/base64/${process.env.Instance_Name}?messageId=3EB08FCF27E532F1B0F5`, {
    method: "GET",
    headers: {
      "token": process.env.Token_Instance
    }
  });
  ```

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

  requests.get(
      f"https://ryzeapi.cloud/api/chat/base64/{os.environ['Instance_Name']}?messageId=3EB08FCF27E532F1B0F5",
      headers={"token": os.environ["Token_Instance"]}
  )
  ```

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

  import (
      "net/http"
      "os"
  )

  func main() {
      req, _ := http.NewRequest("GET", "https://ryzeapi.cloud/api/chat/base64/"+os.Getenv("Instance_Name")+"?messageId=3EB08FCF27E532F1B0F5", nil)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Success response

The response echoes `message_id`, brings `mime_type` and `media_type` (general category: `image`, `video`, `audio`, `document`, `sticker`), and returns in `base64` the raw media bytes already encoded, ready to write to a file, upload elsewhere, or display inline. The payload can be large for long videos/audios.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Base64 retrieved successfully",
  "message_id": "3EB08FCF27E532F1B0F5",
  "mime_type": "image/jpeg",
  "media_type": "image",
  "base64": "iVBORw0KGgoAAAANSUhEUgAAAAEA..."
}
```

## Path parameters

<ParamField path="instance" type="string" required>
  Instance name.
</ParamField>

## Query params

<ParamField query="messageId" type="string" required>
  ID of the message that contains the media.
</ParamField>

## Headers

| Name    | Required                 | Example        | Description                    |
| ------- | ------------------------ | -------------- | ------------------------------ |
| `token` | yes (or `Authorization`) | `a1b2c3d4-...` | TokenAccount or TokenInstance. |

## Error responses

| HTTP | `error.message`                           | When it happens                      |
| ---- | ----------------------------------------- | ------------------------------------ |
| 400  | `Instance name is required`               | ,                                    |
| 400  | `messageId query parameter is required`   | ,                                    |
| 401  | `Invalid token`                           | ,                                    |
| 404  | `Instance not found`                      | ,                                    |
| 404  | `Message not found or no media available` | Media missing or not yet downloaded. |
| 503  | `Instance is not connected to WhatsApp`   | ,                                    |

```json Error 404 theme={null}
{
  "success": false,
  "error": { "message": "Message not found or no media available" }
}
```

## Related

<CardGroup cols={2}>
  <Card title="Find message" href="/en/api/chat/find-message">
    Retrieve metadata before downloading.
  </Card>

  <Card title="Delivery status" href="/en/api/chat/contact-status">
    Check delivery/read.
  </Card>
</CardGroup>
