Update a campaign
Update campaign fields, including scheduled_at to reschedule an active one-off campaign. Completed campaigns cannot be updated. Requires an account administrator and API access enabled for the account.
curl --request PATCH \
--url https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id} \
--header 'Content-Type: application/json' \
--header 'api_access_token: <api-key>' \
--data '
{
"campaign": {
"title": "<string>",
"description": "<string>",
"inbox_id": 123,
"sender_id": 123,
"message": "<string>",
"enabled": true,
"scheduled_at": "2027-01-15T10:00:00Z",
"audience": [
{
"type": "Label",
"id": 123
}
],
"trigger_rules": {
"url": "https://example.com/pricing",
"time_on_page": 10
},
"trigger_only_during_business_hours": true
}
}
'import requests
url = "https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}"
payload = { "campaign": {
"title": "<string>",
"description": "<string>",
"inbox_id": 123,
"sender_id": 123,
"message": "<string>",
"enabled": True,
"scheduled_at": "2027-01-15T10:00:00Z",
"audience": [
{
"type": "Label",
"id": 123
}
],
"trigger_rules": {
"url": "https://example.com/pricing",
"time_on_page": 10
},
"trigger_only_during_business_hours": True
} }
headers = {
"api_access_token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {api_access_token: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
campaign: {
title: '<string>',
description: '<string>',
inbox_id: 123,
sender_id: 123,
message: '<string>',
enabled: true,
scheduled_at: '2027-01-15T10:00:00Z',
audience: [{type: 'Label', id: 123}],
trigger_rules: {url: 'https://example.com/pricing', time_on_page: 10},
trigger_only_during_business_hours: true
}
})
};
fetch('https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'campaign' => [
'title' => '<string>',
'description' => '<string>',
'inbox_id' => 123,
'sender_id' => 123,
'message' => '<string>',
'enabled' => true,
'scheduled_at' => '2027-01-15T10:00:00Z',
'audience' => [
[
'type' => 'Label',
'id' => 123
]
],
'trigger_rules' => [
'url' => 'https://example.com/pricing',
'time_on_page' => 10
],
'trigger_only_during_business_hours' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_access_token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}"
payload := strings.NewReader("{\n \"campaign\": {\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"inbox_id\": 123,\n \"sender_id\": 123,\n \"message\": \"<string>\",\n \"enabled\": true,\n \"scheduled_at\": \"2027-01-15T10:00:00Z\",\n \"audience\": [\n {\n \"type\": \"Label\",\n \"id\": 123\n }\n ],\n \"trigger_rules\": {\n \"url\": \"https://example.com/pricing\",\n \"time_on_page\": 10\n },\n \"trigger_only_during_business_hours\": true\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("api_access_token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}")
.header("api_access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"campaign\": {\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"inbox_id\": 123,\n \"sender_id\": 123,\n \"message\": \"<string>\",\n \"enabled\": true,\n \"scheduled_at\": \"2027-01-15T10:00:00Z\",\n \"audience\": [\n {\n \"type\": \"Label\",\n \"id\": 123\n }\n ],\n \"trigger_rules\": {\n \"url\": \"https://example.com/pricing\",\n \"time_on_page\": 10\n },\n \"trigger_only_during_business_hours\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["api_access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"campaign\": {\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"inbox_id\": 123,\n \"sender_id\": 123,\n \"message\": \"<string>\",\n \"enabled\": true,\n \"scheduled_at\": \"2027-01-15T10:00:00Z\",\n \"audience\": [\n {\n \"type\": \"Label\",\n \"id\": 123\n }\n ],\n \"trigger_rules\": {\n \"url\": \"https://example.com/pricing\",\n \"time_on_page\": 10\n },\n \"trigger_only_during_business_hours\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"title": "<string>",
"description": "<string>",
"account_id": 123,
"inbox": {
"id": 123,
"name": "<string>",
"website_url": "<string>",
"page_id": "<string>",
"instagram_id": "<string>",
"business_id": "<string>",
"provider_name": "<string>",
"profile_id": "<string>",
"line_channel_id": "<string>",
"email": "<string>",
"bot_name": "<string>",
"inbox_identifier": "<string>",
"channel_type": "<string>",
"avatar_url": "<string>",
"widget_color": "<string>",
"website_token": "<string>",
"enable_auto_assignment": true,
"web_widget_script": "<string>",
"welcome_title": "<string>",
"welcome_tagline": "<string>",
"greeting_enabled": true,
"greeting_message": "<string>",
"channel_id": 123,
"working_hours_enabled": true,
"enable_email_collect": true,
"csat_survey_enabled": true,
"auto_assignment_config": {},
"out_of_office_message": "<string>",
"working_hours": [
{
"day_of_week": 123,
"closed_all_day": true,
"open_hour": 123,
"open_minutes": 123,
"close_hour": 123,
"close_minutes": 123,
"open_all_day": true
}
],
"timezone": "<string>",
"callback_webhook_url": "<string>",
"allow_messages_after_resolved": true,
"lock_to_single_conversation": true,
"sender_name_type": "<string>",
"business_name": "<string>",
"branded_email_layout": "<string>",
"hmac_mandatory": true,
"selected_feature_flags": [
"<string>"
],
"reply_time": "<string>",
"messaging_service_sid": "<string>",
"phone_number": "<string>",
"medium": "<string>",
"provider": "<string>"
},
"sender": {},
"message": "<string>",
"template_params": {},
"campaign_status": "active",
"campaign_type": "ongoing",
"enabled": true,
"scheduled_at": 123,
"started_at": 123,
"completed_at": 123,
"audience": [
{
"type": "<string>",
"id": 123
}
],
"trigger_rules": {},
"trigger_only_during_business_hours": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}Authorizations
This token can be obtained by visiting the profile page or via rails console. Provides access to endpoints based on the user permissions levels. This token can be saved by an external system when user is created via API, to perform activities on behalf of the user.
Path Parameters
The numeric ID of the account
Account-scoped campaign ID returned by the campaign API.
Body
Show child attributes
Show child attributes
Response
Success
Account-scoped campaign ID. Use this value in campaign API paths.
Show child attributes
Show child attributes
Sender details, or an empty object when no sender is assigned.
active, processing, completed Derived from the inbox type; website campaigns are ongoing and supported messaging campaigns are one-off.
ongoing, one_off Scheduled time in Unix seconds. Only present for one-off campaigns.
Start time in Unix seconds. Only present for one-off campaigns.
Completion time in Unix seconds. Only present for one-off campaigns.
Audience for a one-off campaign. Only present for one-off campaigns.
Show child attributes
Show child attributes
curl --request PATCH \
--url https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id} \
--header 'Content-Type: application/json' \
--header 'api_access_token: <api-key>' \
--data '
{
"campaign": {
"title": "<string>",
"description": "<string>",
"inbox_id": 123,
"sender_id": 123,
"message": "<string>",
"enabled": true,
"scheduled_at": "2027-01-15T10:00:00Z",
"audience": [
{
"type": "Label",
"id": 123
}
],
"trigger_rules": {
"url": "https://example.com/pricing",
"time_on_page": 10
},
"trigger_only_during_business_hours": true
}
}
'import requests
url = "https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}"
payload = { "campaign": {
"title": "<string>",
"description": "<string>",
"inbox_id": 123,
"sender_id": 123,
"message": "<string>",
"enabled": True,
"scheduled_at": "2027-01-15T10:00:00Z",
"audience": [
{
"type": "Label",
"id": 123
}
],
"trigger_rules": {
"url": "https://example.com/pricing",
"time_on_page": 10
},
"trigger_only_during_business_hours": True
} }
headers = {
"api_access_token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {api_access_token: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
campaign: {
title: '<string>',
description: '<string>',
inbox_id: 123,
sender_id: 123,
message: '<string>',
enabled: true,
scheduled_at: '2027-01-15T10:00:00Z',
audience: [{type: 'Label', id: 123}],
trigger_rules: {url: 'https://example.com/pricing', time_on_page: 10},
trigger_only_during_business_hours: true
}
})
};
fetch('https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'campaign' => [
'title' => '<string>',
'description' => '<string>',
'inbox_id' => 123,
'sender_id' => 123,
'message' => '<string>',
'enabled' => true,
'scheduled_at' => '2027-01-15T10:00:00Z',
'audience' => [
[
'type' => 'Label',
'id' => 123
]
],
'trigger_rules' => [
'url' => 'https://example.com/pricing',
'time_on_page' => 10
],
'trigger_only_during_business_hours' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_access_token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}"
payload := strings.NewReader("{\n \"campaign\": {\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"inbox_id\": 123,\n \"sender_id\": 123,\n \"message\": \"<string>\",\n \"enabled\": true,\n \"scheduled_at\": \"2027-01-15T10:00:00Z\",\n \"audience\": [\n {\n \"type\": \"Label\",\n \"id\": 123\n }\n ],\n \"trigger_rules\": {\n \"url\": \"https://example.com/pricing\",\n \"time_on_page\": 10\n },\n \"trigger_only_during_business_hours\": true\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("api_access_token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}")
.header("api_access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"campaign\": {\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"inbox_id\": 123,\n \"sender_id\": 123,\n \"message\": \"<string>\",\n \"enabled\": true,\n \"scheduled_at\": \"2027-01-15T10:00:00Z\",\n \"audience\": [\n {\n \"type\": \"Label\",\n \"id\": 123\n }\n ],\n \"trigger_rules\": {\n \"url\": \"https://example.com/pricing\",\n \"time_on_page\": 10\n },\n \"trigger_only_during_business_hours\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chatwoot.com/api/v1/accounts/{account_id}/campaigns/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["api_access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"campaign\": {\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"inbox_id\": 123,\n \"sender_id\": 123,\n \"message\": \"<string>\",\n \"enabled\": true,\n \"scheduled_at\": \"2027-01-15T10:00:00Z\",\n \"audience\": [\n {\n \"type\": \"Label\",\n \"id\": 123\n }\n ],\n \"trigger_rules\": {\n \"url\": \"https://example.com/pricing\",\n \"time_on_page\": 10\n },\n \"trigger_only_during_business_hours\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"title": "<string>",
"description": "<string>",
"account_id": 123,
"inbox": {
"id": 123,
"name": "<string>",
"website_url": "<string>",
"page_id": "<string>",
"instagram_id": "<string>",
"business_id": "<string>",
"provider_name": "<string>",
"profile_id": "<string>",
"line_channel_id": "<string>",
"email": "<string>",
"bot_name": "<string>",
"inbox_identifier": "<string>",
"channel_type": "<string>",
"avatar_url": "<string>",
"widget_color": "<string>",
"website_token": "<string>",
"enable_auto_assignment": true,
"web_widget_script": "<string>",
"welcome_title": "<string>",
"welcome_tagline": "<string>",
"greeting_enabled": true,
"greeting_message": "<string>",
"channel_id": 123,
"working_hours_enabled": true,
"enable_email_collect": true,
"csat_survey_enabled": true,
"auto_assignment_config": {},
"out_of_office_message": "<string>",
"working_hours": [
{
"day_of_week": 123,
"closed_all_day": true,
"open_hour": 123,
"open_minutes": 123,
"close_hour": 123,
"close_minutes": 123,
"open_all_day": true
}
],
"timezone": "<string>",
"callback_webhook_url": "<string>",
"allow_messages_after_resolved": true,
"lock_to_single_conversation": true,
"sender_name_type": "<string>",
"business_name": "<string>",
"branded_email_layout": "<string>",
"hmac_mandatory": true,
"selected_feature_flags": [
"<string>"
],
"reply_time": "<string>",
"messaging_service_sid": "<string>",
"phone_number": "<string>",
"medium": "<string>",
"provider": "<string>"
},
"sender": {},
"message": "<string>",
"template_params": {},
"campaign_status": "active",
"campaign_type": "ongoing",
"enabled": true,
"scheduled_at": 123,
"started_at": 123,
"completed_at": 123,
"audience": [
{
"type": "<string>",
"id": 123
}
],
"trigger_rules": {},
"trigger_only_during_business_hours": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
