Update campaign

It allows to update some parameters of a campaign.

API Description

Update

post

Update an existing campaign

Authorizations
Header parameters
X-Batch-Projectstringrequired

The unique project key, identifying a project on the Batch platform

Example: project_0664hxvwffvbpn278gxdyhsadddqgna6
Body
idstringrequired

Campaign id received from the create API

campaignobjectrequired

Campaign object as describe in the create query. An update on a campaign will overwrite its contents. It is not possible to update a completed or running campaign if not recurrent

Responses
application/json
objectoptional
post
POST /2.4/campaigns/update HTTP/1.1
Host: api.batch.com
Authorization: Bearer YOUR_SECRET_TOKEN
X-Batch-Project: text
Content-Type: application/json
Accept: */*
Content-Length: 452

{
  "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q",
  "campaign": {
    "name": "The campaign name",
    "state": "RUNNING",
    "when": {
      "local_time": false,
      "start_time": "2024-01-24T10:22:00Z"
    },
    "targeting": {
      "languages": [
        "fr"
      ],
      "regions": [
        "FR"
      ],
      "query": {
        "firstname": {
          "$eq": "Jane"
        }
      }
    },
    "messages": [
      {
        "channel_type": "email",
        "subject": "The campaign subject",
        "sender_identity_id": "4012",
        "reply_to": {
          "email_address": "[email protected]"
        },
        "html": "The campaign HTML content"
      }
    ]
  }
}
{}

Request structure

The Campaign API exposes a POST endpoint that allows to update a campaign:

https://api.batch.com/2.4/campaigns/update

Headers and authentication

See Overview → Using Project APIs.

Post data

The body of the request must contain a valid JSON payload describing the campaign.

Exemple of a request body:

  {
    "id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q",
    "campaign": {
      "name": "The campaign name",
      "state": "RUNNING",
      "when": {
        "local_time": false,
        "start_time": "2024-01-24T10:22:00Z"
      },
      "targeting": {
        "languages": [
          "fr"
        ],
        "regions": [
          "FR"
        ],
        "query": {
          "firstname": {
            "$eq": "Jane"
          }
        }
      },
      "messages": [
        {
          "channel_type": "email",
          "subject": "The campaign subject",
          "sender_identity_id": "4012",
          "reply_to": {
            "email_address": "[email protected]"
          },
          "html": "The campaign HTML content"
        }
      ]
    }
  }

identifier block

"id": "orchestration_0664hyh918hr1gnzka9py5t62nrc0e1q"

Campaign identifier is received in the API Campaign create response.

Campaign block

See API Campaigns create for details about parameters.

Responses

Success

If the POST to the API endpoint is successfull you will receive an HTTP 200 confirmation.

Failure

If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at [email protected] if you need further support.

  • AUTHENTICATION_INVALID (Http status code: 401, Error code: 10)

  • API_MISUSE (Http status code: 403, Error code: 12)

  • ROUTE_NOT_FOUND (Http status code: 404, Error code: 20)

  • MISSING_PARAMETER (Http status code: 400, Error code: 30)

  • MALFORMED_PARAMETER (Http status code: 400, Error code: 31)

  • MALFORMED_JSON_BODY (Http status code: 400, Error code: 32)

  • SERVER_ERROR (Http status code: 500, Error code: 1)

  • MAINTENANCE_ERROR (Http status code: 503, Error code: 2)

  • TOO_MANY_REQUESTS (Http status code: 429, Error code: 60) If you get a "too many requests" response, please wait for at least 5 seconds before trying again. Further requests might still return this error.

Last updated

Was this helpful?