Ver .md

groups.schedule_create

Agendar o envio de uma mensagem. Agenda a mensagem para o alvo. kind: once exige runAt (ISO com fuso, pelo menos 2 minutos no futuro); recurring exige weekdays (0 = domingo a 6) e timeOfDay HH:MM no fuso da campanha. O conteúdo fica congelado, a menos que useLatest seja verdadeiro (usa a versão atual da mensagem na hora de enviar). Devolve warnings: outro agendamento a menos de 10 minutos do próximo disparo, ou alvo sem grupos hoje.

  • Endpoint: POST https://app.atomiks.com.br/api/v1/groups.schedule_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_schedule_create
  • Ficha em JSON: https://app.atomiks.com.br/api/v1/openapi.json (operationId groups.schedule_create)

Entrada

CampoTipoObrigatórioNota
campaignIdstring (uuid)sim
messageIdstring (uuid)sim
targetobjectsim
speed"slow" | "normal" | "fast"nãopadrão "normal"
kind"once" | "recurring"sim
runAtstring (date-time)não
weekdaysinteger[]não
timeOfDaystringnão
useLatestbooleannãopadrão false
JSON Schema
{
  "$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)$"
    },
    "messageId": {
      "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)$"
    },
    "target": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "all": {
              "type": "boolean",
              "const": true
            }
          },
          "required": [
            "all"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "folderId": {
              "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": [
            "folderId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "linkId": {
              "anyOf": [
                {
                  "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)$"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "linkId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "groupIds": {
              "minItems": 1,
              "maxItems": 2000,
              "type": "array",
              "items": {
                "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": [
            "groupIds"
          ],
          "additionalProperties": false
        }
      ]
    },
    "speed": {
      "default": "normal",
      "type": "string",
      "enum": [
        "slow",
        "normal",
        "fast"
      ]
    },
    "kind": {
      "type": "string",
      "enum": [
        "once",
        "recurring"
      ]
    },
    "runAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "weekdays": {
      "minItems": 1,
      "maxItems": 7,
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 0,
        "maximum": 6
      }
    },
    "timeOfDay": {
      "type": "string",
      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
    },
    "useLatest": {
      "default": false,
      "type": "boolean"
    }
  },
  "required": [
    "campaignId",
    "messageId",
    "target",
    "kind"
  ]
}

Exemplo

curl -X POST https://app.atomiks.com.br/api/v1/groups.schedule_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"campaignId":"00000000-0000-4000-8000-000000000001","messageId":"00000000-0000-4000-8000-000000000001","target":{"all":true},"speed":"normal","kind":"recurring","weekdays":[1,3],"timeOfDay":"09:00","useLatest":false}'

CLI:

node cli/atomiks.mjs groups.schedule_create --json '{"campaignId":"00000000-0000-4000-8000-000000000001","messageId":"00000000-0000-4000-8000-000000000001","target":{"all":true},"speed":"normal","kind":"recurring","weekdays":[1,3],"timeOfDay":"09:00","useLatest":false}'

MCP: ferramenta groups_schedule_create com a mesma entrada.

Saída

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

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "messageId": {
      "type": [
        "string",
        "null"
      ]
    },
    "title": {
      "type": [
        "string",
        "null"
      ]
    },
    "kind": {
      "type": "string",
      "enum": [
        "once",
        "recurring"
      ]
    },
    "runAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "weekdays": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "timeOfDay": {
      "type": [
        "string",
        "null"
      ]
    },
    "nextRunAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "nextRuns": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "state": {
      "type": "string"
    },
    "target": {},
    "speed": {
      "type": "string"
    },
    "useLatest": {
      "type": "boolean"
    },
    "version": {
      "type": "number"
    },
    "lastRunAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "lastJobIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "id",
    "messageId",
    "title",
    "kind",
    "runAt",
    "weekdays",
    "timeOfDay",
    "nextRunAt",
    "nextRuns",
    "state",
    "target",
    "speed",
    "useLatest",
    "version",
    "lastRunAt",
    "lastJobIds",
    "warnings"
  ],
  "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).