API Reference

Complete reference for Castimer's REST API, Embed Widget, Webhooks, and quick start guides.

REST API

Authentication

All API requests require a Bearer token in the Authorization header. Get your API key from the Dashboard.

Authorization: Bearer YOUR_API_KEY

Base URL & Headers

Base URL: https://castimer.com/api/v1

HeaderValueRequired
AuthorizationBearer {api_key}Yes
Content-Typeapplication/jsonYes (POST/PATCH)
Acceptapplication/jsonNo

Endpoints

GET/events

List all timer events for the authenticated user.

curl -X GET https://castimer.com/api/v1/events \
  -H "Authorization: Bearer YOUR_API_KEY"
POST/timers

Create a new timer.

curl -X POST https://castimer.com/api/v1/timers \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Meeting Timer",
    "type": "countdown",
    "duration": 1800
  }'
GET/timers/:id

Get a specific timer by ID.

curl -X GET https://castimer.com/api/v1/timers/tmr_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"
PATCH/timers/:id/state

Update timer state (start, pause, resume, reset).

curl -X PATCH https://castimer.com/api/v1/timers/tmr_abc123/state \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "state": "running" }'
DELETE/timers/:id

Delete a timer.

curl -X DELETE https://castimer.com/api/v1/timers/tmr_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Error Codes

CodeMeaning
400Bad Request — Invalid parameters
401Unauthorized — Invalid or missing API key
404Not Found — Timer not found
422Unprocessable — Validation error
429Too Many Requests — Rate limit exceeded
500Internal Server Error

Rate Limits

PlanRequests/minRequests/day
Free301,000
Pro12010,000
Enterprise600Unlimited

SDK & Libraries

Official and community SDKs for popular languages and frameworks.

JavaScript/TypeScript
OfficialGitHub
Python
OfficialGitHub
PHP
CommunityGitHub

Embed Widget

Widget URL Format

The widget is served at a single URL with query parameters for configuration:

https://castimer.com/widget?type=countdown&title=My+Timer&duration=300&theme=dark&primary_color=6C63FF&lang=en

Parameters Reference

ParameterTypeDefaultDescription
typestringcountdownTimer type: countdown, event, interval
titlestring-Display title
durationnumber-Countdown duration in seconds
target_datestring-Target date (ISO8601), for event type
timezonestringUTCTimezone for event type
worknumber20Work duration in seconds, for interval type
restnumber10Rest duration in seconds, for interval type
roundsnumber8Number of rounds, for interval type
themestringdarkTheme: light, dark, auto
primary_colorstring6C63FFPrimary color (hex without #)
langstringenLanguage: en, zh, ja, es, fr, de, ko
show_title0|11Show title
show_date0|11Show date (event type only)
alarm0|11Play alarm sound on completion
show_brand0|11Show Castimer branding (Pro)

iframe Integration

Embed the widget using a standard iframe element:

<iframe
  src="https://castimer.com/widget?type=countdown&duration=300&theme=dark"
  style="width:360px;height:360px;border:none;"
  loading="lazy"
  title="Countdown Timer"
></iframe>

style — Set width and height (min 100×200, max 600×600)

loading="lazy" — Recommended for performance

title — Accessibility label

Embed Generator Tool

Use our visual Embed Generator to configure your widget and generate iframe code instantly. No need to manually construct URLs.

Tip: The generator provides a live preview, so you can see exactly how your widget will look before copying the code.

Webhooks

Get real-time notifications when timer events occur. For full documentation, see the Webhooks Guide.

Overview

Webhooks let Castimer notify your server in real-time when a timer event occurs — such as start, pause, or completion. Register a webhook URL when creating or updating a timer.

Event Types

EventTrigger
timer.startedTimer started running
timer.pausedTimer paused
timer.resumedTimer resumed from paused
timer.completedTimer reached zero
timer.resetTimer reset to initial duration
interval.round_endInterval timer round completed
interval.completedAll interval rounds completed

Payload Format

{
  "event": "timer.completed",
  "timestamp": "2026-05-10T14:30:00Z",
  "timer_id": "tmr_abc123xyz",
  "title": "Flash Sale Countdown",
  "type": "event",
  "data": {
    "state": "completed",
    "duration": 1800,
    "actual_duration": 1803,
    "started_at": "2026-05-10T14:00:00Z",
    "completed_at": "2026-05-10T14:30:00Z"
  },
  "signature": "sha256=a8f3b2c..."
}

Signature Verification

Castimer signs each webhook with HMAC-SHA256. The signature is included in the X-Castimer-Signature header.

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  return `sha256=${expected}` === signature;
}

Retry Behavior

If your endpoint returns a non-2xx response or times out, Castimer retries with exponential backoff:

1Attempt 1Immediate (initial)
2Attempt 21 minute
3Attempt 35 minutes
4Attempt 430 minutes
5Attempt 52 hours

Quick Start

Create Your First Timer

  1. 1Get your API key from the Dashboard
  2. 2Create a timer via the API:
curl -X POST https://castimer.com/api/v1/timers \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My First Timer",
    "type": "countdown",
    "duration": 300
  }'
  1. 3Use the returned timer ID to control it (start, pause, etc.)

Embed a Widget

  1. 1Open the Embed Generator
  2. 2Configure your timer settings visually
  3. 3Copy the generated iframe code and paste it into your website

Set Up Webhooks

  1. 1Create an endpoint on your server to receive POST requests
  2. 2Include webhook_url when creating a timer
  3. 3Verify the HMAC-SHA256 signature on incoming requests
curl -X POST https://castimer.com/api/v1/timers \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Webhook Timer",
    "type": "countdown",
    "duration": 60,
    "webhook_url": "https://yourapp.com/webhooks/castimer"
  }'