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

# Update Campaign

> Update an existing campaign.

Use this endpoint to **update an existing campaign**.

## Endpoint

**POST** `/update-campaign`

**Content-Type:** `application/json`
**Authentication:** Required (workspace auth)

## Request Body

To update a campaign, send its `id` and any fields you want to change.

```json theme={null}
{
  "id": 42,
  "agent_id": 123,
  "campaign_name": "Winter Sale Campaign - Updated",
  "description": "Updated description for winter offer campaign",
  "start_date": "2025-12-05",
  "end_date": "2026-01-05",
  "max_retry": 5,
  "max_delay": "{\"d\":1,\"h\":2,\"m\":30}",
  "campaign_status": "inprogress",
  "conditions": [
    {
      "rules": [
        { "field": "status", "operator": "==", "value": "active" },
        { "field": "region", "operator": "==", "value": "US" }
      ]
    },
    {
      "join": "OR",
      "rules": [
        { "field": "priority", "operator": "==", "value": "high" }
      ]
    }
  ]
}
```

### Notes

* `id` is **required** — it identifies the campaign to update.
* Only the fields you send are updated.
* `campaign_status` accepts a string value: `draft`, `inprogress`, `hold`, or `pause`.
* `max_delay` must be passed as a **JSON string** with keys `d` (days), `h` (hours), and `m` (minutes) as numbers.
* `start_date` and `end_date` must be in **`YYYY-MM-DD`** format (e.g., `"2025-12-05"`).
* `max_retry` cannot be greater than **50**.

### Conditions Format

The `conditions` field accepts an **array of groups**. Each group contains `rules` that are evaluated together.

**Structure:**

| Field   | Type   | Required | Description                                                                                      |
| ------- | ------ | -------- | ------------------------------------------------------------------------------------------------ |
| `join`  | string | No       | `"OR"` or `"AND"` — how this group connects with the previous group. Omit for the first group.   |
| `rules` | array  | Yes      | Array of condition rules within this group. Rules within a group are always joined with **AND**. |

**Each rule:**

| Field      | Type   | Required | Description                                                     |
| ---------- | ------ | -------- | --------------------------------------------------------------- |
| `field`    | string | Yes      | The field name to evaluate (from agent's metadata input fields) |
| `operator` | string | Yes      | One of the allowed operators (see table below)                  |
| `value`    | string | Yes      | The value to match against                                      |

**Allowed operators:**

| Operator     | Description                     |
| ------------ | ------------------------------- |
| `==`         | Equals (case-insensitive)       |
| `!=`         | Not equals                      |
| `>`          | Greater than (numeric)          |
| `>=`         | Greater than or equal (numeric) |
| `<`          | Less than (numeric)             |
| `<=`         | Less than or equal (numeric)    |
| `contains`   | Value contains the substring    |
| `startsWith` | Value starts with the string    |
| `endsWith`   | Value ends with the string      |

**Logic:**

* Rules **within the same group** are joined with **AND**.
* **Groups** are joined with each other using the `join` field (`"OR"` or `"AND"`).

**Example — single condition:**

```json theme={null}
"conditions": [
  {
    "rules": [
      { "field": "status", "operator": "==", "value": "active" }
    ]
  }
]
```

This means: **status == "active"**

**Example — multiple conditions with AND (same group):**

```json theme={null}
"conditions": [
  {
    "rules": [
      { "field": "status", "operator": "==", "value": "active" },
      { "field": "region", "operator": "==", "value": "US" }
    ]
  }
]
```

This means: **status == "active" AND region == "US"**

**Example — two groups with OR:**

```json theme={null}
"conditions": [
  {
    "rules": [
      { "field": "status", "operator": "==", "value": "active" },
      { "field": "region", "operator": "==", "value": "US" }
    ]
  },
  {
    "join": "OR",
    "rules": [
      { "field": "priority", "operator": "==", "value": "high" }
    ]
  }
]
```

This means: **(status == "active" AND region == "US") OR (priority == "high")**

**To clear conditions**, send `"conditions": null`.

## Example cURL

```bash theme={null}
curl -X POST https://www.tryunleashx.com/api/v1/global/update-campaign \
  -H "Content-Type: application/json" \
  -H "token: <api_key>" \
  -d '{
    "id": 42,
    "campaign_name": "Winter Sale Campaign - Updated",
    "start_date": "2025-12-05",
    "end_date": "2026-01-05",
    "max_retry": 5,
    "max_delay": "{\"d\":1,\"h\":2,\"m\":30}",
    "campaign_status": "inprogress",
    "conditions": [
      {
        "rules": [
          { "field": "status", "operator": "==", "value": "active" }
        ]
      }
    ]
  }'
```


## OpenAPI

````yaml api-reference/openapi.json POST /update-campaign
openapi: 3.1.0
info:
  title: >-
    UnleashX - Build human like conversations | Voice Agents | Automations | AI
    Workforce
  version: 1.0.0
  description: UnleashX - Your home for human like conversations
servers:
  - url: https://www.tryunleashx.com/api/v1/global/
security:
  - bearerAuth: []
paths:
  /update-campaign:
    post:
      tags:
        - Campaigns
      summary: Update campaign
      description: Update an existing campaign.
      parameters:
        - name: token
          in: header
          required: true
          description: API token for authentication
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  description: Campaign ID to update
                agent_id:
                  type: integer
                  description: Updated voice agent to use for this campaign
                campaign_name:
                  type: string
                  description: Updated campaign name (must remain unique within workspace)
                description:
                  type: string
                  description: Updated description
                start_date:
                  type: string
                  format: date
                  description: Updated start date in YYYY-MM-DD format (e.g. 2025-12-05)
                end_date:
                  type: string
                  format: date
                  description: Updated end date in YYYY-MM-DD format (e.g. 2026-01-05)
                max_retry:
                  type: integer
                  maximum: 50
                  description: Updated maximum retry attempts (cannot be greater than 50)
                max_delay:
                  type: string
                  description: >-
                    Delay between retries as a JSON string. Keys: d (days), h
                    (hours), m (minutes) with numeric values. Example:
                    {"d":1,"h":2,"m":30}
                campaign_status:
                  type: string
                  enum:
                    - draft
                    - inprogress
                    - hold
                    - pause
                  description: Updated campaign status.
                conditions:
                  type: array
                  description: >-
                    Condition groups with AND/OR logic. Each group contains
                    rules joined by AND. Groups are joined by the 'join' field
                    (OR or AND).
                  items:
                    type: object
                    properties:
                      join:
                        type: string
                        enum:
                          - OR
                          - AND
                        description: >-
                          How this group joins with the previous group. Omit or
                          set null for the first group.
                      rules:
                        type: array
                        description: Conditions within this group (joined by AND).
                        items:
                          type: object
                          properties:
                            field:
                              type: string
                              description: Field name to evaluate
                            operator:
                              type: string
                              enum:
                                - '=='
                                - '!='
                                - '>'
                                - '>='
                                - <
                                - <=
                                - contains
                                - startsWith
                                - endsWith
                              description: Comparison operator
                            value:
                              type: string
                              description: Value to match against
                          required:
                            - field
                            - operator
                            - value
                    required:
                      - rules
              required:
                - id
      responses:
        '200':
          description: Campaign updated successfully
        '400':
          description: >-
            Bad Request - validation failed or business rule violated (e.g.,
            max_retry > 50, missing required fields when publishing)
        '404':
          description: Campaign not found
      security: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````