ZapSMTP / Docs / Modules, images & timersResponse
Create a countdown timer
POST/v1/template-timers
Create a countdown timer image: an animated GIF that shows the time left whenever the email is opened.
Requires a full-access live key; test keys get 403 test_key_restricted.
Nothing is stored: the URL carries the signed settings, so changing it breaks the image. Put it in an <img> of a template (the visual editor’s timer block does this for you).
Each open renders one frame per second for a minute, then the last frame stays; after end it shows zeros. Renders are shared for 5 seconds, so a broadcast opened by many recipients at once costs one render.
Body parameters
endstring (RFC 3339)required- When the countdown reaches zero. Limits: missing → 422 invalid_parameter "end is required"; not RFC 3339 → 400 validation_error
widthinteger- Image width in px, 200-600; the height follows. Limits: otherwise 422 invalid_parameter "w must be 200–600" Default
600. digit_colorstringrequired- Digit colour, hex
RRGGBBorRRGGBBAA(a leading # is allowed). Limits: otherwise 422 invalid_parameter "fg: colour must be RRGGBB or RRGGBBAA" label_colorstringrequired- Label colour, same format. Limits: 422 invalid_parameter "lc: …"
backgroundstringrequired- Background colour, same format; alpha
00(e.g.ffffff00) is transparent. Limits: 422 invalid_parameter "bg: …" labelsstring[]- Exactly 4 labels under days, hours, minutes and seconds, each up to 12 characters, without
|.""hides one label; four empty labels hide the label row. Limits: 422 invalid_parameter "l must hold 4 labels separated by |" / "labels are limited to 12 characters" Default["days", "hours", "minutes", "seconds"].
Errors
validation_errorHTTP 400- invalid JSON body (e.g. end not RFC 3339)
restricted_api_keyHTTP 403test_key_restrictedHTTP 403- test-mode keys can send test email and read, not change the account: use a live key
invalid_parameterHTTP 422- see the fields
curl -X POST 'https://zapsmtp.xyz/v1/template-timers' \
-H "Authorization: Bearer $ZAP_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"end": "2026-11-28T23:59:59Z",
"digit_color": "111827",
"label_color": "6b7280",
"background": "ffffff"
}'const res = await fetch('https://zapsmtp.xyz/v1/template-timers', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ZAP_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"end": "2026-11-28T23:59:59Z",
"digit_color": "111827",
"label_color": "6b7280",
"background": "ffffff"
}),
});
// 204 No Content (e.g. a delete) has no body
const data = res.status === 204 ? null : await res.json();
if (!res.ok) throw new Error(`${data.name}: ${data.message}`);
console.log(data);import os
import requests
res = requests.post(
"https://zapsmtp.xyz/v1/template-timers",
headers={"Authorization": f"Bearer {os.environ['ZAP_API_KEY']}"},
json={
"end": "2026-11-28T23:59:59Z",
"digit_color": "111827",
"label_color": "6b7280",
"background": "ffffff",
},
timeout=30,
)
res.raise_for_status()
print(res.json() if res.status_code != 204 else "deleted")<?php
$ch = curl_init('https://zapsmtp.xyz/v1/template-timers');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZAP_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'end' => '2026-11-28T23:59:59Z',
'digit_color' => '111827',
'label_color' => '6b7280',
'background' => 'ffffff',
]),
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
throw new RuntimeException($data['message']);
}
print_r($data);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"end": "2026-11-28T23:59:59Z",
"digit_color": "111827",
"label_color": "6b7280",
"background": "ffffff"
}`)
req, err := http.NewRequest(
"POST",
"https://zapsmtp.xyz/v1/template-timers",
body,
)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ZAP_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(out))
}require 'net/http'
require 'json'
uri = URI('https://zapsmtp.xyz/v1/template-timers')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = "Bearer #{ENV.fetch('ZAP_API_KEY')}"
req['Content-Type'] = 'application/json'
req.body = {
end: "2026-11-28T23:59:59Z",
digit_color: "111827",
label_color: "6b7280",
background: "ffffff"
}.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.code, (JSON.parse(res.body) unless res.body.to_s.empty?)import java.net.URI;
import java.net.http.*;
public class ZapRequest {
public static void main(String[] args) throws Exception {
var request = HttpRequest.newBuilder(URI.create("https://zapsmtp.xyz/v1/template-timers"))
.header("Authorization", "Bearer " + System.getenv("ZAP_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"end": "2026-11-28T23:59:59Z",
"digit_color": "111827",
"label_color": "6b7280",
"background": "ffffff"
}"""))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var http = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://zapsmtp.xyz/v1/template-timers");
request.Headers.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ZAP_API_KEY"));
request.Content = new StringContent("""
{
"end": "2026-11-28T23:59:59Z",
"digit_color": "111827",
"label_color": "6b7280",
"background": "ffffff"
}
""", Encoding.UTF8, "application/json");
var response = await http.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");Set
ZAP_API_KEY in your environment.Response 200 OK
{
"object": "template_timer",
"url": "https://zapsmtp.xyz/i/timer.gif?bg=ffffff&end=1795910399&fg=111827&l=days%7Chours%7Cminutes%7Cseconds&lc=6b7280&w=600&sig=Hk3x9vQm2LrT8aWc"
}