Klaviyo Campaigns

Reads and writes Klaviyo campaigns, their messages and their variations.

Configuration

- klaviyo_campaigns:
    name: find_campaign
    operation: list
    credentials_path: /etc/klaviyo/credentials.json
    filter: "contains(name,'{{event.data.name}}')"

Fields

FieldTypeDefaultDescription
namestringrequiredTask name.
operationstringrequiredSee the table below.
credentials_pathstringrequiredPath to the credentials file.
base_urlstringKlaviyo’sKlaviyo API address, for example a proxy.
campaign_idstringCampaign ID.
message_idstringCampaign message ID for variations.
variation_idstringCampaign variation ID for update_variation.
filterstringKlaviyo filter for list, e.g. equals(archived,false).
payloadobjectThe campaign’s or variation’s attributes, or from_event: true. See Payload.
depends_onlistUpstream task names.
retryobjectRetry configuration.

Operations

OperationNeedsWhat it does
getcampaign_idGets the campaign.
listLists campaigns, narrowed by filter if set. Klaviyo filters campaigns on id, name, archived, builder, created_at and updated_at; name takes only contains, so an exact name match is checked after the list.
createpayloadCreates a draft campaign with its audiences, messages and variations.
updatecampaign_id, payloadUpdates the campaign’s definition.
deletecampaign_idDeletes the campaign.
clonecampaign_idCopies the campaign, named payload.name if set.
messagescampaign_idLists the campaign’s messages.
variationsmessage_idLists the message’s variations, each with its subject, sender and template_id.
update_variationvariation_id, payloadUpdates the variation. Only the fields in payload are sent, so {definition: {details: {channel: email, template_id: ...}}} changes the template and keeps the subject.
sendcampaign_idSends or schedules the campaign as its send settings say. Delivers real messages and is never retried.

A campaign is created with its audiences and messages inline. A message refers to its audience by audience_temporary_id, and each variation carries the subject, sender and template:

{
  "definition": { "name": "Spring newsletter" },
  "audiences": [{ "temporary_id": "newsletter", "included": ["LIST_ID"] }],
  "messages": [{
    "audience_temporary_id": "newsletter",
    "name": "Spring newsletter",
    "variations": [{
      "definition": {
        "name": "Spring newsletter",
        "details": {
          "channel": "email",
          "subject": "What's new this spring",
          "template_id": "TEMPLATE_ID"
        }
      }
    }]
  }]
}

Output

The Klaviyo response as JSON. list emits one event per page, with the campaigns in data. delete emits {"id": "...", "done": true}.