Custom API Integrations
Custom API Integrations
Learn how to integrate your own systems with the Shifts platform using our comprehensive REST API, authenticate securely with API tokens, and create custom integrations for your organization’s unique needs.
Overview
The Shifts platform provides a powerful REST API that enables you to build custom integrations with your existing systems. This article explains how to access the API, authenticate your requests, understand the available endpoints, and build reliable integrations that automate workflows between Shifts and your other business systems.
API Capabilities
The Shifts API allows you to programmatically:
- Retrieve and manage shift information
- Access employee data and schedules
- Track attendance records
- Process leave requests
- Generate forecasts and analyze demand signals
- Create and manage bulk operations
- Export and import data
- Receive real-time event notifications via webhooks
Getting Started with API Access
Creating API Tokens
To use the API, you need to create an authentication token:
- Navigate to Admin Settings > API Tokens
- Click Create New Token
- Enter a descriptive name for the token (e.g., “Payroll Integration”)
- Select the permissions needed for your integration
- Optionally set an expiration date for enhanced security
- Click Generate Token
- Important: Copy and securely store the generated token immediately; it will only be displayed once
API Rate Limits
The Shifts API employs rate limiting to ensure system stability:
- Standard limit: 1,000 requests per hour per token
- Burst limit: 100 requests per minute per token
- Rate limit headers are included in all responses
- Exceeding limits results in 429 (Too Many Requests) responses
API Authentication
All API requests require authentication using your API token:
Authorization: Bearer YOUR_API_TOKEN
Example using curl:
curl -X GET "https://yoursubdomain.shifts.com/api/v1/shifts" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"
Key API Endpoints
The Shifts API includes the following primary endpoints:
Shifts Management
GET /api/v1/shifts- List shiftsPOST /api/v1/shifts- Create a new shiftGET /api/v1/shifts/{id}- Get shift detailsPUT /api/v1/shifts/{id}- Update a shiftDELETE /api/v1/shifts/{id}- Delete a shift
Employee Data
GET /api/v1/employees- List employeesGET /api/v1/employees/{id}- Get employee detailsGET /api/v1/employees/{id}/schedule- Get employee schedule
Attendance Management
GET /api/v1/attendance_records- List attendance recordsPOST /api/v1/attendance_records- Create an attendance recordGET /api/v1/attendance_records/{id}- Get attendance detailsPUT /api/v1/attendance_records/{id}- Update an attendance record
Leave Management
GET /api/v1/leave_requests- List leave requestsPOST /api/v1/leave_requests- Submit a leave requestGET /api/v1/leave_requests/{id}- Get leave request detailsPUT /api/v1/leave_requests/{id}- Update a leave request status
Bulk Operations
POST /api/v1/bulk_operations- Create a bulk operationGET /api/v1/bulk_operations/{id}- Check operation status
Forecasting
GET /api/v1/forecasts- List forecastsPOST /api/v1/forecasts- Create a forecastGET /api/v1/demand_signals- Get demand signals
Exports
POST /api/v1/export_files- Request a data exportGET /api/v1/export_files/{id}- Get export file statusGET /api/v1/export_files/{id}/download- Download an export file
Webhook Integration
For real-time event notifications, you can set up webhooks:
- Go to Admin Settings > Integrations > Webhooks
- Click Add Webhook
- Enter the URL where you want to receive webhook events
- Select the events you’re interested in:
shift.created,shift.updated,shift.cancelledshift_assignment.created,shift_assignment.updatedattendance.check_in,attendance.check_out,attendance.missedleave_request.created,leave_request.approved,leave_request.rejected
- The system generates a secret key for secure verification
- Use this key to validate incoming webhook payloads
Webhook Payload Verification
For security, always verify webhook payloads:
- Each webhook request includes an
X-Webhook-Signatureheader - Calculate HMAC-SHA256 of the payload using your secret key
- Compare your calculation with the signature header
- Only process the webhook if signatures match
// Example code for verifying webhook signatures (Node.js)
const crypto = require('crypto');
function verifySignature(payload, signature, secret) {
const hmac = crypto.createHmac('sha256', secret);
const calculatedSignature = 'sha256=' + hmac.update(JSON.stringify(payload)).digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(calculatedSignature)
);
}
Common API Integration Scenarios
HRIS Integration
Synchronize employee data between your HRIS system and Shifts:
- Create a scheduled job that pulls employee data from your HRIS
- Map HRIS fields to Shifts API fields
- Use the Shifts API to create or update employee records
- Set up webhooks to receive notifications of employee updates in Shifts
Payroll Integration
Automatically send timesheet data to your payroll system:
- Create a scheduled job that runs before each pay period
- Use the Shifts API to retrieve attendance records for the period
- Calculate hours worked, including regular and overtime
- Format and send the data to your payroll system’s API
Business Intelligence Integration
Feed workforce data into your BI tools:
- Use the Shifts API to export shift, attendance, and cost data
- Transform the data to match your data warehouse schema
- Import the data into your BI platform
- Create dashboards that combine Shifts data with other business metrics
Best Practices
For reliable API integration:
- Use Webhooks for Real-Time Updates: Instead of frequent polling
- Implement Proper Error Handling: Account for API rate limits and server errors
- Cache Data When Appropriate: Reduce API calls for frequently accessed data
- Use Bulk Endpoints: For operations involving multiple records
- Handle Pagination: Many endpoints return paginated results
- Keep Tokens Secure: Store API tokens in secure environment variables, not in code
- Monitor API Usage: Track rate limits and integration performance
- Test in Sandbox First: Verify integrations in a test environment before production
Troubleshooting
Common API issues and solutions:
- 401 Unauthorized: Check API token validity and permissions
- 403 Forbidden: Verify the token has appropriate permissions
- 429 Too Many Requests: Implement exponential backoff and respect rate limits
- 500 Server Error: Contact support with the request details and response error
- Webhook delivery failures: Ensure your endpoint is consistently available and responds quickly
API Documentation
For complete API documentation:
- Visit
https://yoursubdomain.shifts.com/api/documentation - Browse interactive documentation with all endpoints and parameters
- Test API calls directly from the documentation interface
- View example requests and responses for each endpoint
Related Resources
This article should be updated when:
- New API endpoints are added
- Authentication methods change
- Rate limits are adjusted
- Webhook event types are modified
- New integration capabilities are introduced