Email Countdowns.
AI automation guide

Automate countdowns in Resend Broadcasts

Let OpenClaw or Claude Code create a live countdown GIF, place it in a Resend Broadcast, and leave the Broadcast safely in draft for review.

Before you start

Email Countdowns

An API key and the timer's name, date, time, and IANA timezone.

Get your API key →

Resend

A Resend API key, a verified sender, and the ID of the target Segment.

Create Broadcast docs ↗
Keep credentials out of chat and source control. Put keys in trusted environment or global secret storage, expose only the variable names the agent needs, and confirm both accounts are connected before asking it to act.

End-to-end workflow

  1. Create the countdown POST the timer settings to Email Countdowns with a Bearer API key.
  2. Read the result Keep data.embed_html for the email and data.gif_url for logs or a direct preview.
  3. Build the Broadcast HTML Insert embed_html into the message and include Resend’s unsubscribe variable.
  4. Create a draft Call Resend’s /broadcasts create API with segmentId, from, subject, html, and send:false.
  5. Preview, then approve Check the recipient segment, sender, links, timer deadline, desktop and mobile rendering before any separate send or schedule action.

The two API calls

Email Countdowns accepts a Bearer key. Its GIF is generated when the recipient opens the email, so the same image URL continues to show the current remaining time rather than a frozen value.

Create the countdown

curl https://emailcountdowns.com/api/countdowns \
  --request POST \
  --header "Authorization: Bearer ${EMAIL_COUNTDOWNS_API_KEY}" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "Summer sale broadcast",
    "date": "2026-08-31",
    "time": "23:59",
    "timezone": "Europe/London",
    "text_colour": "#ffffff",
    "background_colour": "#111827"
  }'

Relevant response fields

{
  "data": {
    "id": "COUNTDOWN_ID",
    "gif_url": "https://emailcountdowns.com/countdown/public/COUNTDOWN_ID.gif",
    "embed_html": "<img src=\\"https://emailcountdowns.com/countdown/public/COUNTDOWN_ID.gif\\" alt=\\"Summer sale broadcast\\" width=\\"300\\" style=\\"max-width:100%;border:0;display:block;\\" />"
  }
}

With the Resend Node SDK, broadcasts.create calls the Broadcast create endpoint. Resend defaults send to false; setting it explicitly makes the safety boundary obvious.

Node.js — create a draft

import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

const countdownResult = await fetch(
  'https://emailcountdowns.com/api/countdowns',
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.EMAIL_COUNTDOWNS_API_KEY}`,
      Accept: 'application/json',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Summer sale broadcast',
      date: '2026-08-31',
      time: '23:59',
      timezone: 'Europe/London',
    }),
  },
);

if (!countdownResult.ok) throw new Error('Countdown creation failed');
const { data: countdown } = await countdownResult.json();

const { data: broadcast, error } = await resend.broadcasts.create({
  segmentId: process.env.RESEND_SEGMENT_ID,
  from: process.env.RESEND_FROM,
  subject: 'Summer sale ends soon',
  html: `<h1>Summer sale</h1>
    <p>Offer ends when this timer reaches zero.</p>
    ${countdown.embed_html}
    <p><a href="{{{RESEND_UNSUBSCRIBE_URL}}}">Unsubscribe</a></p>`,
  send: false,
});

if (error) throw error;
console.log({ countdownId: countdown.id, broadcastId: broadcast.id });

Use OpenClaw

Store secrets in trusted/global configuration and give OpenClaw a precise, draft-only instruction. It still needs tools and account access capable of making the two API calls.

Prompt for OpenClaw

Read https://emailcountdowns.com/ai.md and Resend's current Create Broadcast documentation before acting.

Use only the credentials already available from trusted/global secret storage as EMAIL_COUNTDOWNS_API_KEY and RESEND_API_KEY. Never print them, paste them into files, or commit them. Confirm that RESEND_SEGMENT_ID and RESEND_FROM are configured.

Create an Email Countdowns timer named “Summer sale broadcast” for 31 August 2026 at 23:59 Europe/London. Take data.embed_html from the response and insert it into a Resend Broadcast with subject “Summer sale ends soon”. Include {{{RESEND_UNSUBSCRIBE_URL}}} in the HTML.

Create a draft only: omit send or set send:false. Do not send or schedule anything. Return the countdown ID, GIF URL, broadcast ID, and any available preview/dashboard URL, then stop and wait for my approval.

Use Claude Code

Start an interactive session in a clean working folder with your variable names already available to the process:

Terminal

claude --permission-mode plan

Then paste this task. Review its plan and approve only the calls you expect. A reusable local script is useful for future Broadcasts, but keep secret files ignored and never commit credentials.

Prompt for Claude Code

Plan this task first and ask before making network requests that create resources.

Read https://emailcountdowns.com/ai.md and https://resend.com/docs/api-reference/broadcasts/create-broadcast. Use EMAIL_COUNTDOWNS_API_KEY, RESEND_API_KEY, RESEND_SEGMENT_ID, and RESEND_FROM from the environment; never reveal or write secret values.

Create a small reusable Node script that:
1. creates an Email Countdowns timer for 2026-08-31 23:59 in Europe/London;
2. inserts response.data.embed_html into a Resend Broadcast HTML body;
3. includes {{{RESEND_UNSUBSCRIBE_URL}}};
4. creates the Broadcast as a draft with send:false;
5. prints only the countdown ID, data.gif_url, Broadcast ID, and a preview/dashboard URL if the API returns one.

Run it only after I approve the plan. Never send or schedule the Broadcast; stop for human preview and approval.
Claude Code CLI reference ↗

The automation stops at draft

Treat sending as a second, separately approved task. First open the draft, send a test if appropriate, verify the unsubscribe link and timer at multiple widths, and confirm the final audience. Only then ask the tool to send or schedule the known Broadcast ID.

Campaign automation guide