Email Countdowns.
AI automation guide

Automate countdowns in Klaviyo Campaigns

Let OpenClaw or Claude Code create a live countdown, build a Klaviyo CODE template, and attach it to a draft email Campaign without sending it.

Before you start

Email Countdowns

An API key plus the timer name, deadline, and IANA timezone.

Get your API key →

Klaviyo

A private API key with the needed template and campaign scopes, sender details, and an audience list or segment ID.

Campaigns API overview ↗
Keep credentials out of prompts, logs, and Git. Put them in trusted environment or global secret storage and expose only the variable names required for the run.

The verified sequence

This integration is a chain of resources, not one “create countdown Campaign” endpoint. Keep each returned ID for the next call.

  1. Create the countdown POST name, date, time, timezone and optional styling to Email Countdowns.
  2. Create a CODE template Insert response.data.embed_html into the template HTML, including Klaviyo’s required unsubscribe content.
  3. Create a draft email Campaign Target the intended list or segment and use the current Campaigns API request shape. Keep it in draft.
  4. Get the Campaign message Retrieve the email Campaign’s message and save its message ID.
  5. Assign the template POST the campaign-message and template relationship to campaign-message-assign-template.
  6. Preview and test Check rendering, audience, sender, subject, links and timer deadline. Schedule or send only as a separate, human-approved action.

Focused API snippets

Create the timer with a Bearer key. The useful response values are data.embed_html and data.gif_url. The GIF is generated dynamically when the email is opened, so it continues to display the current remaining time.

Email Countdowns request

POST https://emailcountdowns.com/api/countdowns
Authorization: Bearer ${EMAIL_COUNTDOWNS_API_KEY}
Accept: application/json
Content-Type: application/json

{
  "name": "VIP launch campaign",
  "date": "2026-09-15",
  "time": "18:00",
  "timezone": "America/New_York",
  "text_colour": "#ffffff",
  "background_colour": "#111827"
}

Use these headers on Klaviyo requests. This guide was verified against revision 2026-07-15; when you automate later, check the official reference before changing the revision or request shape.

Klaviyo request headers

Authorization: Klaviyo-API-Key ${KLAVIYO_API_KEY}
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
revision: 2026-07-15

Replace COUNTDOWN_EMBED_HTML with the exact HTML returned by Email Countdowns. A CODE template uses the html attribute rather than the drag-and-drop template definition.

Create the CODE template

POST https://a.klaviyo.com/api/templates

{
  "data": {
    "type": "template",
    "attributes": {
      "name": "VIP launch countdown",
      "editor_type": "CODE",
      "html": "<html><body><h1>VIP launch</h1><p>We launch when the timer reaches zero.</p>COUNTDOWN_EMBED_HTML<p>{% unsubscribe %}</p></body></html>"
    }
  }
}

After creating the draft email Campaign, retrieve its Campaign message ID. Then assign the reusable template; Klaviyo clones it into a non-reusable version attached to that message.

Assign template to Campaign message

POST https://a.klaviyo.com/api/campaign-message-assign-template

{
  "data": {
    "type": "campaign-message",
    "id": "CAMPAIGN_MESSAGE_ID",
    "relationships": {
      "template": {
        "data": {
          "type": "template",
          "id": "TEMPLATE_ID"
        }
      }
    }
  }
}
The full Campaign payload changes as Klaviyo evolves and depends on audience and sender configuration. Have the agent read the current Campaigns reference and build only the fields needed for your account instead of copying an oversized, brittle example.

Use OpenClaw

OpenClaw needs tools with access to both APIs. Give it the resource sequence and an explicit stop condition so campaign sending remains a human decision.

Prompt for OpenClaw

Read https://emailcountdowns.com/ai.md plus Klaviyo's current Templates, Campaigns, and Assign Template to Campaign Message API documentation before acting.

Use EMAIL_COUNTDOWNS_API_KEY and KLAVIYO_API_KEY only from trusted/global secret storage. Never display the values, paste them into chat, write them to tracked files, or commit them. Confirm KLAVIYO_AUDIENCE_ID and the sender details are configured and that the key has templates:write and campaigns:write access.

Create an Email Countdowns timer named “VIP launch campaign” for 15 September 2026 at 18:00 America/New_York. Use response.data.embed_html inside a Klaviyo CODE HTML template, with a valid unsubscribe tag.

Then create a DRAFT email campaign for KLAVIYO_AUDIENCE_ID using Klaviyo's current revision 2026-07-15 schema, retrieve its campaign message ID, and assign the template with POST https://a.klaviyo.com/api/campaign-message-assign-template. Do not schedule or send it.

Return the countdown ID and GIF URL, template ID, campaign ID, campaign message ID, and available preview/dashboard URLs. Stop and wait for my approval after preview/test checks.

Use Claude Code

Start Claude Code interactively in a clean folder. Plan mode lets you review the intended script and API sequence before permitting actions:

Terminal

claude --permission-mode plan

Paste the task below, then review each resource-creating call. Keep generated secret files ignored and do not commit them.

Prompt for Claude Code

Work interactively: make a plan, verify it against the current official API references, and request permission before API calls that create resources.

Use EMAIL_COUNTDOWNS_API_KEY, KLAVIYO_API_KEY, and KLAVIYO_AUDIENCE_ID from the environment. Never reveal secret values or put them in generated files. Use Klaviyo headers Authorization: Klaviyo-API-Key, application/vnd.api+json, and revision 2026-07-15.

Generate a reusable local script that follows this exact draft-first sequence:
1. POST a timer for 2026-09-15 18:00 America/New_York to https://emailcountdowns.com/api/countdowns.
2. Create a Klaviyo CODE HTML template containing response.data.embed_html and a valid unsubscribe tag.
3. Create a draft EMAIL campaign for the configured list or segment using the current Campaigns API request shape; do not invent or reuse stale fields.
4. Retrieve the campaign's message ID.
5. Assign the template with POST https://a.klaviyo.com/api/campaign-message-assign-template.
6. Return resource IDs and preview/test information, then stop.

Do not call a schedule or send endpoint. Run the script only after I approve your plan.
Claude Code CLI reference ↗

Preview before the irreversible step

The successful result is a draft Campaign, not a send. Preview the generated template, send a test where appropriate, confirm consent and audience selection, and inspect desktop and mobile output. Only a later, explicitly approved task should call Klaviyo’s schedule or send APIs.

Official Klaviyo references

Campaign automation guide