Getting Started

Setting Up Webhooks

Receive real-time notifications when events happen in TempClock by setting up webhook subscriptions.

8 min read

Before You Start

Make sure you have everything you need to get up and running with webhooks.

Before you start

  • A TempClock account with API access enabled (see API Setup Guide)
  • An active API key with the webhooks:write scope
  • An HTTPS endpoint on your server to receive webhook events
  • Basic understanding of HTTP POST requests and JSON
Note

Webhooks are ideal for CRM/ATS integrations (e.g. Salesforce, Bullhorn). Instead of polling the API for changes, your system gets notified instantly when clock-ins, worker updates, and shifts happen.

What Are Webhooks?

Understand how TempClock webhooks work before setting one up.

Webhooks are automatic HTTP POST requests that TempClock sends to your server whenever specific events occur. Think of them as real-time notifications:

A worker clocks in → your CRM gets notified immediately
A shift is created → your scheduling system updates automatically
A worker record changes → your payroll sync stays up to date

Each webhook delivery includes the event type, a timestamp, and the relevant data, all signed with HMAC-SHA256 so you can verify authenticity.

Note

TempClock supports these events: clock_in, clock_out, worker_created, worker_updated, shift_created, document_expired, and ping (for testing).

Step 1: Create a Webhook Subscription

Register your endpoint URL and choose which events to receive.

Send a POST request to the webhooks endpoint with your HTTPS URL and the events you want to subscribe to:

Terminal — Create webhook subscription
$ curl -X POST \
"https://tempclock.com/api/v1/webhooks.php" \
-H "Authorization: Bearer tc_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"url":"https://your-system.com/webhooks/tempclock","events":["clock_in","clock_out"],"description":"My CRM integration"}'

The response will include a signing secret. This is only shown once, so copy and store it securely:

API Response — 201 Created
{
"data": {
"id": 1,
"url": "https://your-system.com/webhooks/tempclock",
"events": ["clock_in", "clock_out"],
"secret": "a1b2c3d4e5f6g7h8..."
},
"message": "Webhook subscription created."
}
Important

Security: Store the signing secret in a secure location such as a password manager or environment variable. If you lose it, you will need to delete and re-create the subscription to get a new secret.

Step 2: Verify Webhook Signatures

Always validate that webhook deliveries genuinely came from TempClock.

Every webhook delivery includes an X-TempClock-Signature header. Compute the HMAC-SHA256 of the raw request body using your signing secret and compare it:

PHP — Signature verification
// Get the raw POST body and signature header
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_TEMPCLOCK_SIGNATURE'];
$expected = 'sha256=' . hash_hmac('sha256', $payload, $secret);
 
// Use constant-time comparison
if (!hash_equals($expected, $signature)) {
http_response_code(401);
die('Invalid signature');
}
Tip

Always use constant-time comparison functions like hash_equals() in PHP or hmac.compare_digest() in Python to prevent timing attacks.

Step 3: Test Your Endpoint

Send a test ping to make sure everything is connected correctly.

Use the test action to send a ping event to your endpoint:

Terminal — Send test ping
$ curl -X POST \
"https://tempclock.com/api/v1/webhooks.php?id=1&action=test" \
-H "Authorization: Bearer tc_live_YOUR_KEY_HERE"

Your endpoint should receive a JSON payload like this:

Webhook payload — ping event
{
"event": "ping",
"timestamp": "2026-03-16T14:30:00Z",
"delivery_id": 1,
"data": {
"message": "This is a test ping from the TempClock API."
}
}
Tip

If the test fails, check that your endpoint returns a 200 response code and that your URL is correct and accessible from the internet.

Step 4: Handle Incoming Events

Process webhook events in your application.

Each event has a different data payload. Here is what you can expect for the most common events:

clock_in

entry_id, worker_id, worker_name, clock_in timestamp, location_id

clock_out

entry_id, worker_id, worker_name, clock_in, clock_out, total_minutes, location_id

worker_updated

worker_id, worker_name, list of fields that changed

shift_created

shift_id, worker_id, location_id, shift_date, start_time, end_time

Note

Best practice: Return a 200 response immediately and process the event asynchronously (e.g. via a job queue). This prevents timeouts if your processing takes more than a few seconds.

Step 5: Monitor Deliveries

Track delivery status and check for failures.

Fetch a subscription by ID to see the last 10 delivery attempts:

Terminal — Check delivery status
$ curl \
"https://tempclock.com/api/v1/webhooks.php?id=1" \
-H "Authorization: Bearer tc_live_YOUR_KEY_HERE"

The response includes a recent_deliveries array showing the event type, response code, attempt number, and timestamps for each delivery.

Delivered: Response code 2xx — your endpoint acknowledged the event
Retrying: Non-2xx response — TempClock will retry with exponential backoff (1m, 5m, 30m, 2h)
Failed: After 5 attempts — delivery is permanently marked as failed
Important

If you see consistent failures, check your endpoint's error logs and ensure it is returning a 2xx status code. Common issues include SSL certificate problems, firewall rules, and application errors.

Troubleshooting

Common issues and how to resolve them.

Not receiving webhooks

Verify your subscription is active, your URL is correct, and your server is accessible from the internet.

Signature mismatch

Make sure you are comparing against the raw request body (not parsed JSON) and using the correct signing secret.

401 errors from API

Check that your API key has the webhooks:read and webhooks:write scopes.

Timeouts / 5xx errors

Your endpoint must respond within 30 seconds. Process events asynchronously if your logic is complex.

Ready to try TempClock?

10-day free trial. All features included. No hidden fees, cancel anytime.