# Create Campaign

## Campaign Creation API

### Overview

This API endpoint enables the programmatic creation of voice agent campaigns within the automation system. It handles necessary validations and returns the campaign ID upon success.

### Endpoint

```
POST https://www.tabbly.io/dashboard/agents/endpoints/create-campaign
```

### Authentication

Include your API key in the request body for authentication.





\


### Request Format

Submit data in JSON format with these required parameters:

| Parameter           | Type    | Description                                              |
| ------------------- | ------- | -------------------------------------------------------- |
| `api_key`           | String  | Your organization's unique API key                       |
| `campaign_name`     | String  | Name of the campaign                                     |
| `agent_id`          | Integer | ID of the voice agent for the campaign                   |
| `start_time`        | String  | Campaign start time in 24-hour format (HH:MM)            |
| `end_time`          | String  | Campaign end time in 24-hour format (HH:MM)              |
| `time_zone`         | String  | Time zone code (e.g., "IST", "UTC", "EST")               |
| `custom_first_line` | String  | Custom first line for the agent script ex: hello ramesh" |

### Supported Time Zones

* `IST`, `UTC`, `GMT`, `EST`, `PST`, `CST`, `MST`, `AST`, `PKT`, `BST`
* `ICT`, `JST`, `KST`, `AEST`, `ACST`, `AWST`, `NZST`, `SST`, `HAST`
* `AKST`, `WET`, `CET`, `EET`, `MSK`, `NST`

### Example Request

#### JSON Payload

```json
{
  "api_key": "your_api_key_here",
  "campaign_name": "March Sales Outreach",
  "agent_id": 123,
  "start_time": "09:00",
  "end_time": "17:00",
  "time_zone": "EST",
  "custom_first_line": "Hello, I'm calling from ABC Company regarding your recent inquiry."
}
```

#### cURL Example

```bash
curl -X POST https://www.tabbly.io/dashboard/endpoints/create-campaign \
  -H "Content-Type: application/json" \
  -d '{
    "campaign_name": "Test Campaign",
    "agent_id": 123,
    "start_time": "09:00",
    "end_time": "18:00",
    "time_zone": "IST",
    "custom_first_line": "Hello, this is a test campaign.",
    "api_key": "YOUR_API_KEY_HERE"
  }'
```

### Response Format

#### Success Response

```json
{
  "status": "success",
  "data": {
    "campaign_id": 456
  }
}
```

HTTP Status Code: 200 OK

#### Error Responses

```json
{
  "status": "error",
  "message": "Error message details"
}
```

HTTP Status Code: 400 Bad Request, 401 Unauthorized, or 405 Method Not Allowed

### Error Codes

| Status Code | Description                                          |
| ----------- | ---------------------------------------------------- |
| 400         | Bad Request - Missing fields or invalid data format  |
| 401         | Unauthorized - Invalid API key                       |
| 405         | Method Not Allowed - Only POST requests are accepted |

### Notes

1. Campaign is created with an "Active" status by default.
2. Handles time zone conversions, storing all times in UTC.
3. End time earlier than start time implies next day.
4. Voice agent must be part of your organization.
5. API-marked contact lists are labeled "Uploaded".

### Limitations

1. Endpoint creates campaign structure only, returning the ID.
2. Separate API call required to add contacts (not covered here).
3. Only accepts POST requests; other methods are rejected.
