---
title: "Create a draft automation"
method: POST
path: "/automations"
tags: ["Automations"]
---

# Create a draft automation

`POST /automations`

## Request

- Base URL: `https://api.groundmail.dev`
- URL: `https://api.groundmail.dev/automations`
- Auth: HTTP bearer

## Request body

- CreateAutomationRequest
  - `name` string, required
  - `trigger` AutomationTrigger, required
    - `type` 'event', required
    - `event` string, required
    - `cancel_on_events` string[]: When any listed event fires for the same recipient, cancel queued/running/waiting runs for this automation.
    - `once_per_contact` boolean: Enrol each recipient at most once, ever. Matched on the trigger event's `email` or `user_id`. A later matching event is reported in `enrollment_skips` instead of starting a run.
    - `cooldown_days` integer: Do not enrol the same recipient again within this many days of their last run on this automation. Ignored when `once_per_contact` is true.
  - `steps` AutomationStep[], required
    - `type` 'delay' | 'send_email' | 'send_sms' | 'condition' | 'wait_for_event', required
  - `folder` string: Folder to file it in on the dashboard, matched by name (any case) and created when it does not exist.

## Response `201`

Automation created as draft

- AutomationResponse
  - `automation` Automation, required
    - `id` string, required
    - `name` string, required
    - `status` 'draft' | 'active' | 'paused', required
    - `trigger` AutomationTrigger, required
      - `type` 'event', required
      - `event` string, required
      - `cancel_on_events` string[]: When any listed event fires for the same recipient, cancel queued/running/waiting runs for this automation.
      - `once_per_contact` boolean: Enrol each recipient at most once, ever. Matched on the trigger event's `email` or `user_id`. A later matching event is reported in `enrollment_skips` instead of starting a run.
      - `cooldown_days` integer: Do not enrol the same recipient again within this many days of their last run on this automation. Ignored when `once_per_contact` is true.
    - `steps` AutomationStep[], required
      - `type` 'delay' | 'send_email' | 'send_sms' | 'condition' | 'wait_for_event', required
    - `folder` string, nullable, required: Name of the dashboard folder it is filed in, or null.
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required
  - `warnings` string[]: Returned on create and update when a step saves but should not ship as written — for example a `product` email whose body has no `{{unsubscribe_url}}` link.

## Other responses

- `400`: Invalid automation definition
- `401`: Missing or invalid API key / session
- `409`: Automation name already in use

---

[API](https://skmtc.dev/groundmail/apis/groundmail-api.md) · [All operations](https://skmtc.dev/groundmail/apis/groundmail-api/llms.txt) · [OpenAPI document](https://skmtc.dev/groundmail/apis/groundmail-api/revisions/479821c9fecf?raw)
