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

# Create Campaign

> Create a new outreach campaign

## Request

### Headers

```
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
```

### Body Parameters

<ParamField body="name" type="string" required>
  Campaign name
</ParamField>

<ParamField body="list_id" type="string" required>
  UUID of the target contact list
</ParamField>

<ParamField body="template" type="string" required>
  Email template text (supports variables: `{{name}}`, `{{company}}`, `{{title}}`)
</ParamField>

## Response

<ResponseField name="data" type="object">
  The created campaign object

  <Expandable title="Campaign properties">
    <ResponseField name="id" type="string">
      Campaign UUID
    </ResponseField>

    <ResponseField name="name" type="string">
      Campaign name
    </ResponseField>

    <ResponseField name="status" type="string">
      Campaign status (`draft`)
    </ResponseField>

    <ResponseField name="list_id" type="string">
      Target list UUID
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO 8601 timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    https://data.leadlex.com/functions/v1/api-gateway/v1/campaigns \
    -H "Authorization: Bearer wbk_your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Q2 Outreach",
      "list_id": "list-uuid-here",
      "template": "Hi {{name}}, I noticed your work at {{company}}..."
    }'
  ```

  ```python Python theme={null}
  import requests

  API_KEY = "wbk_your_api_key_here"
  BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"

  headers = {
      "Authorization": f"Bearer {API_KEY}",
      "Content-Type": "application/json"
  }

  data = {
      "name": "Q2 Outreach",
      "list_id": "list-uuid-here",
      "template": "Hi {{name}}, I noticed your work at {{company}}..."
  }

  response = requests.post(f"{BASE_URL}/v1/campaigns", headers=headers, json=data)
  campaign = response.json()["data"]
  print(f"Created campaign: {campaign['id']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://data.leadlex.com/functions/v1/api-gateway/v1/campaigns',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer wbk_your_api_key_here',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Q2 Outreach',
        list_id: 'list-uuid-here',
        template: 'Hi {{name}}, I noticed your work at {{company}}...'
      })
    }
  );

  const { data } = await response.json();
  console.log(`Created campaign: ${data.id}`);
  ```
</CodeGroup>

### Example Response

```json theme={null}
{
  "data": {
    "id": "new-campaign-uuid",
    "name": "Q2 Outreach",
    "status": "draft",
    "list_id": "list-uuid-here",
    "created_at": "2026-02-24T16:00:00Z"
  }
}
```

## Template Variables

Use these variables in your template to personalize emails:

| Variable        | Description          | Example    |
| --------------- | -------------------- | ---------- |
| `{{name}}`      | Contact's first name | John       |
| `{{full_name}}` | Contact's full name  | John Smith |
| `{{company}}`   | Company name         | Acme Corp  |
| `{{title}}`     | Job title            | CEO        |

### Example Template

```
Hi {{name}},

I noticed you're the {{title}} at {{company}}. I wanted to reach out because...

Best regards,
Your Name
```

## Next Steps

After creating a campaign:

1. Review the draft in your dashboard
2. Use the [Start Campaign](/api-reference/campaigns/start) endpoint to launch it
3. Or send it to Lexi AI for automated optimization

## Errors

| Status | Code                       | Description                                |
| ------ | -------------------------- | ------------------------------------------ |
| 400    | `validation_error`         | Missing required fields or invalid list ID |
| 401    | `invalid_key`              | Invalid API key                            |
| 403    | `insufficient_permissions` | Missing `write` permission                 |
| 404    | `not_found`                | List not found                             |
| 429    | `rate_limited`             | Rate limit exceeded                        |
