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

# Update Campaign

> Edit an existing calling campaign's settings, and optionally add more calls to it from a CSV file.

## Overview

Update an existing campaign to change its name, calling numbers, calling schedule, retry settings, DNC setting, holiday list or call outcome tracking. You can also add more calls to the campaign in the same request by attaching a CSV file.

The request can be sent in two ways:

* **JSON** (`application/json`) – to update settings only.
* **Form data** (`multipart/form-data`) – to update settings **and** add calls from a CSV file in one request.

## Prerequisites

* An API key for your workspace
* An existing campaign and its `batchId`. The campaign must have been created by the user who owns the API key.
* The campaign must be **paused** or **completed**. Pause a running campaign before updating it.
* Voice campaigns only. Chat campaigns can't be edited with this endpoint.

## Endpoint

**/api/call/update-batch/\{batchId}**

## Request

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

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

**batchId** `string` *required*

Unique identifier of the campaign to update.

```bash cURL (settings only) theme={null}
curl --location --request PUT 'https://api.weya.live/backend/api/call/update-batch/6806382f98da85ec32fac955' \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "batchName": "Sales Campaign - July",
    "callingNumbers": ["6889c4ab7c7d3f9876543210"],
    "timezone": "Asia/Kolkata",
    "callingHour": { "start": "09:00", "end": "17:00" },
    "allowedDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
    "retry": 3,
    "delay": 30
}'
```

```bash cURL (settings + CSV) theme={null}
curl --location --request PUT 'https://api.weya.live/backend/api/call/update-batch/6806382f98da85ec32fac955' \
  --header 'x-api-key: YOUR_API_KEY' \
  --form 'batchName="Sales Campaign - July"' \
  --form 'callingNumbers="[\"6889c4ab7c7d3f9876543210\"]"' \
  --form 'retry="3"' \
  --form 'delay="30"' \
  --form 'file=@"/path/to/new-leads.csv"' \
  --form 'mandatoryVariables="[\"customer_name\"]"' \
  --form 'type="false"'
```

### Request Body

```json theme={null}
{
  "batchName": "Sales Campaign - July",
  "callingNumbers": ["6889c4ab7c7d3f9876543210"],
  "timezone": "Asia/Kolkata",
  "callingHour": { "start": "09:00", "end": "17:00" },
  "allowedDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
  "retry": 3,
  "delay": 30,
  "holidayListId": "68a1f2c3b7c7d3f123456789",
  "pushingCrms": [
    {
      "type": "webhook",
      "schemaId": "68b2e3d4b7c7d3f123456789",
      "crmId": "68b2e3d4b7c7d3f123456789"
    }
  ]
}
```

### Request Parameters

All settings are optional. Send only the fields you want to change; fields you leave out keep their current values.

**batchName** `string`

Name of the campaign.

**callingNumbers** `array[string]`

IDs of the phone numbers used to place calls. Replaces the campaign's current list, so send every number the campaign should use. Calls are handled by the agent assigned to each number. Get the IDs from [Get Phone Numbers](https://docs.weya.ai/api-reference/PhoneNumbers/getPhoneNumbers.md).

**timezone** `string`

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

**callingHour** `object`

Daily calling window in 24-hour `HH:MM` format. Both `start` and `end` are required. Example: `{ "start": "09:00", "end": "17:00" }`.

**allowedDays** `array[string]`

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

**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`

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

**enableDNC** `boolean`

The campaign's DNC setting. Can be `true` only when DNC is enabled for your organization. Numbers on your organization's [DNC list](https://docs.weya.ai/api-reference/DNC/getDNCList.md) are skipped in every campaign whatever this value is.

**holidayListId** `string`

ID of a holiday list in your organization. Send an empty string or `null` to remove the holiday list.

**pushingCrms** `array[object]`

Destinations call outcomes are sent to after each call. Replaces the current list. Send an empty array to stop tracking. A webhook or Google Sheet added here receives only calls that end after the update; earlier calls are not sent. Each item has:

* `type` – one of `standard` (HubSpot/Zoho), `custom`, `webhook` or `gsheet`
* `schemaId` – ID of the form or schema. For `gsheet`, the Google Sheet integration ID.
* `crmId` – ID of the connection or webhook. For `custom` it must equal `schemaId`; for `gsheet` it is set to `schemaId`.

A campaign can have at most one Google Sheet, and a Google Sheet already connected to another active campaign can't be added.

### CSV Upload Parameters

Send these as `multipart/form-data` to add calls to the campaign. When using form data, send object and array fields (`callingNumbers`, `callingHour`, `allowedDays`, `pushingCrms`) as JSON strings, and `enableDNC` as `"true"` or `"false"`.

The settings are saved first, then the file is processed. If the file is rejected, the settings change is still saved, and a paused campaign stays paused.

The file uses the same columns as [Upload Campaign CSV](https://docs.weya.ai/api-reference/Campaigns/uploadCSV.md). New calls use the campaign's settings after this update.

**file** `file`

File of contacts to add: `.csv`, `.xls` or `.xlsx`. Existing calls in the campaign are not removed. Not supported for inbound campaigns.

**mandatoryVariables** `string`

JSON array of variables that every row must have a value for. Example: `["customer_name"]`.

**type** `string`

`"true"` to skip invalid rows and upload only the valid ones. `"false"` (default) to reject the upload if any row is invalid. A file with no valid rows is always rejected.

## Response

```json 200 OK theme={null}
{
  "status": true,
  "code": 200,
  "message": "Batch updated and resumed successfully",
  "errorMessage": null,
  "data": {
    "_id": "6806382f98da85ec32fac955",
    "batchName": "Sales Campaign - July",
    "type": "outbound",
    "callingNumbers": ["6889c4ab7c7d3f9876543210"],
    "timezone": "Asia/Kolkata",
    "callingHour": { "start": "09:00", "end": "17:00" },
    "allowedDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
    "retry": 3,
    "delay": 30,
    "holidayListId": null,
    "pushingCrms": [],
    "queue_status": "pending"
  }
}
```

**status** `boolean` *required*

Indicates whether the request completed successfully.

**code** `integer` *required*

HTTP status code.

**message** `string` *required*

Human-readable success message. It is always `Batch updated and resumed successfully`, even when the campaign was not paused or did not resume. Check `data.queue_status` for the campaign's status.

**data** `object` *required*

The updated campaign. The example shows the main fields; the response includes the full campaign record.

**data.\_id** `string`

Unique identifier of the campaign.

**data.batchName** `string`

Name of the campaign.

**data.type** `string`

Campaign type: `outbound`, `inbound` or `mixed`.

**data.callingNumbers** `array[string]`

IDs of the calling numbers.

**data.callingHour** `object`

Daily calling window.

**data.allowedDays** `array[string]`

Days calls are placed on.

**data.retry** `integer`

Maximum attempts per contact.

**data.delay** `integer`

Minutes between attempts.

**data.queue\_status** `string`

Campaign status after the update:

* A paused campaign resumes: `in-progress`, `pending`, or `freezed` when outside its calling window. It stays `paused` if the automatic resume failed; call **Resume Campaign** in that case.
* A completed campaign becomes `pending` when the file added calls, and otherwise stays `completed`.

## Error Handling

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

* **400 Bad Request**
  * `Invalid Batch ID` – `batchId` is not a valid ID.
  * `Batch is currently running. Please pause this batch before updating.`
  * `A chat campaign cannot be edited here…` – the campaign is a chat campaign.
  * `callingHour` is missing `start` or `end`, or they are not in `HH:MM` format.
  * `Invalid JSON format for …` – a form field that must be a JSON string could not be parsed.
  * `enable DNC must be … in organization settings` – `enableDNC: true` was sent but DNC is not enabled for your organization.
  * `Invalid holidayListId` or `Holiday list not found` – the holiday list ID is malformed or not in your organization.
  * A `pushingCrms` entry is invalid: `Invalid CRM type`, `Invalid CRM schemaId`, `Invalid CRM crmId`, `Custom CRM crmId must equal schemaId`, more than one Google Sheet, or a Google Sheet already connected to another active campaign.
  * `CSV upload is not allowed for inbound batches.`
  * The file is empty, is not CSV or Excel, or has no valid rows.
  * The file has invalid rows and `type` is `"false"`. `data` contains:

    * `code` – `INVALID_CSV_ROWS`
    * `totalInvalidRows` – number of invalid rows
    * `validRows` – rows that would be uploaded if invalid rows are skipped
    * `truncated` – `true` if `invalidRows` lists only some of the rows
    * `invalidRows` – list of `{ rowNumber, phoneNumber, reason }`

    Fix the rows, or resend with `type` set to `"true"` to skip them.
* **401 Unauthorized** – Missing or invalid API key.
  * `Unauthorized: Invalid API Key` – the `x-api-key` value is wrong, the key was deleted, or it was created in a different environment (for example the dev dashboard).
  * `Unauthorized: No API Key OR Token Provided` – the `x-api-key` header was not sent.
* **404 Not Found**
  * `Batch not found` – no campaign with this ID was created by the user who owns the API key, or it was deleted.
  * A `pushingCrms` entry points to something that does not exist: `CRM schema not found`, `CRM not found`, `Custom CRM schema not found` or `Google Sheets integration not found`.
* **500 Internal Server Error** – Unexpected server error.

> [!NOTE]
>
> A campaign that was **paused** resumes automatically after a successful update. You do not need to call the resume endpoint unless `data.queue_status` is still `paused`.

> [!NOTE]
>
> The campaign type (outbound, inbound or mixed) and scheduled start date are set when the campaign is created and cannot be changed with this endpoint. In this request, `type` is the skip-invalid-rows flag described above, not the campaign type.

> [!TIP]
>
> After updating a campaign, you can:
>
> * `GET /api/call/batch-details/{batchId}` to retrieve the updated campaign details.
> * `POST /api/call/addCallsToBatch` to add more calls without changing settings.
> * `POST /api/call/start-calling` to start calling.
> * `DELETE /api/call/delete-batch/{batchId}` to delete the campaign.


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