# groups.message_create

Criar mensagem de grupos. Cria a mensagem. `kind`: `text` (texto obrigatório), `link` (texto com um endereço https://), `media` (`media` vem do upload em `/api/v1/grupos-media`; `body` é a legenda), `poll` (2 a 12 opções de até 100 caracteres), `contact` (telefone com 12 ou 13 dígitos). Texto até 4.096 caracteres e variação `{a|b}` válida. `isWelcome: true` desmarca a boas-vindas anterior da campanha.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/groups.message_create` (corpo JSON)
- Quem pode chamar: administrador da conta
- Escopo da chave: `marketing:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `groups_message_create`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `groups.message_create`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `campaignId` | string (uuid) | sim |  |
| `title` | string | sim |  |
| `kind` | "text" \| "media" \| "link" \| "poll" \| "contact" | sim |  |
| `body` | string | não |  |
| `media` | object | não |  |
| `poll` | object | não |  |
| `contact` | object | não |  |
| `mentionAll` | boolean | não | padrão false |
| `isWelcome` | boolean | não | padrão false |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "campaignId": {
      "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)$"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "kind": {
      "type": "string",
      "enum": [
        "text",
        "media",
        "link",
        "poll",
        "contact"
      ]
    },
    "body": {
      "type": "string",
      "maxLength": 4096
    },
    "media": {
      "type": "object",
      "properties": {
        "storagePath": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "mime": {
          "type": "string",
          "maxLength": 100
        },
        "mediaKind": {
          "type": "string",
          "enum": [
            "image",
            "video",
            "audio",
            "document"
          ]
        },
        "fileName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "storagePath",
        "mime",
        "mediaKind",
        "fileName",
        "size"
      ]
    },
    "poll": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "options": {
          "maxItems": 12,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 100
          }
        },
        "selectable": {
          "default": 1,
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "name",
        "options"
      ]
    },
    "contact": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "phone": {
          "type": "string",
          "maxLength": 30
        }
      },
      "required": [
        "name",
        "phone"
      ]
    },
    "mentionAll": {
      "default": false,
      "type": "boolean"
    },
    "isWelcome": {
      "default": false,
      "type": "boolean"
    }
  },
  "required": [
    "campaignId",
    "title",
    "kind"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/groups.message_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"campaignId":"00000000-0000-0000-0000-000000000000","title":"Boas-vindas","kind":"text","body":"{Oi|Olá}! Seja bem-vindo.","mentionAll":false,"isWelcome":true}'
```

CLI:

```bash
node cli/atomiks.mjs groups.message_create --json '{"campaignId":"00000000-0000-0000-0000-000000000000","title":"Boas-vindas","kind":"text","body":"{Oi|Olá}! Seja bem-vindo.","mentionAll":false,"isWelcome":true}'
```

MCP: ferramenta `groups_message_create` 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": {
    "id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "text",
        "media",
        "link",
        "poll",
        "contact"
      ]
    },
    "body": {
      "type": [
        "string",
        "null"
      ]
    },
    "media": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "storagePath": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "mime": {
              "type": "string",
              "maxLength": 100
            },
            "mediaKind": {
              "type": "string",
              "enum": [
                "image",
                "video",
                "audio",
                "document"
              ]
            },
            "fileName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "size": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "storagePath",
            "mime",
            "mediaKind",
            "fileName",
            "size"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "poll": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "options": {
              "maxItems": 12,
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 100
              }
            },
            "selectable": {
              "default": 1,
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "name",
            "options",
            "selectable"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "contact": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "phone": {
              "type": "string",
              "maxLength": 30
            }
          },
          "required": [
            "name",
            "phone"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "mentionAll": {
      "type": "boolean"
    },
    "isWelcome": {
      "type": "boolean"
    },
    "version": {
      "type": "number"
    },
    "updatedAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "title",
    "kind",
    "body",
    "media",
    "poll",
    "contact",
    "mentionAll",
    "isWelcome",
    "version",
    "updatedAt"
  ],
  "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).
