# groups.campaign_create

Criar campanha de grupos. Cria a campanha com o link principal (`shortCode`, 8 caracteres). Padrões: capacidade 1024, rotação sequencial, cookie desligado (0 dias), reserva de vaga de 10 minutos, fuso America/Sao_Paulo. `fallbackUrl` (https) recebe o clique quando não há vaga.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/groups.campaign_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_campaign_create`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `groups.campaign_create`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `name` | string | sim |  |
| `capacity` | integer | não | padrão 1024 |
| `rotationPolicy` | "sequential" \| "weighted" \| "round_robin" | não | padrão "sequential" |
| `cookieDays` | integer | não | padrão 0 |
| `reservationMinutes` | integer | não | padrão 10 |
| `timezone` | string | não | padrão "America/Sao_Paulo" |
| `fallbackUrl` | string \| null | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "capacity": {
      "default": 1024,
      "type": "integer",
      "minimum": 1,
      "maximum": 1024
    },
    "rotationPolicy": {
      "default": "sequential",
      "type": "string",
      "enum": [
        "sequential",
        "weighted",
        "round_robin"
      ]
    },
    "cookieDays": {
      "default": 0,
      "type": "integer",
      "minimum": 0,
      "maximum": 90
    },
    "reservationMinutes": {
      "default": 10,
      "type": "integer",
      "minimum": 1,
      "maximum": 60
    },
    "timezone": {
      "default": "America/Sao_Paulo",
      "type": "string"
    },
    "fallbackUrl": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "name"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/groups.campaign_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Lançamento Out","capacity":1024,"rotationPolicy":"sequential","cookieDays":0,"reservationMinutes":10,"timezone":"America/Sao_Paulo"}'
```

CLI:

```bash
node cli/atomiks.mjs groups.campaign_create --json '{"name":"Lançamento Out","capacity":1024,"rotationPolicy":"sequential","cookieDays":0,"reservationMinutes":10,"timezone":"America/Sao_Paulo"}'
```

MCP: ferramenta `groups_campaign_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"
    },
    "name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "attention",
        "paused",
        "ended"
      ]
    },
    "timezone": {
      "type": "string"
    },
    "shortCode": {
      "type": "string"
    },
    "capacity": {
      "type": "number"
    },
    "rotationPolicy": {
      "type": "string",
      "enum": [
        "sequential",
        "weighted",
        "round_robin"
      ]
    },
    "cookieDays": {
      "type": "number"
    },
    "reservationMinutes": {
      "type": "number"
    },
    "fallbackUrl": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "status",
    "timezone",
    "shortCode",
    "capacity",
    "rotationPolicy",
    "cookieDays",
    "reservationMinutes",
    "fallbackUrl",
    "createdAt"
  ],
  "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).
