Error Handling
When something goes wrong, the TempClock API returns a consistent error response format. This page covers every error code, what causes it, and how to fix it.
Error Response Format
All errors follow the same JSON structure, making them easy to handle in your code:
| Field | Type | Description |
|---|---|---|
| error | boolean | Always true for error responses. |
| message | string | A human-readable explanation of the error. |
| status | integer | The HTTP status code (matches the response header). |
Error Code Quick Reference
| Status | Name | Common Cause |
|---|---|---|
| 400 | Bad Request | Missing or invalid parameters |
| 401 | Unauthorized | Missing, invalid, or expired API key |
| 403 | Forbidden | API not enabled or insufficient scope |
| 404 | Not Found | Resource does not exist or belongs to another client |
| 405 | Method Not Allowed | Wrong HTTP method for this endpoint |
| 409 | Conflict | Worker already clocked in / no open clock-in to close |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Unexpected server-side error |
Bad Request
The request could not be processed because of missing or invalid parameters. Check the message field for details on which parameter is invalid.
Common Causes
- Missing required fields in a POST request body (e.g. worker_id, action)
- Invalid date format (expected YYYY-MM-DD)
- Invalid value for action (must be "in" or "out")
- Malformed JSON in the request body
Example Response
Unauthorized
The request lacks valid authentication credentials. The API could not identify you based on the provided Authorization header.
Common Causes
- No Authorization header included in the request
- Using Token instead of Bearer prefix
- API key has been revoked or deactivated in the manage portal
- API key has passed its expiry date
- Typo or truncation in the API key value
Example Responses
Forbidden
The API key is valid, but does not have permission to perform this action. This is different from 401 — the key is recognised, but access is denied.
Common Causes
- API access has not been enabled for the account (contact TempClock)
- The API key does not have the required scope for this endpoint (e.g. trying to use /clock.php without clock:write)
Example Responses
Not Found
The requested resource does not exist. For security reasons, the API also returns 404 when a resource exists but belongs to another client — you will never be told about resources outside your account.
Common Causes
- The id parameter refers to a worker, location, or resource that does not exist
- The resource belongs to a different client account
- The resource was deleted
Example Response
Method Not Allowed
The HTTP method used is not supported for this endpoint. The response includes an Allow header indicating which methods are accepted.
Common Causes
- Sending a POST request to a GET-only endpoint (e.g. POST /workers.php)
- Sending a GET request to a POST-only endpoint (e.g. GET /clock.php)
- Using PUT or DELETE (not currently supported)
Example Response
Conflict
The request conflicts with the current state of the resource. This is specific to the /clock.php endpoint.
Common Causes
- Attempting to clock in a worker who is already clocked in
- Attempting to clock out a worker who has no open clock-in entry
Example Responses
Too Many Requests
You have exceeded the rate limit of 60 requests per minute for this API key. The response includes a Retry-After header indicating how many seconds to wait.
Example Response
Internal Server Error
An unexpected error occurred on the server. This is not caused by your request — it indicates a problem on the TempClock side.
Example Response
Handling Errors in Your Code
Always check the HTTP status code of the response. For non-2xx codes, parse the error JSON and handle accordingly: