---
title: "Create a automation"
method: POST
path: "/v1/projectId/{projectId}/automations"
tags: ["Automations"]
---

# Create a automation

`POST /v1/projectId/{projectId}/automations`

## Request

- Base URL: `https://api.bluefox.email`
- URL: `https://api.bluefox.email/v1/projectId/{projectId}/automations`
- Auth: HTTP bearer

Either provide trigger directly, or basedOn to duplicate an existing automation. The automation always starts in "draft" status - use POST .../automations/{id}/activate once its trigger and sequence are ready.

## Path parameters

- `projectId` string, required

## Request body

- AutomationInput
  - `name` string, required
  - `trigger` object: Required on create unless basedOn is given. Shape depends on type - see the Automations guide.
  - `exitCriteria` object
  - `basedOn` string: Duplicate an existing automation (by _id) as the starting point - copies its sequence, trigger, and exit criteria. The new automation is always created in "draft" status regardless of the source's status.
  - `subscriberListId` string: With basedOn, overrides the duplicated trigger's subscriberListId - lets you clone an automation onto a different list.

## Response `201`

Created

- object
  - `status` integer
  - `result` Automation
    - `_id` string
    - `name` string
    - `status` 'draft' | 'active' | 'paused'
    - `trigger` object: Discriminated by trigger.type (contact-added | contact-updated | enter-segment | leave-segment | time-based) - shape varies by type, see the Automations guide. Every type except time-based also supports runOnce (boolean, default true): when true, a contact who has ever run this automation before is skipped even if the trigger matches again; set false to let them re-enter each time it matches.
    - `exitCriteria` object: A condition that removes a contact from this automation mid-flow when true. Has an "active" boolean plus condition fields.
    - `sequence` AutomationNode[]: The live, running sequence. Use the node sub-resource endpoints to add/update/delete nodes rather than replacing this array directly.
      - `_id` string
      - `type` 'delay' | 'send-email' | 'filter-audience' | 'branch' | 'complete' | 'set-value' | 'notify' | 'manage-tags' | 'webhook'
      - `error` string[]: Populated by the server when this node fails validation on an activate/merge-draft attempt - not settable by the client.
    - `draftSequence` AutomationNode[]: Present only while this automation is active and has unmerged staged edits. POST .../merge-draft to apply, or .../discard-draft to drop them.
      - `_id` string
      - `type` 'delay' | 'send-email' | 'filter-audience' | 'branch' | 'complete' | 'set-value' | 'notify' | 'manage-tags' | 'webhook'
      - `error` string[]: Populated by the server when this node fails validation on an activate/merge-draft attempt - not settable by the client.
    - `draftTrigger` object: Staged trigger edit, present only while active with unmerged changes.
    - `draftExitCriteria` object: Staged exit-criteria edit, present only while active with unmerged changes.
    - `usedSegments` string[]
    - `lastTriggeredAt` string, date-time
    - `createdAt` string, date-time
    - `updatedAt` string, date-time

## Other responses

- `400`: Invalid request body or query - every violation found (missing/invalid/unexpected fields) is reported in one response, semicolon-separated, not just the first one hit.
- `403`: Missing or invalid API key

---

[API](https://skmtc.dev/bluefox/apis/bluefox-email-public-api.md) · [All operations](https://skmtc.dev/bluefox/apis/bluefox-email-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/bluefox/apis/bluefox-email-public-api/revisions/fa1a0a835c7f?raw)
