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

# Messages

> Send text, media, interactive messages, reactions, and chat actions with the Java SDK

Message calls live under `client.messages()`. The Java SDK sends `instanceId` in the URL and `instanceToken` as `X-Instance-Token`; neither field is included in the JSON body.

## Text

```java theme={null}
client.messages().sendText(SendTextMessageRequest.builder()
    .instanceId(instanceId)
    .instanceToken(instanceToken)
    .phone("5511999999999")
    .message("Hello from Java")
    .build());
```

**Return:** envelope `{ code, success, data.message_id }` — message accepted/queued.

## Dynamic message payloads

Use `GenericInstanceRequest` for media and interactive payloads:

```java theme={null}
client.messages().sendImage(GenericInstanceRequest.builder()
    .instanceId(instanceId)
    .instanceToken(instanceToken)
    .put("phone", "5511999999999")
    .put("image", "https://example.com/image.png")
    .put("caption", "Image from Java")
    .build());
```

## Returns for other methods

| Method                                                                                                                                                            | Return                                                                              |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `sendImage`, `sendAudio`, `sendDocument`, `sendVideo`, `sendSticker`, `sendGif`, `sendLocation`, `sendContact`, `sendButtons`, `sendList`, `sendLink`, `sendPoll` | envelope `{ code, success, data.message_id }`                                       |
| `pollVote`, `react`                                                                                                                                               | envelope `{ code, success, data }` with confirmation (`details`, `timestamp`, `id`) |
| `removeReaction`, `presence`, `markRead`, `edit`, `delete`                                                                                                        | envelope `{ code, success, data.details }`                                          |
| `downloadImage`, `downloadVideo`, `downloadAudio`, `downloadDocument`                                                                                             | envelope `{ code, success, data.mimetype, data.data }`                              |
| `send(instanceId, path, body, token)`                                                                                                                             | same HTTP contract as the proxied path                                              |

Use `GenericInstanceRequest` for media and interactive payloads:

```java theme={null}
client.messages().sendImage(GenericInstanceRequest.builder()
    .instanceId(instanceId)
    .instanceToken(instanceToken)
    .put("phone", "5511999999999")
    .put("image", "https://example.com/image.png")
    .put("caption", "Image from Java")
    .build());
```

**Return:** envelope `{ code, success, data }` with `data.mimetype` and `data.data` (base64 or data URL).

## Escape hatch

```java theme={null}
client.messages().send(instanceId, "send/text", Map.of("phone", phone, "message", "Hi"), instanceToken);
```
