---
title: "Create a campaign"
method: POST
path: "/api/v1/campaigns"
tags: ["Campaigns"]
---

# Create a campaign

`POST /api/v1/campaigns`

## Request

- Base URL: `https://api.sendly.now`
- URL: `https://api.sendly.now/api/v1/campaigns`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `better-auth.session_token`
  - OAuth 2 (authorization code, authorization URL `https://app.sendly.now/api/auth/oauth2/authorize`, token URL `https://app.sendly.now/api/auth/oauth2/token`, scopes: `campaigns:write`)

Create a campaign in `DRAFT`. Creating never sends — `POST /api/v1/campaigns/{id}/send` is the only operation that puts mail on the wire — so a campaign can be built up and reviewed before it costs anything.

The `from` address is checked against this project's verified domains before the campaign is written, so a campaign never exists with a sender it cannot use.

`segment_id` is required when `audience_type` is `SEGMENT`; `audience_condition` is required when it is `FILTERED`. Both answer 422 when missing.

`audience_condition` is checked when the campaign is written: a filter on a field contacts cannot be filtered on, or an operator that field does not have, answers 400 naming it. A list is not a filter field — to mail a list, send `audience_type: "LIST"` with a top-level `list_id`.

Requires the `campaigns:write` scope — Create, edit, and organize your campaigns.

## Headers

- `Idempotency-Key` string: Replay-safety key (24h TTL). Reuse it only to retry the identical request.

## Request body

- CampaignV1Create: Body for POST /api/v1/campaigns. `segment_id` is required when `audience_type` is `SEGMENT`, `audience_condition` when it is `FILTERED`, and `list_id` when it is `LIST`.
  - `audience_condition` FilterConditionV1: A filter condition: one or more groups combined with `logic`.
    - `groups` FilterGroupV1[], required
      - `conditions` FilterConditionV1 (recursive)
      - `filters` SegmentFilterV1[], required
        - `field` string, required
        - `operator` 'equals' | 'notEquals' | 'contains' | 'notContains' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'exists' | 'notExists' | 'within' | 'olderThan' | 'triggered' | 'triggeredWithin' | 'triggeredOlderThan' | 'notTriggered' | 'notTriggeredWithin' | 'isMemberOf', required
        - `unit` 'days' | 'hours' | 'minutes'
        - `value` unknown
    - `logic` 'AND' | 'OR', required
  - `audience_type` 'ALL' | 'FILTERED' | 'SEGMENT' | 'LIST', required: `ALL` — every subscribed contact. `FILTERED` — the contacts matching `audience_condition`. `SEGMENT` — the members of `segment_id`. `LIST` — the CONFIRMED members of `list_id`, which is the only audience that honours double opt-in: a member who never confirmed, or who unsubscribed, is not mailed.
  - `body` string, required
  - `description` string
  - `email_category` 'TRANSACTIONAL' | 'MARKETING' | 'SELF_MANAGED_UNSUBSCRIBE'
  - `from` string, email, required: Sender address. Its domain must be verified for this project.
  - `from_name` string, nullable
  - `list_id` string, uuid: Required when `audience_type` is `LIST`. Only that list's CONFIRMED members receive the campaign.
  - `name` string, required
  - `reply_to` string, email, nullable
  - `segment_id` string, uuid
  - `subject` string, required
  - `topic_id` string, uuid, nullable: The subject this campaign is about. A contact who unsubscribed from the topic is excluded WHATEVER the audience type — a topic opt-out is a standing answer, not an audience filter, so it cannot be routed around by selecting a different audience. Ignored for `TRANSACTIONAL` campaigns, which a marketing preference does not cancel.

## Response `201`

Campaign created

- CampaignV1: A campaign as exposed on the v1 API.
  - `audience_type` 'ALL' | 'FILTERED' | 'SEGMENT' | 'LIST', required
  - `created_at` string, date-time, required
  - `id` string, uuid, required
  - `list_id` string, uuid, nullable, required
  - `name` string, required
  - `scheduled_at` string, date-time, nullable, required
  - `sent_at` string, date-time, nullable, required
  - `stats` object, required
    - `bounced` integer, required
    - `clicked` integer, required
    - `delivered` integer, required
    - `opened` integer, required
    - `sent` integer, required
    - `total_recipients` integer, required
  - `status` 'DRAFT' | 'SCHEDULED' | 'SENDING' | 'PAUSED' | 'SENT' | 'CANCELLED', required
  - `subject` string, required
  - `topic_id` string, uuid, nullable, required

## Other responses

- `400`: `validation_error` — `audience_condition` filters on a field contacts cannot be filtered on, or uses an operator that field does not have. A list is not a filter field: use `audience_type: "LIST"` with `list_id`.
- `401`: `invalid_api_key` or `invalid_session` — missing or invalid credentials.
- `403`: `scope_missing`, `project_access_denied`, or `project_disabled`.
- `404`: `resource_not_found` — `segment_id` names a segment that does not belong to this project.
- `409`: `conflict` — a request with this `Idempotency-Key` is still in flight. Retry shortly.
- `422`: `validation_error` — the request did not match the schema; or `idempotency_key_reused` — this `Idempotency-Key` was already spent on a request with a different body. A key names ONE request, so it is never silently served another one's result: send a new key.
- `429`: `rate_limited` — see `Retry-After` and the `RateLimit` headers.
- `500`: `internal_error`.

---

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