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_KEYBase URL & Headers
Base URL: https://castimer.com/api/v1
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {api_key} | Yes |
| Content-Type | application/json | Yes (POST/PATCH) |
| Accept | application/json | No |
Endpoints
/eventsList all timer events for the authenticated user.
curl -X GET https://castimer.com/api/v1/events \
-H "Authorization: Bearer YOUR_API_KEY"/timersCreate 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
}'/timers/:idGet a specific timer by ID.
curl -X GET https://castimer.com/api/v1/timers/tmr_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"/timers/:id/stateUpdate 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" }'/timers/:idDelete a timer.
curl -X DELETE https://castimer.com/api/v1/timers/tmr_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"Error Codes
| Code | Meaning |
|---|---|
| 400 | Bad Request — Invalid parameters |
| 401 | Unauthorized — Invalid or missing API key |
| 404 | Not Found — Timer not found |
| 422 | Unprocessable — Validation error |
| 429 | Too Many Requests — Rate limit exceeded |
| 500 | Internal Server Error |
Rate Limits
| Plan | Requests/min | Requests/day |
|---|---|---|
| Free | 30 | 1,000 |
| Pro | 120 | 10,000 |
| Enterprise | 600 | Unlimited |
SDK & Libraries
Official and community SDKs for popular languages and frameworks.
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=enParameters Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
| type | string | countdown | Timer type: countdown, event, interval |
| title | string | - | Display title |
| duration | number | - | Countdown duration in seconds |
| target_date | string | - | Target date (ISO8601), for event type |
| timezone | string | UTC | Timezone for event type |
| work | number | 20 | Work duration in seconds, for interval type |
| rest | number | 10 | Rest duration in seconds, for interval type |
| rounds | number | 8 | Number of rounds, for interval type |
| theme | string | dark | Theme: light, dark, auto |
| primary_color | string | 6C63FF | Primary color (hex without #) |
| lang | string | en | Language: en, zh, ja, es, fr, de, ko |
| show_title | 0|1 | 1 | Show title |
| show_date | 0|1 | 1 | Show date (event type only) |
| alarm | 0|1 | 1 | Play alarm sound on completion |
| show_brand | 0|1 | 1 | Show 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
| Event | Trigger |
|---|---|
| timer.started | Timer started running |
| timer.paused | Timer paused |
| timer.resumed | Timer resumed from paused |
| timer.completed | Timer reached zero |
| timer.reset | Timer reset to initial duration |
| interval.round_end | Interval timer round completed |
| interval.completed | All 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:
Quick Start
Create Your First Timer
- 1Get your API key from the Dashboard
- 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
}'- 3Use the returned timer ID to control it (start, pause, etc.)
Embed a Widget
- 1Open the Embed Generator
- 2Configure your timer settings visually
- 3Copy the generated iframe code and paste it into your website
Set Up Webhooks
- 1Create an endpoint on your server to receive POST requests
- 2Include
webhook_urlwhen creating a timer - 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"
}'