Trigger a campaign
POST/v1/campaigns/{id}/trigger
Requires an API key with the campaigns:send scope. About keys and scopes
Works with integration and partner keys, not agent keys.
Send Idempotency-Key. A retry with the same key and body repeats nothing. Most writes replay the first response; a transactional send returns the message as it stands now. About idempotency
Sends a draft now, once, to the contacts recipients names, by contactId, externalId or email, instead of its saved audience; it needs none. Each person may carry their own data, read in the content as {{ data.<key> }} over the shared data: "the item in your basket is now cheaper", to each their item. Up to 5,000 recipients, the request up to 10 MB. A recipient that names no contact is not sent and comes back in notFound; one contact listed twice is refused with 400. Each message is checked as any campaign send is (consent, suppression, topic, limits), and a message whose content reads a value its recipient lacks is skipped with missing_merge_tag. Data is kept on a message only until it is sent. A campaign whose content reads data can go out only this way. A campaign is sent at most once, and every channel must be ready, as for a send. An Idempotency-Key header is required, and is kept with the campaign for as long as it exists: a retry with the same key and request returns the first response, notFound included, with Idempotency-Replay: true; the same key with a different request is 409 IDEMPOTENCY_KEY_REUSED, and any other trigger of a campaign already sent is 409 CONFLICT: to send again, duplicate it. Agent keys are refused with 403, and a campaign an agent wrote or edited returns 409 AGENT_CONFIRMATION_REQUIRED until a person confirms it in the dashboard.
Path parameters
idstringrequiredThe campaign's id.
uuid
Header parameters
Idempotency-KeystringrequiredMakes a retry safe for as long as what the request created exists: a repeat with the same key and body gets the first response again, with
Idempotency-Replay: true. The same key with another request is 409IDEMPOTENCY_KEY_REUSED. Use a new key, such as a UUID, for each new request.8–255 characters
Kirora-WorkspacestringoptionalPartner keys only: the child workspace to act in, by the external id the partner gave it. Without it, a partner key acts in its own workspace. Any other key that sends it is refused with 403, and an unknown workspace is 404.
pattern
^[A-Za-z0-9._:-]{1,128}$
Request body
datamap<string, any>optionalValues every recipient shares.
keys: pattern
^[A-Za-z0-9_-]{1,64}$recipientsobject[]requiredThe people to send to, each named by one identifier.
at least 1 item · at most 5,000 items
Any of 3 shapes
- Recipient by contact ID
2 child attributes
contactIdstringrequiredKirora's id for the contact.
uuid
datamap<string, any>optionalThis person's values; each key overrides the trigger's shared
data.keys: pattern
^[A-Za-z0-9_-]{1,64}$
- Recipient by external ID
2 child attributes
externalIdstringrequiredYour own id for the contact, as set with identify.
1–255 characters
datamap<string, any>optionalThis person's values; each key overrides the trigger's shared
data.keys: pattern
^[A-Za-z0-9_-]{1,64}$
- Recipient by email
2 child attributes
emailstringrequiredThe contact's email address, matched trimmed and without case.
datamap<string, any>optionalThis person's values; each key overrides the trigger's shared
data.keys: pattern
^[A-Za-z0-9_-]{1,64}$
Returns
Returns 202 Accepted with a TriggeredCampaign in data. It can also return 409 Conflict, 413 Payload Too Large or 415 Unsupported Media Type; see the statuses below. Otherwise returns an error; Errors lists every code and which to retry.
202 AcceptedThe campaign, now sending or already sent, and the recipients not found.409 ConflictThe request conflicts with current state — a duplicate unique value, or a resource whose status does not allow this operation.413 Payload Too LargeThe body is larger than this operation accepts (PAYLOAD_TOO_LARGE).415 Unsupported Media TypeThe body is not JSON, or not the upload the operation takes (UNSUPPORTED_MEDIA_TYPE).
campaignCampaignrequired25 child attributes
idstringrequireduuid
namestringrequiredchannelsstring[]requiredThe channels it sends on.
allContactsbooleanrequiredWhether it goes to all contacts: everyone its channels reach, with consent and suppressions applied as on any send.
listIdsstring[] | nullrequiredThe lists it goes to, if any: a member of any of them receives it once.
segmentIdstring | nullrequiredThe segment it goes to, if any.
uuid
audienceNamestring | nullrequiredThe names of the lists or the segment it went to, once one of them has been deleted (the list leaves
listIds, orsegmentIdbecomesnull). Only a sent or cancelled campaign can lose its audience this way.audienceRulesobject | nullrequiredInline rules choosing the audience, if any. At most one audience is set.
Any of 2 shapes
- Match all
1 child attribute
allobject[]requiredEvery rule or nested group must match.
at least 1 item · at most 20 items
Any of 10 shapes
- Attribute
- Contact field
- Event
- Message activity
- Push installation
- List membership
- Segment membership
- Topic
- Match all
- Match any
- Match any
1 child attribute
anyobject[]requiredAt least one rule or nested group must match.
at least 1 item · at most 20 items
Any of 10 shapes
- Attribute
- Contact field
- Event
- Message activity
- Push installation
- List membership
- Segment membership
- Topic
- Match all
- Match any
exclusionsobject | nullrequiredLists and segments left out of its audience ("don't send to");
nullfor none.2 child attributes
listIdsstring[]requiredLists whose members are left out.
at most 20 items · default
[]segmentIdsstring[]requiredSegments whose members are left out, by the segment's rules at send.
at most 10 items · default
[]
topicIdstring | nullrequiredSends only to contacts the topic reaches;
nullsends to everyone with consent.uuid
messageLimitsMessageLimitUserequired2 child attributes
applybooleanrequiredWhether its messages count toward the workspace's message limits and are held by them.
retryForDurationoptionalHow long a message over a limit keeps being retried before it is skipped with reason
message_limit: whole hours, at most 48. Unset, it is skipped at once. Absent whenapplyis false.2 child attributes
valueintegerrequiredmin > 0
unitstringrequiredone of
seconds,minutes,hours,days
utmobject | nullrequiredUTM parameters added to the links in the email.
6 child attributes
enabledbooleanrequiredsourcestringoptionalpattern
^[\p{L}\p{N}\p{M} ._\-+/]+$· 1–100 charactersmediumstringoptionalpattern
^[\p{L}\p{N}\p{M} ._\-+/]+$· 1–100 characterscampaignstringoptionalpattern
^[\p{L}\p{N}\p{M} ._\-+/]+$· 1–100 characterscontentstringoptionalpattern
^[\p{L}\p{N}\p{M} ._\-+/]+$· 1–100 characterstermstringoptionalpattern
^[\p{L}\p{N}\p{M} ._\-+/]+$· 1–100 characters
contentCampaignContentrequired2 child attributes
emailobjectoptionalThe email fields and design; any may be missing on a draft.
8 child attributes
subjectstringoptionalThe subject line. Merge tags are allowed.
1–998 characters
previewTextstringoptionalShown by inboxes after the subject. Merge tags are allowed; keep it near 100 characters.
1–255 characters
htmlstringoptionalThe HTML body. Rendered from the design when one is set.
1–512,000 characters
textstringoptionalThe plain-text alternative.
1–512,000 characters
fromstringoptionalThe sender address, on a verified sending domain.
1–320 characters
replyTostringoptionalWhere replies go; the part before the @ must be ASCII.
email
templateSnapshotobjectoptionalThe email design or HTML, copied into the campaign so later template edits do not change it.
One of 2 shapes
- With schemaVersion, blocks and theme
- With kind and html
translationsEmailTranslationsoptionalThe email in other languages, keyed by language tag (
fr,pt-BR). Each contact gets the version for theirlocale: the exact tag first, then each shorter one (fr-CAtakesfr), else the main email. A field a version leaves out is the main email's; the sender, reply-to, topic and tracking are always the main email's, and every A/B version shares the translations. Up to 30.at most 30 keys
5 child attributes
subjectstringoptionalThe subject line. Merge tags are allowed.
1–998 characters
previewTextstringoptionalShown by inboxes after the subject. Merge tags are allowed; keep it near 100 characters.
1–255 characters
htmlstringoptionalThe HTML body. Rendered from the design when one is set.
1–512,000 characters
textstringoptionalThe plain-text alternative.
1–512,000 characters
templateSnapshotobjectoptionalThis language's design; left out, it uses the main email's.
pushobjectoptionalThe notification content.
15 child attributes
titlestringoptionalThe notification title (up to 100 characters).
1–100 characters
bodystringoptionalThe notification text (up to 500 characters).
1–500 characters
actionUrlstringoptionalThe HTTPS page opened when the notification is tapped.
uri · up to 2,048 characters
imageUrlstringoptionalA large picture: web and Android show it; iOS needs the app's service extension.
uri · up to 2,048 characters
iconUrlstringoptionalWeb only; iOS and Android show the app's own notification icon.
uri · up to 2,048 characters
datamap<string, string>optionalUp to 10 string key-value pairs passed to the app untouched, for deep links and in-app routing.
at most 10 keys · keys: pattern
^[A-Za-z0-9_.-]{1,64}$· values: up to 1,024 charactersbuttonsobject[]optionalUp to 2 action buttons. iPhones show them through a notification service extension.
at least 1 item · at most 2 items
2 child attributes
titlestringrequiredThe button label.
1–30 characters
urlstringrequiredThe HTTPS page the button opens.
uri · up to 2,048 characters
collapseKeystringoptionalA newer notification with the same key replaces the older one on the device.
pattern
^[A-Za-z0-9_-]{1,64}$soundstringoptionalThe name of a sound the app ships; the device's default if unset.
1–64 characters
badgeintegeroptionalThe number shown on the iOS app icon.
min 0 · max 99999
ttlDurationOrZerooptionalHow long a provider keeps trying an offline device, up to 28 days; zero delivers now or never. Defaults to one day.
2 child attributes
valueintegerrequiredmin 0
unitstringrequiredone of
seconds,minutes,hours,days
urgencystringoptionalhigh(the default) asks the push service to deliver promptly, even to a locked or sleeping device;normallets it wait for a good moment to save battery, so a locked phone may show it only once woken. Device settings and the app still decide whether and how it is shown.one of
high,normaltranslationsPushTranslationsoptionalThe title and body in other languages, keyed by language tag (
fr,pt-BR). Each device gets the one for its own language, as it last reported it: the exact tag first, then its language (fr-CAtakesfr); a device that reported none, the contact'slocale; otherwise the shared text. A translation replaces the title and body on every platform, overrides included, and in every A/B version. Merge tags work as in the shared text.at most 30 keys
2 child attributes
titlestringoptionalThe notification title (up to 100 characters).
1–100 characters
bodystringoptionalThe notification text (up to 500 characters).
1–500 characters
overridesobjectoptionalFields that differ on one platform, each replacing the shared one there (a whole
datamap, not merged key by key). On iOS and AndroidactionUrlmay be an app link such asmyapp://orders; the shared one and the web one must be HTTPS.3 child attributes
iosobjectoptionalReplaces shared fields on iOS.
androidobjectoptionalReplaces shared fields on Android.
webobjectoptionalReplaces shared fields on web.
pushProjectIdstringoptionalThe push project it goes out through. Needed to send.
uuid
abTestobject | nullrequiredIts A/B test, if it has one;
nullsends one version to everyone.8 child attributes
versionsobject[]requiredVersions 2 onward; version 1 is the campaign's own content.
2 child attributes
emailobjectoptionalThis version's email fields and design; any left out are version 1's.
8 child attributes
subjectstringoptionalThe subject line. Merge tags are allowed.
1–998 characters
previewTextstringoptionalShown by inboxes after the subject. Merge tags are allowed; keep it near 100 characters.
1–255 characters
htmlstringoptionalThe HTML body. Rendered from the design when one is set.
1–512,000 characters
textstringoptionalThe plain-text alternative.
1–512,000 characters
fromstringoptionalThe sender address, on a verified sending domain.
1–320 characters
replyTostringoptionalWhere replies go; the part before the @ must be ASCII.
email
templateSnapshotobjectoptionalThe email design or HTML, copied into the campaign so later template edits do not change it.
translationsEmailTranslationsoptionalThe email in other languages, keyed by language tag (
fr,pt-BR). Each contact gets the version for theirlocale: the exact tag first, then each shorter one (fr-CAtakesfr), else the main email. A field a version leaves out is the main email's; the sender, reply-to, topic and tracking are always the main email's, and every A/B version shares the translations. Up to 30.at most 30 keys
pushobjectoptionalThis version's push title, body and image; any left out are version 1's.
3 child attributes
titlestringoptionalThe notification title (up to 100 characters).
1–100 characters
bodystringoptionalThe notification text (up to 500 characters).
1–500 characters
imageUrlstringoptionalA large picture: web and Android show it; iOS needs the app's service extension.
uri · up to 2,048 characters
testPercentintegerrequiredThe share of the audience, in percent, the versions go to, split evenly between them. The rest get the winner.
min 10 · max 50
winnerBystringrequiredHow the winner is picked: the version with the highest click or open rate over its delivered messages that could show one (as the campaign's own rates: email sent without tracking is left out; over sent until any version has a delivery), or the highest share of its sent messages that reached the campaign's conversion goal (
conversionGoalId). Opens overcount: machine opens (Apple Mail Privacy Protection, Gmail's prefetch, mail scanners) count unread email as opened. A push test is decided by clicks (a tap the app reports with a link to follow, so the push needs anactionUrl) or conversions, not opens. A tie goes to the lower version.one of
clicks,opens,conversionsconversionGoalIdstring | nullrequiredThe conversion goal that decides, when
winnerByisconversions.uuid
decideAfterobject | nullrequiredHow long after the test went out to pick the winner and send it to the rest, from 1 to 72 hours;
nullto pick it by hand.2 child attributes
valueintegerrequiredmin > 0
unitstringrequiredone of
seconds,minutes,hours,days
winnerinteger | nullrequiredThe winning version, once picked.
min 1
testSentAtstring | nullrequiredWhen every test message was queued.
date-time
decidedAtstring | nullrequiredWhen the winner was picked.
date-time
statusstringrequiredWhere the campaign is in its lifecycle.
testing: an A/B test went out and the rest of the audience waits for the winner.sent: every message was created and queued; it says nothing about delivery, whichGET /v1/campaigns/{id}/metricsreports (some may still be queued, skipped or failed).one of
draft,scheduled,sending,testing,sent,cancelledscheduleobject | nullrequiredWhen it sends:
fixed, everyone at one instant, orlocal_time, each contact at a time on their own clock. Set while it isscheduled; a local-time schedule stays set once sending starts, since each contact's time still decides when theirs goes.nullotherwise.One of 2 shapes
- Fixed time
2 child attributes
type"fixed"requiredsendAtstringrequiredThe instant everyone receives it at.
date-time
- Local time
5 child attributes
type"local_time"requiredlocalDateTimestringrequiredThe wall-clock time (
YYYY-MM-DDTHH:MM, no timezone) each contact receives it at on their own clock. It may already have passed in some timezones, not in all.pattern
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$timezoneIfUnknownstring | nullrequiredThe IANA timezone for contacts without one;
null: the workspace's.ifTimeHasPassedstringrequiredWhere the time has already gone when it is scheduled:
send_nowsends there at once,next_dayat the same time the next day, andskipleaves those contacts out (skipped withlocal_time_passed).one of
send_now,skip,next_daystartsAtstringrequiredWhen sending starts: the earliest timezone reaching
localDateTime.date-time
sentAtstring | nullrequiredWhen sending started; set from
sendingon (testing, sent, cancelled),nullbefore. A local-time campaign starts in the earliest timezone.date-time
deliveryCampaignDeliveryrequiredHow fast it goes out, and until when; frozen with its content at send.
2 child attributes
rateLimitobject | nullrequiredHow fast it goes out;
nullas fast as the plan allows. The plan's own send rate still applies, so a campaign can only slow a send down.2 child attributes
recipientsintegerrequiredAt most this many recipients per
per, spread evenly across it. Counts people, so one person's email and push go together.min 1 · max 1000000
perstringrequiredThe period the limit counts over.
one of
minute,hour,day
expiresAfterobject | nullrequiredFrom when sending starts, from 1 to 720 hours: recipients not yet sent when it passes are skipped with reason
expired. A rate-limited send always expires, after 720 hours unless set. With an A/B test it must outlastabTest.decideAfter.null: no expiry.2 child attributes
valueintegerrequiredmin > 0
unitstringrequiredone of
seconds,minutes,hours,days
pendingAgentReviewbooleanrequiredAn agent key authored or edited it and it is still a draft, so it waits in the agent review queue: sending needs a person's approval.
sendApprovalRequestobject | nullrequiredThe latest request, from a member in the dashboard, that an admin send it while the workspace keeps sending to admins; kept after it sends, cleared by any edit before then.
3 child attributes
userIdstringrequiredThe member who asked.
uuid
requestedAtstringrequireddate-time
notestring | nullrequired
archivedAtstring | nullrequiredWhen it was archived; archived campaigns are left out of the list by default.
date-time
tagsstring[]requiredTag names, sorted without case.
revisionintegerrequiredRaised by every edit. Send it back as
expectedRevisionon the update so a change made since you read it is refused instead of overwritten.min > 0 · max 2147483647
createdAtstringrequireddate-time
updatedAtstringrequireddate-time
notFoundobject[]requiredRecipients that name no contact in the workspace, as listed; not sent.
Any of 3 shapes
- By contact id
1 child attribute
contactIdstringrequiredKirora's id for the contact.
uuid
- By external id
1 child attribute
externalIdstringrequiredYour own id for the contact, as set with identify.
1–255 characters
- By email
1 child attribute
emailstringrequiredThe contact's email address, matched trimmed and without case.
email · up to 320 characters
Headers on 202 Accepted
Idempotency-Replaystringoptionaltruewhen this is the stored response to an earlier request with the same key.one of
true