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

# Create Campaign

> Create a voice, video or web chat campaign without uploading contacts.

## Overview

Create an empty campaign that you add contacts to later, for example with [Add Calls to Campaign](https://docs.weya.ai/api-reference/Campaigns/addCallsToBatch.md). The fields you send depend on `channel_type`:

* **`voice`** (default) – an outbound calling campaign. Send the calling numbers and schedule.
* **`video`** – a video agent campaign. Send `videoAgentId`. The response includes the link people use to join.
* **`web_chat`** – a chat widget campaign. Send `chatAgentId` and `allowedDomains`. The response includes the script tag to embed.

To create a voice campaign and upload contacts in one step, use [Upload Campaign CSV](https://docs.weya.ai/api-reference/Campaigns/uploadCSV.md) instead.

## Prerequisites

* An API key for your workspace
* For voice: at least one phone number with an outbound agent assigned. The agent is needed when you add contacts.
* For video or web chat: a video or chat agent created by the user who owns the API key. A chat agent (and the optional voice agent) must have at least one saved version.

## Endpoint

**/api/call/createBatch**

## Request

**x-api-key** `string` *required*

Your workspace API key. Create one from the profile menu in the dashboard → **API Keys**.

```bash cURL (voice) theme={null}
curl --location 'https://api.weya.live/backend/api/call/createBatch' \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "channel_type": "voice",
    "batchName": "API Campaign May 2025",
    "callingNumbers": ["64e5f12345abcdef87654321"],
    "retry": 3,
    "delay": 30,
    "timezone": "Asia/Kolkata",
    "callingHour": { "start": "09:00", "end": "17:00" },
    "allowedDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
    "holidayListId": "64f12345abcdef9876543210"
}'
```

```bash cURL (video) theme={null}
curl --location 'https://api.weya.live/backend/api/call/createBatch' \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "channel_type": "video",
    "batchName": "Product Demo Campaign",
    "videoAgentId": "6891a23bc456def789123456"
}'
```

```bash cURL (web chat) theme={null}
curl --location 'https://api.weya.live/backend/api/call/createBatch' \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "channel_type": "web_chat",
    "batchName": "Website Chat",
    "chatAgentId": "6891a23bc456def789654321",
    "allowedDomains": ["example.com"]
}'
```

### Request Parameters

**channel\_type** `string` (default: voice)

Type of campaign: `voice`, `video` or `web_chat`.

**batchName** `string` *required*

Name of the campaign, shown in the dashboard.

#### Voice campaigns

**callingNumbers** `array[string]` *required*

IDs of the phone numbers to call from, from [Get Phone Numbers](https://docs.weya.ai/api-reference/PhoneNumbers/getPhoneNumbers.md). At least one is required. Calls are handled by the outbound agent assigned to each number.

**type** `string` (default: outbound)

Campaign type: `outbound`, `inbound` or `mixed`. Any other value creates an `outbound` campaign. It can't be changed later.

**retry** `integer`

Maximum attempts per contact. Use a value from 1 to 10, the range the dashboard allows. The API does not check the range.

**delay** `integer`

Time to wait between attempts to the same contact, in **minutes**. Use a value from 5 to 1440, the range the dashboard allows. The API does not check the range.

**timezone** `string`

Timezone used for the calling schedule. Example: `Asia/Kolkata`.

**callingHour** `object`

Daily calling window in 24-hour `HH:MM` format, with both `start` and `end`. Example: `{ "start": "09:00", "end": "17:00" }`. This endpoint does not check the format, so send valid values.

**allowedDays** `array[string]`

Days of the week calls can be placed on. Example: `["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]`.

**holidayListId** `string`

ID of a holiday list in your organization. No calls are placed on the dates in that list.

#### Video campaigns

**videoAgentId** `string` *required*

ID of the video agent people talk to. Required when `channel_type` is `video`.

#### Web chat campaigns

**chatAgentId** `string` *required*

ID of the chat agent. Required when `channel_type` is `web_chat`.

**voiceAgentId** `string`

Optional voice agent for visitors who switch to a call from the chat widget. Must not be a chat agent.

**allowedDomains** `array[string]` *required*

Websites the chat widget is allowed to load on: 1 to 50 domains. Required when `channel_type` is `web_chat`.

## Response

```json 201 Created theme={null}
{
  "message": "Batch created successfully",
  "status": true,
  "code": 201,
  "errorMessage": null,
  "data": "64e5f12345abcdef98765432"
}
```

```json 201 Created (video) theme={null}
{
  "message": "Video campaign created",
  "status": true,
  "code": 201,
  "errorMessage": null,
  "data": {
    "id": "64e5f12345abcdef98765433",
    "link": "https://..."
  }
}
```

**status** `boolean` *required*

Indicates whether the campaign was created.

**code** `integer` *required*

HTTP status code.

**message** `string` *required*

Human-readable success message: `Batch created successfully`, `Video campaign created` or `Chat campaign created`.

**data** `string | object` *required*

For voice campaigns, the new campaign's ID (`batchId`). For video campaigns, an object with the campaign `id` and its join `link`. For web chat campaigns, an object with the campaign `id`, `campaignToken` and the `scriptTag` to embed on your site.

## Error Handling

Errors return `status: false`, with the reason in `errorMessage`.

* **400 Bad Request**
  * `batchName` is missing, or `channel_type` is not `voice`, `video` or `web_chat`.
  * Voice: `Batch name & valid callingNumbers required` – `callingNumbers` is missing or empty.
  * Voice: `Invalid holidayListId` or `Holiday list not found`.
  * Video: `videoAgentId is required for a video campaign`.
  * Web chat: `chatAgentId` missing, `allowedDomains` empty, over 50 entries or containing an invalid domain, or the chat or voice agent has no saved version.
* **401 Unauthorized** – Missing or invalid API key.
* **404 Not Found** – `Video agent not found`, `Chat agent not found` or `Voice agent not found`: the agent doesn't exist or wasn't created by the user who owns the API key.
* **500 Internal Server Error** – Unexpected server error.

> [!TIP]
>
> After creating a campaign, you can:
>
> * `POST /api/call/addCallsToBatch` to add contacts to a voice campaign.
> * `POST /api/call/start-calling` to start calling.
> * `GET /api/call/batches/{userId}` to see it in your campaign list.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.