# Draft a campaign

> Create a campaign draft with its brief. Nobody sees a draft until publish_campaign makes it live, so the person can review it first. Takes productId, or product to add a new one.

```http
POST https://yapfactory.com/api/v1/campaigns
```

|   |   |
| --- | --- |
| Who can use it | Brands |
| Tier | `write`: Changes your own things only. Nobody else is told. |
| Scope | `campaigns:write`, or `write` |
| Idempotency-Key | Optional, and recommended |
| Rate limit | Writes: 20 a minute |
| MCP tool | [`create_campaign_draft`](https://yapfactory.com/developers/tools.md#create_campaign_draft) |

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `productId` | body | `uuid` | no | From list_products. |
| `product` | body | `object` | no | A new product, when productId isn't given. |
| `product.name` | body | `string` | yes | The product's name. 1 to 80 characters. |
| `product.url` | body | `url` | no | App Store, Play Store or website link. Up to 500 characters. |
| `product.platform` | body | `"ios" \| "android" \| "web"` | yes | Where people use it. |
| `product.description` | body | `string` | no | What it is and who it's for. Up to 2000 characters. |
| `title` | body | `string` | yes | The campaign's name, as creators see it. 3 to 100 characters. |
| `template` | body | `"one_video" \| "test_openings" \| "ad_bundle"` | no | one_video: 1 video for your own channels. test_openings: 1 video with 3 openings. ad_bundle: 3 videos you can run as ads for 3 months. Default `"one_video"`. |
| `videos` | body | `integer` | no | Videos per creator (overrides the template). 1 to 20. |
| `adRights` | body | `"organic" \| "paid_3m" \| "paid_6m" \| "paid_12m" \| "paid_forever"` | no | organic = your own channels, no ads. paid_*: how long you can run it as an ad. |
| `targetCountries` | body | `("GB" \| "US" \| "IE" \| "CA" \| "AU")[]` | no | Where the creators' audiences should be. Left out: your own country. 1 to 5 items. |
| `lengthSeconds` | body | `15 \| 30 \| 60` | no | How long each video runs. Default `30`. |
| `deadline` | body | `date` | no | yyyy-mm-dd, at least 5 days away. Default: the template's (2-3 weeks). |
| `brief` | body | `object` | yes |  |
| `brief.keyMessage` | body | `string` | no | What the video must get across. Leave out to let the creator decide. Up to 600 characters. |
| `brief.hooks` | body | `string[]` | no | Opening lines to try. Leave out to let the creator decide. Up to 5 items. |
| `brief.cta` | body | `string` | no | Closing call to action. Leave out to let the creator decide. Up to 200 characters. |
| `brief.dos` | body | `string[]` | no | Things the video should do. Up to 8 items. |
| `brief.donts` | body | `string[]` | no | Things it must not do or say. Up to 8 items. |
| `brief.exampleVideoUrl` | body | `url` | no | A video in the style you want. Up to 500 characters. |

## What a draft gets

- **Price.** There's no price to set. Each creator sets their own rate per video, and you see it in [`GET /creators`](https://yapfactory.com/developers/api/search_creators.md) before you invite anyone. Ad rights are priced by each creator too.
- **Revisions.** Every deal includes 3 rounds of changes.
- **Disclosure.** Videos are marked `#ad`.
- **Set on the site, not here:** exclusivity, a rush deadline, bonuses, raw footage and cut-downs. The draft's `review` link opens the page where the person can change them before publishing.

## Example request

```bash
curl -X POST "https://yapfactory.com/api/v1/campaigns" \
  -H "Authorization: Bearer $YAP_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "8f14e45f-ceea-4e7a-9b1d-2c3b4a5d6e7f",
    "title": "Morning routine with Sleepwell",
    "template": "one_video",
    "lengthSeconds": 30,
    "brief": {
      "keyMessage": "Sleepwell helps you fall asleep in 10 minutes without your phone.",
      "hooks": [
        "I used to scroll until 2am."
      ],
      "cta": "Try it free tonight."
    }
  }'
```

## Response

`201` with the result in `data`: the same object the MCP tool returns.

```json
{
  "data": {
    "campaignId": "8f14e45f-ceea-4e7a-9b1d-2c3b4a5d6e7f",
    "status": "draft",
    "review": "https://yapfactory.com/brand/campaigns/8f14e45f-ceea-4e7a-9b1d-2c3b4a5d6e7f/edit",
    "next": "Show the person the draft (get_campaign), then publish_campaign when they're happy."
  }
}
```

An example: fields that don't apply are `null`, and new fields can be added at any time, so ignore ones you don't know. Every response carries `Request-Id` and the `RateLimit-*` headers.

## Errors

| Code | Status | When |
| --- | --- | --- |
| `invalid_request` | 400 | A field failed validation (see `meta.issues`), or an unknown query parameter. |
| `unauthorized` | 401 | No token, or it's wrong, expired, revoked or from the other environment. |
| `insufficient_scope` | 403 | The token doesn't have `campaigns:write` (or `write`). |
| `forbidden` | 403 | Only for brands, or the account can't do this yet (email not confirmed, paused). |
| `conflict` | 409 | Its current state doesn't allow this. `message` says why, in words you can show. |
| `idempotency_conflict` | 409 | The same `Idempotency-Key` came with a different body. |
| `rate_limited` | 429 | Over the limit. Wait for `Retry-After` seconds. |
| `internal` | 500 | Our fault. Retry later, and send us the `requestId` if it keeps happening. |

Every error has the same shape. See [Errors](https://yapfactory.com/developers/errors.md) for what to do about each one.

---

HTML version: https://yapfactory.com/developers/api/create_campaign_draft
