# inbox.send

Enviar mensagem em uma conversa. Envia texto, mídia (`uploadId` de `POST /api/v1/uploads`), figurinha da biblioteca (`stickerId` de `inbox.stickers_list`, só WhatsApp) ou modelo aprovado (`templateId` + `params`) pelo número da conversa. Informe exatamente um entre `text`, `uploadId`, `stickerId` e `templateId`. `clientRequestId` torna o pedido idempotente: repetir devolve a mensagem original. `replyToMessageId` cita uma mensagem da mesma conversa. Fora da janela de 24 h só modelo. Resposta incerta da Meta deixa a mensagem `unknown` (`uncertain: true`) e nada é reenviado.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/inbox.send` (corpo JSON)
- Quem pode chamar: membro da conta
- Escopo da chave: `messages:send`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `inbox_send`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `inbox.send`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `conversationId` | string (uuid) | sim |  |
| `clientRequestId` | string (uuid) | sim |  |
| `text` | string | não |  |
| `uploadId` | string (uuid) | não |  |
| `caption` | string | não |  |
| `templateId` | string (uuid) | não |  |
| `params` | object | não |  |
| `stickerId` | string (uuid) | não |  |
| `replyToMessageId` | string (uuid) | não |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "conversationId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "text": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "uploadId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "caption": {
      "type": "string",
      "maxLength": 1024
    },
    "templateId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "params": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "string",
        "maxLength": 2048
      }
    },
    "stickerId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "replyToMessageId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    }
  },
  "required": [
    "conversationId",
    "clientRequestId"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/inbox.send \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"conversationId":"00000000-0000-0000-0000-000000000000","clientRequestId":"6f1c2b0e-8a4d-4c3b-9e2f-1a2b3c4d5e6f","text":"Olá!"}'
```

CLI:

```bash
node cli/atomiks.mjs inbox.send --json '{"conversationId":"00000000-0000-0000-0000-000000000000","clientRequestId":"6f1c2b0e-8a4d-4c3b-9e2f-1a2b3c4d5e6f","text":"Olá!"}'
```

MCP: ferramenta `inbox_send` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "message": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "conversationId": {
          "type": "string"
        },
        "direction": {
          "type": "string",
          "enum": [
            "inbound",
            "outbound",
            "outbound_echo",
            "internal",
            "system"
          ]
        },
        "source": {
          "type": "string",
          "enum": [
            "live",
            "history"
          ]
        },
        "type": {
          "type": "string"
        },
        "body": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": [
            "string",
            "null"
          ]
        },
        "errorMessage": {
          "type": [
            "string",
            "null"
          ]
        },
        "metaTimestamp": {
          "type": [
            "string",
            "null"
          ]
        },
        "createdAt": {
          "type": "string"
        },
        "sentBy": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "media": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "mimeType": {
                  "type": "string"
                },
                "filename": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "sizeBytes": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "available",
                    "failed",
                    "expired"
                  ]
                }
              },
              "required": [
                "id",
                "mimeType",
                "filename",
                "sizeBytes",
                "state"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "payload": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ]
        },
        "replyTo": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "body": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "type": {
                  "type": "string"
                },
                "senderName": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "body",
                "type",
                "senderName"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "reactions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "emoji": {
                "type": "string"
              },
              "mine": {
                "type": "boolean"
              },
              "fromContact": {
                "type": "boolean"
              }
            },
            "required": [
              "emoji",
              "mine",
              "fromContact"
            ],
            "additionalProperties": false
          }
        },
        "isFavorited": {
          "type": "boolean"
        },
        "parentNoteId": {
          "type": [
            "string",
            "null"
          ]
        },
        "edited": {
          "type": "boolean"
        },
        "deleted": {
          "type": "boolean"
        },
        "editedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "deletedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "clientRequestId": {
          "type": [
            "string",
            "null"
          ]
        },
        "scheduled": {
          "type": "boolean"
        },
        "senderName": {
          "type": [
            "string",
            "null"
          ]
        },
        "senderJid": {
          "type": [
            "string",
            "null"
          ]
        },
        "meta": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ]
        },
        "rawType": {
          "type": [
            "string",
            "null"
          ]
        },
        "origin": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "phone",
                "automation",
                "flow"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "originLabel": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "conversationId",
        "direction",
        "source",
        "type",
        "body",
        "status",
        "errorMessage",
        "metaTimestamp",
        "createdAt",
        "sentBy",
        "media",
        "payload",
        "replyTo",
        "reactions",
        "isFavorited",
        "parentNoteId",
        "edited",
        "deleted",
        "editedAt",
        "deletedAt",
        "senderName",
        "senderJid"
      ],
      "additionalProperties": false
    },
    "uncertain": {
      "type": "boolean"
    }
  },
  "required": [
    "message",
    "uncertain"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
