---
title: "Add a new campaign"
method: POST
path: "/campaigns"
tags: ["campaigns"]
---

# Add a new campaign

`POST /campaigns`

Add a new campaign. When the campaign is firstly created, it has a `draft` status. 
After a campaign has been created it can either be sent, scheduled or deleted. In order to send a campaign you will need to connect your AWS account.

## Request body

- object
  - `name` string, required — The name of the new campaign, must be unique.
  - `template_name` string, required — The name of the template to be used for the campaign content.

## Response `201`

OK

- Campaign
  - `id` integer — The ID of the resource.
  - `created_at` string, date-time — The date and time when the resource was created.
  - `updated_at` string, date-time — The date and time when the resource was last updated.
  - `name` string — The name of the campaign.
  - `status` 'draft' | 'scheduled' | 'sending' | 'sent' — The campaign's status.
  - `template` BaseTemplate
    - `id` integer — The ID of the resource.
    - `created_at` string, date-time — The date and time when the resource was created.
    - `updated_at` string, date-time — The date and time when the resource was last updated.
    - `name` string — The name of the template.
    - `subject_part` string — The subject part.
  - `schedule` CampaignSchedule
    - `id` string — The ID of the resource.
    - `scheduled_at` string, date-time — The date and time when the campaign is scheduled to be sent.
    - `created_at` string, date-time — The date and time when the resource was created.
    - `updated_at` string, date-time — The date and time when the resource was last updated.
  - `started_at` string, date-time — The date and time when the campaign was started.
  - `completed_at` string, date-time — The date and time when the campaign was completed (the e-mail has been sent to all of the subscribers).

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `422` — Unprocessable entity
- `default` — Unexpected error

## Changes

- **2021-11-30** `17c65a731b7b` — 2 warning
  - removed the optional property `allOf[subschema #2]/template/anyOf[#/components/schemas/BaseTemplate]/allOf[subschema #2]/user_id` from the response with the `201` status
  - removed the optional property `allOf[subschema #2]/user_id` from the response with the `201` status
- **2021-11-27** `75b3657b756c` — 1 breaking, 1 info
  - removed the media type `application/x-www-form-urlencoded` from the request body
  - added the media type `application/json` to the request body
- **2021-06-15** `4a5e5935c381` — 1 info
  - endpoint added
- **2021-05-18** `c686bd33a4a5` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/mailbadger/apis/mailbadger-api/changes/campaigns/post.md)

---

[API](https://skmtc.dev/mailbadger/apis/mailbadger-api.md) · [All operations](https://skmtc.dev/mailbadger/apis/mailbadger-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/mailbadger/mailbadger-api/revisions/3a7ef49250a1/schema)
