Overview
The WorkTime One REST API allows you to programmatically interact with your WorkTime One account. You can manage employees, track attendance, generate reports, and integrate with smart locks.
Base URL
https://api.worktime.one/v1
Format
JSON
Protocol
HTTPS only
Getting Started
1. Get Your API Key
Log in to your WorkTime One account and navigate to Settings → API Keys to generate your API key.
2. Make Your First Request
Here's a simple example to get your organization information:
curl -X GET https://api.worktime.one/v1/organization \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
3. Response Format
All responses are returned in JSON format:
{
"success": true,
"data": {
"id": "org_123456",
"name": "Acme Corporation",
"employees_count": 42,
"created_at": "2024-01-15T10:30:00Z"
}
}
Authentication
The WorkTime One API uses Bearer token authentication. Include your API key in the Authorization header of every request:
Authorization: Bearer YOUR_API_KEY
Security Note: Never expose your API key in client-side code or public repositories. Always keep it secure on your backend server.
API Key Scopes
You can create API keys with different permission levels:
- Read Only: Can only retrieve data (GET requests)
- Read/Write: Can retrieve and modify data (GET, POST, PUT requests)
- Full Access: Complete access including delete operations
API Endpoints
Employees
/employees
Retrieve a list of all employees in your organization.
Query Parameters
page- Page number (default: 1)limit- Results per page (default: 50, max: 100)department- Filter by department IDstatus- Filter by status (active, inactive)
Example Request
curl -X GET "https://api.worktime.one/v1/employees?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
Example Response
{
"success": true,
"data": [
{
"id": "emp_123456",
"name": "John Doe",
"email": "[email protected]",
"department": "Engineering",
"position": "Senior Developer",
"salary": 75000,
"status": "active",
"created_at": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 42
}
}
/employees
Create a new employee.
Request Body
{
"name": "Jane Smith",
"email": "[email protected]",
"department_id": "dept_789",
"position": "Marketing Manager",
"salary": 65000,
"start_date": "2024-02-01"
}
/employees/:id
Retrieve a specific employee by ID.
/employees/:id
Update an existing employee.
/employees/:id
Delete an employee (soft delete - can be restored).
Attendance
/attendance
Retrieve attendance records.
Query Parameters
employee_id- Filter by employeestart_date- Start date (YYYY-MM-DD)end_date- End date (YYYY-MM-DD)lock_id- Filter by smart lock
Example Response
{
"success": true,
"data": [
{
"id": "att_123456",
"employee_id": "emp_123456",
"employee_name": "John Doe",
"clock_in": "2024-11-18T09:00:00Z",
"clock_out": "2024-11-18T17:30:00Z",
"work_hours": 8.5,
"late_minutes": 0,
"early_departure_minutes": 0,
"lock_id": "lock_789",
"date": "2024-11-18"
}
]
}
/attendance/clock
Manually record clock in/out event.
Request Body
{
"employee_id": "emp_123456",
"type": "clock_in",
"timestamp": "2024-11-18T09:00:00Z",
"lock_id": "lock_789",
"notes": "Manual entry"
}
Reports
/reports/payroll
Generate payroll report with calculated salaries, overtime, and penalties.
Query Parameters
start_date- Start date (required)end_date- End date (required)employee_id- Filter by employeeformat- Response format (json, excel)
/reports/attendance
Generate detailed attendance report with work hours, late arrivals, and absences.
Smart Locks
/locks
Retrieve list of connected TTLock smart locks.
/locks/:id/history
Retrieve lock access history (opens, access method, timestamp).
Example Response
{
"success": true,
"data": [
{
"id": "event_123456",
"lock_id": "lock_789",
"employee_id": "emp_123456",
"employee_name": "John Doe",
"access_method": "fingerprint",
"timestamp": "2024-11-18T09:00:00Z",
"success": true
}
]
}
Rate Limiting
The WorkTime One API enforces rate limits to ensure fair usage and system stability:
Free Plan
100
requests per hour
Paid Plan
1,000
requests per hour
Enterprise
10,000+
requests per hour
Rate Limit Headers
Every API response includes rate limit information:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 995
X-RateLimit-Reset: 1700308800
429 Too Many Requests: If you exceed the rate limit, you'll receive a 429 error. Wait until the reset time before making new requests.
Webhooks
Webhooks allow you to receive real-time notifications when events occur in your WorkTime One account.
Available Events
employee.created- New employee addedemployee.updated- Employee information changedemployee.deleted- Employee removedattendance.clock_in- Employee clocked inattendance.clock_out- Employee clocked outpenalty.created- Late arrival or early departure penaltylock.opened- Smart lock accessed
Webhook Payload Example
{
"event": "attendance.clock_in",
"timestamp": "2024-11-18T09:00:00Z",
"data": {
"employee_id": "emp_123456",
"employee_name": "John Doe",
"lock_id": "lock_789",
"timestamp": "2024-11-18T09:00:00Z",
"method": "fingerprint"
}
}
Setting Up Webhooks
Configure webhooks in your account settings at Settings → Webhooks. Provide your endpoint URL and select the events you want to receive.
SDKs & Libraries
We provide official SDKs to make integration easier:
JavaScript / Node.js
npm install @worktime/api
const WorkTime One = require('@worktime/api');
const client = new WorkTime One('YOUR_API_KEY');
const employees = await client.employees.list();
console.log(employees);
Python
pip install worktime
from worktime import WorkTime
client = WorkTime One("YOUR_API_KEY")
employees = client.employees.list()
print(employees)
PHP
composer require worktime/api
use WorkTime One\Client;
$client = new Client('YOUR_API_KEY');
$employees = $client->employees->list();
print_r($employees);
Ruby
gem install worktime
require 'worktime'
client = WorkTime One::Client.new('YOUR_API_KEY')
employees = client.employees.list
puts employees
Coming Soon: Go, Java, C#, and more SDKs are in development. Check our GitHub for the latest updates.
Error Codes
The WorkTime One API uses standard HTTP status codes to indicate success or failure:
200 OK
Request succeeded
201 Created
Resource created successfully
400 Bad Request
Invalid request parameters
401 Unauthorized
Invalid or missing API key
403 Forbidden
API key doesn't have required permissions
404 Not Found
Resource not found
429 Too Many Requests
Rate limit exceeded
500 Internal Server Error
Something went wrong on our end
Error Response Format
{
"success": false,
"error": {
"code": "invalid_request",
"message": "The 'email' field is required",
"field": "email"
}
}
Need Help?
Our developer support team is here to help you integrate WorkTime One into your applications.