Create campaign
Campaign API is designed for broad audience interactions, allowing you to send messages to large groups of users. You can target either your entire user base or specific segments using Batch's segmentation features.
This API supports the creation, updating, and deletion of campaigns, giving you full control over your messaging strategies.
API Description
Create a new campaign
The unique project key, identifying a project on the Batch platform
project_0664hxvwffvbpn278gxdyhsadddqgna6
Display name of the campaign on the dashboard
Only RUNNING state supported for now
Campaign programation details (when/how to send)
Who should be reached by the campaign
Messages to send, only one kind of message is allowed at a time.
Request structure
Campaign API exposes a POST endpoint that allows to create a campaign:
https://api.batch.com/2.4/campaigns/create
Headers and authentication
See Overview → Using Project APIs.
Post data
Exemple of a request body:
The body must include a valid JSON payload containing the following blocks:
General information about the campaign.
"When" part (Required) which indicates when to send the campaign.
"Targeting" which indicates who will be the recipients of the campaign (default is the entire user base).
"Messages" part (Required) describing the message to send. Payload will be different if you want to send an email or a push message.
Campaign general information
Describing name and state of the campaign.
For the time being, Batch only supports the "RUNNING" state for a campaign.
When block
Describing when to send the campaign - required.
Targeting block
Describing who will be reached by the campaign. This block is not required, if you omit it, Batch will consider sending the campaign to the entire user base.
Messages block - for email
Describing the messages to send when sending an email campaign - required.
messages
is an array that can only contain one element.
Channel type
value should be email
Sender Identity
Sender identity describes which sender email will be used. This sender needs to be created before the API Call. If not existing, it will not generate a new ID and the API Call will fail. Sender identity ID can be found on the dashboard (Email channel settings).
Languages array
Email messages are available with multi-language
Messages block - for push
Describing the messages to send when sending a push campaign - required.
messages
is an array that can only contain one element.
Channel type
value should be push
Filter push tokens
filter_push_tokens
allows you to target collected tokens or imported tokens, or both.
all : the campaign will target imported and collected push tokens
collected : the campaign will target only collected push tokens, detected by Batch SDKs
imported : the campaign will target only imported push tokens, not yet detected by Batch SDKs
iOS / Android / Web platorms
A push campaign can send the same message to several platforms, using the platform_type
Array. You can select one platform only or a combination of 2 or 3 platforms. You can add some platform specific values for a platform by setting them inside of the ios
, android
and web
objects.
Languages array
Push messages are available with multi-language
iOS specific attributes
The iOS object can specify some attributes:
deeplink
custom payload
Android specific attributes
The Android object comes with android properties:
deeplink
custom payload
media (icon)
Collapse key
Web specific attributes
The Web object can specify some attributes:
deeplink
media (icon)
Multi-language
languages
allows you to define many translations. Each item of an array will give you translation of many attributes (content & some parameters) for the designed language
.
All required parameters at the top level of a message is also required in any given translation.
Email & Push messages can both be translated.
Responses
Success
If the POST to the API endpoint is successful you will receive an HTTP 201 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?