# Change a campaign. Any change takes an approval away

`PATCH /crm/campaigns/{id}` · Rivier · campaigns

Change a campaign. Any change takes an approval away.

- Scope: campaigns:write
- Graphql: Mutation.campaignsCampaignUpdate
- Sdk: campaigns.campaign.update
- Cli: campaigns campaign update

## Parameters

- `id` (path, required), string

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "kind": {
      "type": "string",
      "enum": [
        "broadcast",
        "newsletter"
      ],
      "default": "broadcast"
    },
    "channel": {
      "type": "string",
      "enum": [
        "email",
        "sms",
        "whatsapp"
      ],
      "default": "email"
    },
    "purpose": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]{0,29}$",
      "default": "marketing"
    },
    "audience": {
      "type": "object",
      "properties": {
        "segmentId": {
          "type": "string",
          "format": "uuid"
        },
        "rules": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "all": {
                  "type": "array",
                  "items": {},
                  "minItems": 1,
                  "maxItems": 50
                }
              },
              "required": [
                "all"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "any": {
                  "type": "array",
                  "items": {},
                  "minItems": 1,
                  "maxItems": 50
                }
              },
              "required": [
                "any"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "not": {}
              },
              "required": [
                "not"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "f": {
                  "type": "string",
                  "pattern": "^(email|name|phone|source|lifecycle|country|language|owner|company|tag|created_at|updated_at|last_activity_at|orders_count|orders_total|open_deals|segment|custom\\.[a-z][a-z0-9_]{0,39}|consent\\.(email|sms|whatsapp|phone)(\\.[a-z][a-z0-9_]{0,29})?|suppressed\\.(email|sms|whatsapp|phone))$"
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "ne",
                    "contains",
                    "starts",
                    "in",
                    "nin",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "exists",
                    "within_days",
                    "older_than_days"
                  ]
                },
                "v": {}
              },
              "required": [
                "f",
                "op"
              ],
              "additionalProperties": false
            }
          ]
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "pattern": "^[\\p{L}\\p{N}][\\p{L}\\p{N} _.:/-]*$"
          },
          "maxItems": 20
        },
        "excludeSegmentIds": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          },
          "maxItems": 10
        }
      },
      "additionalProperties": false
    },
    "content": {
      "type": "object",
      "properties": {
        "subject": {
          "type": "string",
          "maxLength": 200,
          "default": ""
        },
        "preheader": {
          "type": "string",
          "maxLength": 200
        },
        "templateId": {
          "type": "string",
          "format": "uuid"
        },
        "html": {
          "type": "string",
          "maxLength": 500000
        },
        "text": {
          "type": "string",
          "maxLength": 100000
        },
        "whatsapp": {
          "type": "object",
          "properties": {
            "templateId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            },
            "variables": {
              "type": "object",
              "additionalProperties": {
                "type": "string",
                "maxLength": 1000
              }
            }
          },
          "required": [
            "templateId"
          ],
          "additionalProperties": false
        },
        "cms": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "maxLength": 40
            },
            "entryIds": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              },
              "maxItems": 20
            },
            "limit": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20
            },
            "locale": {
              "type": "string",
              "maxLength": 20
            }
          },
          "additionalProperties": false
        },
        "ai": {
          "type": "object",
          "properties": {
            "generated": {
              "type": "boolean"
            },
            "model": {
              "type": "string",
              "maxLength": 120
            },
            "runId": {
              "type": "string",
              "maxLength": 120
            },
            "disclosureLine": {
              "type": "string",
              "maxLength": 300
            }
          },
          "required": [
            "generated"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "from": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 100
        },
        "replyTo": {
          "type": "string",
          "maxLength": 320
        }
      },
      "additionalProperties": false
    },
    "variants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9]{0,9}$"
          },
          "subject": {
            "type": "string",
            "maxLength": 200
          },
          "html": {
            "type": "string",
            "maxLength": 500000
          },
          "text": {
            "type": "string",
            "maxLength": 100000
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 4
    },
    "ab": {
      "type": "object",
      "properties": {
        "testPercent": {
          "type": "integer",
          "minimum": 5,
          "maximum": 50,
          "default": 20
        },
        "metric": {
          "type": "string",
          "enum": [
            "clicks",
            "delivered"
          ],
          "default": "clicks"
        },
        "waitHours": {
          "type": "number",
          "minimum": 1,
          "maximum": 72,
          "default": 4
        }
      },
      "additionalProperties": false
    },
    "schedule": {
      "type": "object",
      "properties": {
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "timezone": {
          "type": "string",
          "maxLength": 60
        }
      },
      "additionalProperties": false
    },
    "throttle": {
      "type": "object",
      "properties": {
        "perHour": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000
        }
      },
      "additionalProperties": false
    },
    "recurrence": {
      "type": "object",
      "properties": {
        "every": {
          "type": "string",
          "enum": [
            "day",
            "week",
            "month"
          ]
        },
        "at": {
          "type": "string",
          "pattern": "^\\d{2}:\\d{2}$"
        },
        "weekday": {
          "type": "integer",
          "minimum": 0,
          "maximum": 6
        },
        "dayOfMonth": {
          "type": "integer",
          "minimum": 1,
          "maximum": 28
        },
        "timezone": {
          "type": "string",
          "maxLength": 60,
          "default": "UTC"
        },
        "until": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "every",
        "at"
      ],
      "additionalProperties": false
    },
    "tracking": {
      "type": "object",
      "properties": {
        "clicks": {
          "type": "boolean",
          "default": true
        },
        "opens": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X PATCH 'https://api.rivier.ai/crm/campaigns/{id}' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "kind": "broadcast",
  "channel": "email",
  "purpose": "marketing",
  "audience": {
    "segmentId": "string",
    "rules": {
      "all": []
    },
    "tags": [
      "string"
    ],
    "excludeSegmentIds": [
      "string"
    ]
  },
  "content": {
    "subject": "",
    "preheader": "string",
    "templateId": "string",
    "html": "string",
    "text": "string",
    "whatsapp": {
      "templateId": "string"
    },
    "cms": {
      "type": "string",
      "entryIds": [
        "string"
      ],
      "limit": 0,
      "locale": "string"
    },
    "ai": {
      "generated": false
    }
  },
  "from": {
    "name": "string",
    "replyTo": "string"
  },
  "variants": [
    {
      "id": "string"
    }
  ]
}'
```
