Getting started
Use this guide to connect to Workforce API v1, find a published shift, and read approved leave.
1. Request credentials
Ask your Rightwork contact for an integration key. Include your company administrator’s approval, the locations and data you need, how often you plan to read them, and who should receive the key. Arrange test access with Rightwork. Each key works only in its assigned environment, and new locations need separate approval.
Store the key in your server’s secret manager and load it into RIGHTWORK_API_KEY. Set the production host for the examples:
export RIGHTWORK_BASE_URL="https://getrightwork.dev"
# Load RIGHTWORK_API_KEY from your protected runtime secret configuration.2. Verify the connection
curl --fail-with-body \
-H "Authorization: Bearer $RIGHTWORK_API_KEY" \
"$RIGHTWORK_BASE_URL/api/external/v1/connection"Check company_name, environment, scopes, and expires_at. Then call Locations for approved location IDs and Employees & payroll IDs to find an employee. For example, keep payroll ID 00123 as a string so its leading zeros survive.
3. Retrieve schedules and approved PTO
Published shifts
curl --fail-with-body --get \
-H "Authorization: Bearer $RIGHTWORK_API_KEY" \
-H "Accept: application/json" \
--data-urlencode "date_from=2026-09-01" \
--data-urlencode "date_to=2026-10-01" \
--data-urlencode "payroll_external_id=00123" \
"$RIGHTWORK_BASE_URL/api/external/v1/schedules"This request finds assigned shifts for September. October 1 is the first day excluded. Replace the dates and payroll ID with values from your account. See the schedule response.
Approved leave
curl --fail-with-body --get \
-H "Authorization: Bearer $RIGHTWORK_API_KEY" \
-H "Accept: application/json" \
--data-urlencode "date_from=2026-09-01" \
--data-urlencode "date_to=2026-10-01" \
--data-urlencode "type=PTO" \
--data-urlencode "status=APPROVED" \
"$RIGHTWORK_BASE_URL/api/external/v1/time-off-requests"This returns approved PTO overlapping September across the locations you can access. Add payroll_external_id for one employee. Omit status to include requests awaiting approval and other statuses. See the leave response.
Labor and sales reports
For reports, set RIGHTWORK_LOCATION_ID to an approved location UUID. Each report needs its own scope.
curl --fail-with-body --get \
-H "Authorization: Bearer $RIGHTWORK_API_KEY" \
-H "Accept: application/json" \
--data-urlencode "location_id=$RIGHTWORK_LOCATION_ID" \
--data-urlencode "date_from=2026-10-01" \
--data-urlencode "date_to=2026-10-08" \
--data-urlencode "granularity=daily" \
"$RIGHTWORK_BASE_URL/api/external/v1/reports/labor"Choose the report for your integration based on whether you need staffing hours, sales, or payable hours and pay.
Python example
The cURL requests fetch one page. This Python 3 client collects every page before returning records. It uses the standard library. Save it as rightwork_api.py, set your key, replace the sample dates and payroll ID, and run python3 rightwork_api.py.
"""Fetch a complete snapshot without printing secrets or employee records."""
import json
import os
import random
import time
from urllib.error import HTTPError
from urllib.parse import urlencode, urlsplit
from urllib.request import HTTPRedirectHandler, Request, build_opener
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
raise RuntimeError('Redirect rejected to protect the API key. Confirm the base URL with Rightwork.')
def fetch_page(url, key):
for attempt in range(5):
try:
request = Request(url, headers={'Authorization': f'Bearer {key}', 'Accept': 'application/json'})
with build_opener(NoRedirect()).open(request, timeout=30) as response:
return json.load(response)
except HTTPError as exc:
if exc.code not in (429, 502, 503, 504) or attempt == 4:
request_id = exc.headers.get('X-Request-ID', 'unavailable')
raise RuntimeError(f'API returned {exc.code}; request_id={request_id}. Do not apply a partial export.') from None
retry_after = exc.headers.get('Retry-After')
delay = int(retry_after) if retry_after and retry_after.isdigit() else 2 ** attempt + random.random()
if delay > 60:
raise RuntimeError(f'API requests a {delay}-second wait. Retry later; do not apply a partial export.') from None
time.sleep(delay)
def fetch_all(base_url, key, resource, filters):
parsed = urlsplit(base_url)
if parsed.scheme != 'https' or not parsed.netloc or parsed.query or parsed.fragment or parsed.username or parsed.password:
raise ValueError('Supply the HTTPS base URL provided by Rightwork.')
if resource not in ('employees', 'locations', 'roles', 'time-off-types', 'schedules', 'time-off-requests', 'time-entries', 'reports/labor', 'reports/sales', 'reports/actual-labor'):
raise ValueError('Unsupported collection.')
params = {**filters, 'page_size': 100}
rows, snapshot_id, cursor = [], None, None
seen_cursors = set()
while True:
query = {**params, **({'cursor': cursor} if cursor else {})}
page = fetch_page(f'{base_url.rstrip("/")}/api/external/v1/{resource}?{urlencode(query)}', key)
meta = page['meta']
if snapshot_id is not None and meta['snapshot_id'] != snapshot_id:
raise RuntimeError('Snapshot changed; discard the partial export.')
snapshot_id = meta['snapshot_id']
rows.extend(page['data'])
cursor = meta['next_cursor']
if not cursor:
if not meta['complete']:
raise RuntimeError('Incomplete export; do not reconcile.')
return rows, meta
if cursor in seen_cursors:
raise RuntimeError('Repeated cursor; do not reconcile.')
seen_cursors.add(cursor)
if __name__ == '__main__':
base_url = 'https://getrightwork.dev'
key = os.environ['RIGHTWORK_API_KEY']
payroll_id = '00123' # Replace with an employee's actual payroll ID.
connection = fetch_page(
f'{base_url}/api/external/v1/connection', key
)['data']
print(f'Connected to {connection["company_name"]} ({connection["environment"]})')
schedules, schedule_meta = fetch_all(
base_url, key, 'schedules',
{
'payroll_external_id': payroll_id,
'date_from': '2026-09-21',
'date_to': '2026-09-28',
},
)
pto_requests, pto_meta = fetch_all(
base_url, key, 'time-off-requests',
{
'date_from': '2026-09-01',
'date_to': '2026-10-01',
'type': 'PTO',
'status': 'APPROVED',
},
)
print(f'Retrieved {len(schedules)} shifts')
print(f'Retrieved {len(pto_requests)} approved PTO requests')
# Both exports completed successfully. Pass schedules and pto_requests
# to your destination-system import here.The script prints the company and record counts. Zero records means the request succeeded with no matches. On an error, keep your last complete import. A snapshot_restart_required error means you need to restart that export from its first page. Pagination and synchronization.
Postman
Download the Postman collection and import it into Postman. Set base_url, api_key, and the reporting location_id in a private environment. The previous collection is available for integrations that predate reporting.
Before your first scheduled import
Compare a known employee’s published shift and approved leave with the API results. Check dates, time zones, and breaks. Test a multi-page request and confirm that an interrupted import leaves your existing records intact.
Keys expire after 90 days. Request a replacement before expiry, verify it with GET /connection and a permitted read, then revoke the old key. For support, send Rightwork the request ID, endpoint, time with time zone, HTTP status, and error code. Keep credentials and employee records out of support messages.
