# Create Email Campaign

POST /api/v2/projects/{projectId}/email-campaigns

Creates a campaign together with its first message (subject, body, sender) in one transaction. New campaigns always start as a DRAFT. Creating one never sends anything. Define the audience with `contactListId`, `contactsFilterGroups`, or both; set `type` to `AB_TEST` and supply `abTestConfig` for a split test.

## Request

- projectId: string, path, required — Project that owns the campaign.
- name: string, required — Campaign name shown in the dashboard and reports.
- abTestConfig: object — A/B test settings. Only used when type is AB_TEST; omit for a standard campaign.
  - variable: SUBJECT | FROM_NAME | CONTENT | SEND_TIME, required — What differs across variants: subject, from name, content, or send time.
  - samplePaginationEnd: integer — Send cursor at the end of the sample phase. Set by the runtime.
  - samplePercent: number, default 20 — Percent of the audience that receives the sample variants.
  - sendTimeDelayHours: number, default 2 — Delay between sample sends when variable is SEND_TIME.
  - sendTimeDelayUnit: HOURS | MINUTES, default HOURS — Unit for sendTimeDelayHours.
  - status: AWAITING_SAMPLE | AWAITING_WINNER | ROLLED_OUT, default AWAITING_SAMPLE — A/B test phase. Omit on create; the runtime advances this.
  - winnerMessageId: string — Winning message id. Set by the runtime after the test resolves.
  - winnerMetric: OPEN_RATE | CLICK_RATE, default OPEN_RATE — Metric used to pick the winning variant.
  - winnerRolloutAt: string — ISO timestamp when the winner was rolled out to the rest of the list.
  - winnerSelectedAt: string — ISO timestamp when the winner was selected.
  - winnerWaitHours: number, default 4 — How long to wait after the sample before picking a winner.
  - winnerWaitStartedAt: string — ISO timestamp when the winner-wait countdown started.
  - winnerWaitUnit: HOURS | MINUTES, default HOURS — Unit for winnerWaitHours.
- bcc: string — BCC address applied to e
…

## Response

- 200: Successful response
  - contactsFilterGroups: object[], required
    - filters: object[], required — Attribute filters combined with groupType.
    - groupType: AND | OR | NOT, required — How filters in this group are combined.
    - oneDayEventFilters: object[] — Event filters evaluated over the last 24 hours only.
    - requireSubscribed: boolean — When true, the group is ANDed with `$subscribed == true`. Set by email sending, not the filter UI.
  - createdAt: string, required
  - id: string, required
  - messages: object[], required
    - bodyHTML: string, required
    - bodyJSON: object, required
    - createdAt: string, required
    - emailCampaignId: string, required
    - fromDomain: string, required
    - fromEmailUsername: string, required
    - fromName: string, required
    - id: string, required
    - label: string, required
    - previewTextHTML: string, required
    - previewTextJSON: object, required
    - projectId: string, required
    - sendCount: integer, required, default 0
    - subjectHTML: string, required
    - subjectJSON: object, required
    - text: string, required
    - theme: object, required
    - updatedAt: string, required
    - bcc: string
    - cc: string
    - lastSuccessContactCreatedAt: string
    - lastSuccessContactId: string
    - replyTo: string
    - scheduledAt: string
    - …
  - name: string, required
  - projectId: string, required
  - sendCount: integer, required, default 0
  - sendPaginationCount: integer, required, default 0
  - status: DRAFT | SCHEDULED | SENDING | SENT | PAUSED | CANCELLED, required
  - type: STANDA
…
