# Imagem

Foto, com legenda opcional.

- `url` ou `base64`: o arquivo. Use um dos dois; `base64` aceita com ou sem o prefixo `data:`.
- `text`: a legenda.
- `view_once: true`: visualização única.
- `mime_type`: o tipo do arquivo. Sem ele, a api descobre pelo conteúdo.

Visualização única é só do WhatsApp Web; nos outros canais a resposta é `501` com `unsupported_for_channel`.

## Canais

| Canal | Funciona | Observação |
|---|---|---|
| WhatsApp (Web) | Sim |  |
| WhatsApp (API oficial) | Em parte | Sem `view_once` nem `animated`. |
| Instagram | Em parte | Sem `view_once` nem `animated`. |
| Messenger | Em parte | Sem `view_once` nem `animated`. |
| Telegram | Em parte | Sem `view_once` nem `animated`. |

## Pedido

`POST /messages` com `"type": "image"`. [Testar](/endpoint/post/messages)

```json
{
  "to": "5511999999999",
  "type": "image",
  "url": "https://loja.exemplo/nota.jpg",
  "text": "Sua nota fiscal"
}
```

### Na uazapi

`POST /send/media`, que continua funcionando. Na uazapi era `POST /send/media` com `type: image` e o arquivo em `file`; na Orkesio o arquivo vai em `url` ou `base64`.

```lado-a-lado
{
  "uazapi (POST /send/media)": {
    "number": "5511999999999",
    "type": "image",
    "file": "https://loja.exemplo/nota.jpg",
    "text": "Sua nota fiscal"
  },
  "Orkesio (POST /messages)": {
    "to": "5511999999999",
    "type": "image",
    "url": "https://loja.exemplo/nota.jpg",
    "text": "Sua nota fiscal"
  }
}
```

## Resposta

A própria mensagem (`OrkesioMessage`), no formato do `message.sent` e da busca. No WhatsApp Web volta na hora com `status: queued`: por padrão o envio vai pela fila (com `options.async: false`, espera o envio e volta a mensagem enviada). É o pedido no formato da mensagem: o arquivo, a miniatura e a prévia do link chegam no `message.sent`. Na API oficial volta depois que a Meta aceita, com `status: pending`. O resultado chega em `message.status` (a falha também em `message.failed`).

```json
{
  "id": "3EB05DCE1D4036FCE241C6",
  "chat_id": "5511999999999@s.whatsapp.net",
  "author": {
    "id": "5511888888888@s.whatsapp.net",
    "phone": "5511888888888"
  },
  "direction": "out",
  "sent_at": "2026-10-17T12:00:00.000Z",
  "category": "unsent",
  "type": "image",
  "text": "Sua nota fiscal",
  "sent_by": "api",
  "status": "queued"
}
```

### Na uazapi

O `content` da uazapi é o proto do WhatsApp; aqui vai resumido (`...`).

```lado-a-lado
{
  "uazapi": {
    "id": "5511888888888:3EB05DCE1D4036FCE241C6",
    "messageid": "3EB05DCE1D4036FCE241C6",
    "chatid": "5511999999999@s.whatsapp.net",
    "chatlid": "123456789012345@lid",
    "fromMe": true,
    "isGroup": false,
    "groupName": "",
    "sender": "987654321098765@lid",
    "sender_pn": "5511888888888@s.whatsapp.net",
    "sender_lid": "987654321098765@lid",
    "senderName": "",
    "messageType": "ImageMessage",
    "mediaType": "image",
    "messageTimestamp": 1792238400000,
    "source": "web",
    "status": "",
    "text": "Sua nota fiscal",
    "content": {
      "URL": "https://mmg.whatsapp.net/o1/v/t24/f2/m231/AQ...",
      "directPath": "/o1/v/t24/f2/m231/AQ...",
      "mediaKey": "xc89kGb6...",
      "fileSHA256": "fH72FyaiECvF1pFA4HOHfF6Pyd7c2X0B8jCM+r69RQo=",
      "fileEncSHA256": "f4ddpVBw...",
      "mediaKeyTimestamp": 1792238400,
      "mimetype": "image/jpeg",
      "caption": "Sua nota fiscal",
      "JPEGThumbnail": "/9j/4AAQ..."
    },
    "quoted": "",
    "edited": "",
    "reaction": "",
    "vote": "",
    "buttonOrListid": "",
    "convertOptions": "",
    "pinned": false,
    "owner": "5511888888888",
    "wasSentByApi": true,
    "track_source": "",
    "track_id": "",
    "response": {
      "status": "success",
      "message": "Message sent successfully"
    }
  },
  "Orkesio": {
    "id": "3EB05DCE1D4036FCE241C6",
    "chat_id": "5511999999999@s.whatsapp.net",
    "author": {
      "id": "5511888888888@s.whatsapp.net",
      "phone": "5511888888888"
    },
    "direction": "out",
    "sent_at": "2026-10-17T12:00:00.000Z",
    "category": "unsent",
    "type": "image",
    "text": "Sua nota fiscal",
    "sent_by": "api",
    "status": "queued"
  }
}
```

## No webhook

O que chega no seu webhook (ou em `GET /events`) depois do envio.

### message.sent

Quando a mensagem sai. [O evento `message.sent`](/webhook/message.sent)

```json
{
  "id": "evt_01JAB3K9ZQ7V0M4T8R2X6WYD5H",
  "type": "message.sent",
  "created_at": "2026-10-17T12:00:00.000Z",
  "inbox": {
    "id": "r0269625d29bfbd",
    "name": "loja",
    "phone": "5511888888888",
    "channel": "whatsapp_web"
  },
  "data": {
    "message": {
      "id": "3EB05DCE1D4036FCE241C6",
      "chat_id": "5511999999999@s.whatsapp.net",
      "author": {
        "id": "5511888888888@s.whatsapp.net",
        "phone": "5511888888888"
      },
      "direction": "out",
      "sent_at": "2026-10-17T12:00:00.000Z",
      "category": "conversation",
      "type": "image",
      "text": "Sua nota fiscal",
      "mime_type": "image/jpeg",
      "url": "https://servidor-da-instancia.exemplo/files/AC1FACA14F3FA7A19DB5FB19D7035506.jpg",
      "sent_by": "api"
    },
    "chat": {
      "id": "5511999999999@s.whatsapp.net",
      "lid": "123456789012345@lid",
      "type": "direct"
    }
  }
}
```

### message.status

`sent`, `delivered`, `read` e `played` (áudio e voz), um evento por mudança; `failed` se o envio falhar. [O evento `message.status`](/webhook/message.status)

```json
{
  "id": "evt_01JAB3K9ZQ7V0M4T8R2X6WYD6J",
  "type": "message.status",
  "created_at": "2026-10-17T12:00:05.000Z",
  "inbox": {
    "id": "r0269625d29bfbd",
    "name": "loja",
    "phone": "5511888888888",
    "channel": "whatsapp_web"
  },
  "data": {
    "chat": {
      "id": "5511999999999@s.whatsapp.net",
      "lid": "123456789012345@lid",
      "type": "direct"
    },
    "status": "delivered",
    "at": "2026-10-17T12:00:05.000Z",
    "messages": [
      {
        "id": "3EB05DCE1D4036FCE241C6"
      }
    ]
  }
}
```

