> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcluster.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and launch a campaign

> Build a draft, add its leads and start sending.

## 1. Pick the senders

```bash theme={null}
curl "https://api.getcluster.ai/v1/sender-schedules" \
  -H "Authorization: Bearer $CLUSTER_API_KEY"
```

Take the `sender_id` of each LinkedIn account or inbox the campaign should send from. If the one you need is not on the first page, pass `next_cursor` as `cursor` to read the next: see [Pagination](https://docs.getcluster.ai/pagination.md). A campaign needs a sender for every channel its steps use.

## 2. Create the draft

```bash theme={null}
curl -X POST https://api.getcluster.ai/v1/campaigns \
  -H "Authorization: Bearer $CLUSTER_API_KEY" \
  -H "Idempotency-Key: create-q1-founders" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Q1 founders",
    "linkedin_sender_ids": ["…"],
    "email_sender_ids": ["…"],
    "sequence": {
      "steps": [
        { "type": "connection_request", "body": "Hi {{first_name}}, good to meet you." },
        { "type": "message", "body": "Thanks for connecting, {{first_name}}.", "wait_days": 2 },
        { "type": "email", "subject": "Quick idea", "body": "Hi {{first_name}}, ...", "wait_days": 3 }
      ]
    }
  }'
```

The response is the campaign, with `status` set to `draft`. A draft sends nothing.

How a sequence works:

* Steps run in the order you list them. A sequence holds 1 to 10 steps.
* `type` is `connection_request`, `message` (a LinkedIn message), `email`, `profile_visit` or `like_post`.
* `wait_days` is how long to wait after the previous step. The first step takes 0.
* A LinkedIn message after a connection request waits until the lead accepts.
* The first email needs a `subject`. A later email without one is sent as a reply in the same thread.
* `body` is the message text, or the optional note on a connection request. A message or an email needs one. Profile visits and post likes take none.
* Write `{{first_name}}` and other variables in double braces. Each lead's `custom_variables` fill your own.
* When a lead replies, the sequence stops for that lead.

Sequences with branches, such as a different path when a connection request is not accepted, are built in the app.

The `Idempotency-Key` header is optional here. With it, a retry returns the campaign the first call created. Without it, a retry creates a second draft.

## 3. Change the sequence

```bash theme={null}
curl -X PUT https://api.getcluster.ai/v1/campaigns/$CAMPAIGN_ID/sequence \
  -H "Authorization: Bearer $CLUSTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "steps": [ { "type": "email", "subject": "Quick idea", "body": "Hi {{first_name}}, ..." } ] }'
```

This replaces every step with the list you send and returns the saved sequence. It works on drafts only: a launched campaign returns `409 conflict`.

## 4. Add leads

Add leads with `POST /campaigns/{id}/leads`, as in [Push leads into a campaign](https://docs.getcluster.ai/guides/push-leads.md). A draft keeps them on its list until it launches.

## 5. Launch

```bash theme={null}
curl -X POST https://api.getcluster.ai/v1/campaigns/$CAMPAIGN_ID/launch \
  -H "Authorization: Bearer $CLUSTER_API_KEY" \
  -H "Idempotency-Key: launch-q1-founders"
```

Launching enrolls the leads and starts sending in each sender's next sending window. To let the first step go out at once, send `{"send_window_mode": "start_now"}` as the body.

* The `Idempotency-Key` header is required. Sending the same key again returns the campaign as it is now and launches nothing.
* `409 conflict` means the campaign was already launched, or is paused, completed or archived. Read its `status`.
* `400 bad_request` means something is missing, such as a sender for a channel the steps use, or leads. The message says what.
* Check the returned `status`. A launch can be paused straight away, for example when some leads cannot be reached, with the reason in `paused_reason`.

Stop and restart sending with `POST /campaigns/{id}/pause` and `/resume`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.