# createCampaign

Mutation

Create a campaign of a given campaignType in the current workspace. Idempotent on externalId.

Available to agents as MCP tool `createCampaign` — see [Write tools](/api/v2/docs/mcp/write-tools#create-campaign).

## Arguments

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `input` | [`CreateCampaignInput!`](/api/v2/docs/types/create-campaign-input) | Yes | — | Mutation input. |

## Returns

| Name | Type | Description |
| --- | --- | --- |
| `campaign` | [`Campaign`](/api/v2/docs/types/campaign) | The campaign for this externalId: new, or the existing one on a repeat. Null on validation failure. |
| `userErrors` | [`[UserError!]!`](/api/v2/docs/types/user-error) | List of user-facing validation errors. Empty on success. |

## Examples

### Create a campaign

Create a Content Capture campaign with a stable external key and UTC window.

```graphql
mutation CreateCampaignDefault($input: CreateCampaignInput!) {
  createCampaign(input: $input) {
    campaign {
      id
      name
      campaignType
      externalId
      dateStart
      dateEnd
      creatorsCount
    }
    userErrors {
      field
      message
    }
  }
}
```

Variables:

```json
{
  "input": {
    "campaignType": "CONTENT_CAPTURE",
    "externalId": "docs:campaign:spring-launch",
    "name": "Spring Launch API",
    "dateStart": "2025-01-01T00:00:00Z",
    "dateEnd": "2025-03-31T23:59:59Z"
  }
}
```

Response — HTTP 200:

```json
{
  "data": {
    "createCampaign": {
      "campaign": {
        "id": "aef14a46-923c-56cd-bb59-e7efa9f2c0fc",
        "name": "Spring Launch API",
        "campaignType": "CONTENT_CAPTURE",
        "externalId": "docs:campaign:spring-launch",
        "dateStart": "2025-01-01T00:00:00Z",
        "dateEnd": "2025-03-31T23:59:59Z",
        "creatorsCount": 0
      },
      "userErrors": []
    }
  }
}
```
