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

# Start Campaign

> Start campaign execution immediately using Celery background tasks.

Start campaign execution. The campaign will begin contacting contacts based on the configured schedule.

### Path Parameters

* `campaign_id` (integer, required): The unique identifier of the campaign

### Prerequisites

Before starting a campaign, ensure:

* Campaign has at least one contact imported
* Campaign status is `draft`, `scheduled`, or `paused`
* Associated assistant is properly configured

### Behavior

* **Immediate schedule**: Execution begins immediately
* **Scheduled**: Execution is queued for the scheduled time
* **Paused campaigns**: Resume execution from where it stopped

### Response

```json Response (Immediate Start) theme={null}
{
  "success": true,
  "message": "Campaign execution started immediately",
  "task_id": "abc123-def456",
  "campaign_id": 42,
  "status": "scheduled"
}
```

```json Response (Scheduled) theme={null}
{
  "success": true,
  "message": "Campaign scheduled for 2024-02-15 09:00:00 UTC",
  "task_id": "abc123-def456",
  "campaign_id": 42,
  "status": "scheduled",
  "scheduled_time": "2024-02-15T09:00:00Z"
}
```

### Response Fields

| Field            | Description                                         |
| ---------------- | --------------------------------------------------- |
| `success`        | Whether the operation succeeded                     |
| `message`        | Human-readable status message                       |
| `task_id`        | Background task identifier for tracking             |
| `campaign_id`    | The campaign ID                                     |
| `status`         | New campaign status                                 |
| `scheduled_time` | When execution will begin (for scheduled campaigns) |

### Example Code

```bash cURL theme={null}
curl -X POST "https://api.burki.dev/api/v1/campaigns/42/start" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

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

response = requests.post(
    "https://api.burki.dev/api/v1/campaigns/42/start",
    headers={"Authorization": "Bearer YOUR_API_KEY"}
)

result = response.json()
if result["success"]:
    print(f"Campaign started! Task ID: {result['task_id']}")
else:
    print(f"Error: {result}")
```

```javascript JavaScript theme={null}
const response = await fetch("https://api.burki.dev/api/v1/campaigns/42/start", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY"
  }
});

const result = await response.json();
if (result.success) {
  console.log(`Campaign started! Task ID: ${result.task_id}`);
} else {
  console.error("Error:", result);
}
```

### Error Responses

| Status Code | Description                                           |
| ----------- | ----------------------------------------------------- |
| 400         | Cannot start campaign - invalid status or no contacts |
| 400         | Scheduled time is in the past                         |
| 404         | Campaign not found                                    |
| 500         | Background task system unavailable                    |

### Common Error Messages

| Error                                      | Solution                            |
| ------------------------------------------ | ----------------------------------- |
| "No contacts found"                        | Import contacts before starting     |
| "All contacts have already been processed" | Use re-execute endpoint to retry    |
| "Campaign is not running"                  | Campaign is already in wrong status |
| "Scheduled time is in the past"            | Update schedule to future time      |


## OpenAPI

````yaml POST /api/v1/campaigns/{campaign_id}/start
openapi: 3.1.0
info:
  title: Burki
  description: A system that uses AI to answer customer Calls.
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/campaigns/{campaign_id}/start:
    post:
      tags:
        - campaigns
      summary: Start Campaign Execution
      description: Start campaign execution immediately using Celery background tasks.
      operationId: start_campaign_execution_api_v1_campaigns__campaign_id__start_post
      parameters:
        - name: campaign_id
          in: path
          required: true
          schema:
            type: integer
            title: Campaign Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````