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

<br>

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

#### cURL Example

```bash
curl -X POST https://www.tabbly.io/dashboard/agents/endpoints/create-campaign \
  -H "Content-Type: application/json" \
  -d '{
    "campaign_name": "Test Campaign",
    "agent_id": your_agent_id_here,
    "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",
    "created_by": 1
  }'
```

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tabbly.gitbook.io/tabbly-docs/create-campaign.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
