> ## 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.

# Save Campaign Schedule

> Create or update a campaign schedule.

Create or update the schedule for a campaign. Setting a schedule automatically updates the campaign status.

### Path Parameters

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

### Request Body

| Field              | Type   | Required    | Description                                  |
| ------------------ | ------ | ----------- | -------------------------------------------- |
| `schedule_type`    | string | Yes         | `immediate`, `scheduled`, or `recurring`     |
| `scheduled_at`     | string | Conditional | ISO 8601 datetime (required for `scheduled`) |
| `timezone`         | string | No          | Timezone for scheduling (default: UTC)       |
| `recurring_config` | object | Conditional | Required for `recurring` type                |

### Schedule Types

<Accordion title="Immediate">
  Campaign starts when you call the start endpoint.

  ```json Request theme={null}
  {
    "schedule_type": "immediate"
  }
  ```

  **Effect**: Campaign status remains `draft` until started manually.
</Accordion>

<Accordion title="Scheduled (Once)">
  Campaign runs at a specific date and time.

  ```json Request theme={null}
  {
    "schedule_type": "scheduled",
    "scheduled_at": "2024-02-15T09:00:00",
    "timezone": "America/New_York"
  }
  ```

  **Effect**: Campaign status changes to `scheduled` automatically.
</Accordion>

<Accordion title="Recurring">
  Campaign runs on a repeating schedule.

  ```json Request theme={null}
  {
    "schedule_type": "recurring",
    "scheduled_at": "2024-02-15T09:00:00",
    "timezone": "America/New_York",
    "recurring_config": {
      "frequency": "weekly",
      "interval": 1,
      "days_of_week": [1, 2, 3, 4, 5],
      "time": "09:00",
      "time_zone": "America/New_York",
      "end_date": "2024-12-31"
    }
  }
  ```

  **Effect**: Campaign status changes to `scheduled` automatically.
</Accordion>

### Recurring Config Options

| Field          | Type    | Description                           |
| -------------- | ------- | ------------------------------------- |
| `frequency`    | string  | `daily`, `weekly`, or `monthly`       |
| `interval`     | integer | Every N periods (e.g., every 2 weeks) |
| `days_of_week` | array   | Days for weekly (1-7, Monday=1)       |
| `day_of_month` | integer | Day for monthly (1-31)                |
| `time`         | string  | Time in 24-hour format (HH:MM)        |
| `time_zone`    | string  | Timezone (e.g., `America/New_York`)   |
| `end_date`     | string  | Stop date (ISO 8601)                  |

### Response

```json Response theme={null}
{
  "success": true,
  "message": "Schedule saved"
}
```

### Example Code

```bash cURL theme={null}
# Immediate schedule
curl -X POST "https://api.burki.dev/api/v1/campaigns/42/schedule" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"schedule_type": "immediate"}'

# Scheduled for specific time
curl -X POST "https://api.burki.dev/api/v1/campaigns/42/schedule" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "schedule_type": "scheduled",
    "scheduled_at": "2024-02-15T09:00:00",
    "timezone": "America/New_York"
  }'
```

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

# Schedule for a specific time
response = requests.post(
    "https://api.burki.dev/api/v1/campaigns/42/schedule",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "schedule_type": "scheduled",
        "scheduled_at": "2024-02-15T09:00:00",
        "timezone": "America/New_York"
    }
)

print(response.json()["message"])

# Set up weekly recurring schedule
response = requests.post(
    "https://api.burki.dev/api/v1/campaigns/42/schedule",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "schedule_type": "recurring",
        "scheduled_at": "2024-02-15T09:00:00",
        "timezone": "America/New_York",
        "recurring_config": {
            "frequency": "weekly",
            "interval": 1,
            "days_of_week": [1, 2, 3, 4, 5],  # Monday-Friday
            "time": "09:00",
            "time_zone": "America/New_York",
            "end_date": "2024-12-31"
        }
    }
)
```

```javascript JavaScript theme={null}
// Schedule for a specific time
const response = await fetch("https://api.burki.dev/api/v1/campaigns/42/schedule", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    schedule_type: "scheduled",
    scheduled_at: "2024-02-15T09:00:00",
    timezone: "America/New_York"
  })
});

const result = await response.json();
console.log(result.message);
```

### Behavior

* **Immediate**: Clears any existing schedule, reverts to `draft` if `scheduled`
* **Scheduled/Recurring**: Creates schedule record, sets campaign to `scheduled`
* **Past times**: Returns 400 error - time must be in the future

### Error Responses

| Status Code | Description                    |
| ----------- | ------------------------------ |
| 400         | Scheduled time is in the past  |
| 400         | Invalid schedule configuration |
| 404         | Campaign not found             |
| 500         | Failed to save schedule        |

### Timezone Support

Common timezone values:

| Region         | Timezone              |
| -------------- | --------------------- |
| US Eastern     | `America/New_York`    |
| US Central     | `America/Chicago`     |
| US Mountain    | `America/Denver`      |
| US Pacific     | `America/Los_Angeles` |
| UK             | `Europe/London`       |
| Central Europe | `Europe/Paris`        |
| UTC            | `UTC`                 |

<Callout type="warning">
  Always specify timezone when scheduling. If omitted, the system uses UTC which may not match your intended local time.
</Callout>


## OpenAPI

````yaml POST /api/v1/campaigns/{campaign_id}/schedule
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}/schedule:
    post:
      tags:
        - campaigns
      summary: Save Campaign Schedule
      description: Create or update a campaign schedule.
      operationId: save_campaign_schedule_api_v1_campaigns__campaign_id__schedule_post
      parameters:
        - name: campaign_id
          in: path
          required: true
          schema:
            type: integer
            title: Campaign Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              title: Schedule Data
      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

````