Time capture integration

Many customers already have clocking hardware or a time system on site: wall-mounted badge readers, turnstiles, a client's own attendance app. The time capture integration lets those systems feed clock events straight into WFM shifts, with the same result as a worker tapping the button in the Clock app: the actual start or end lands on the right shift, an ad hoc shift is created when nothing was scheduled, and a Geo Tag records where and when the event happened.

There is one endpoint, clockEvent, on the b3s.TimeCaptureService Apex class. You can call it through the WFM remoting router or as a plain REST call.

When to use it

Situation Use
A clock or reader sends one event per tap, close to real time clockEvent (this article)
You receive a file of worked hours after the fact (a nightly export) The Shift importer in Update existing shifts mode
Workers clock in on their own phones The Clock app
A shared device on site The Terminal app

Who can call it

The endpoint is for authenticated integration users only, typically a dedicated Salesforce integration user that your middleware signs in as (OAuth, connected app).

Give the integration user:

Permission Why
Apex class access to TimeCaptureService To call the class (included in the WFM Admin permission set; add it to your integration permission set)
Read on Contact and the field you identify workers by To resolve the worker
Read on b3s__Site__c When you send siteId
Read and edit on b3s__Shift__c, including b3s__Contact__c, b3s__Work_Site__c, b3s__Scheduled_Start_Time__c, b3s__Actual_Start_Time__c, b3s__Actual_End_Time__c, b3s__Status__c; create when ad hoc shifts are allowed To find and update the shift
Create on b3s__Geo_Tag__c with its shift, type, tag time, location and location error fields To record the event
API Enabled (for REST) To call the REST URL

Calling the endpoint

Over REST

POST /services/apexrest/b3s/wfm/clock/
Authorization: Bearer <access token>
Content-Type: application/json

The body is the event JSON (below). The response is HTTP 200 with the success body, or HTTP 400 with an error body.

Through the remoting router

Integrations that already call the WFM remoting router use the usual contract: controllerName b3s.TimeCaptureService and the event JSON with endp set to clockEvent.

{
  "controllerName": "b3s.TimeCaptureService",
  "endp": "clockEvent",
  "eventType": "in",
  "timestamp": "2026-11-05T08:58:00Z",
  "contactId": "0035g00000AbCdEAAZ"
}

Request fields

Field Required Meaning
eventType Yes in or out (Clock In and Clock Out are accepted too).
timestamp Yes When the event happened: ISO 8601 with Z or an offset (2026-11-05T08:58:00Z, 2026-11-05T09:58:00+01:00), or epoch milliseconds. Always send the offset; a value without one is read as UTC.
contactId One of The worker's Contact Id.
contactExternalId One of The worker's identifier in your system, matched against contactExternalIdField.
contactExternalIdField No The Contact field holding contactExternalId. Default b3s__External_QR_Tag__c (the worker's static badge value, the same one the Terminal accepts). Any Contact field the integration user can read works, for example your own Payroll_Number__c.
siteId No The Site (b3s__Site__c) Id where the event happened.
siteTag No Alternative to siteId: the site's b3s__Terminal_Tag__c. Treat it as a device secret; the tag is matched on the server and never needs field access.
latitude, longitude No The device position. Send both or neither.
locationError No Free text (up to 255 characters) when the device could not get a position.
searchRangeMinutes No How far either side of the event to look for a scheduled shift on clock in. Default 60, allowed 1 to 1440.
allowAdhoc No false rejects a clock in that matches no scheduled shift instead of creating an ad hoc one. Default true.

Exactly one contact must match. If the external id matches two contacts the event fails with More than one Contact matches <field>, so keep the identifier unique.

How the shift is resolved

The rules mirror the Clock app, so a worker gets the same outcome whichever device they use.

Clock in

  1. If the worker already has an ongoing shift (actual start in the 24 hours before the event, no actual end), the event is refused: The worker is already clocked in on shift <Id>.
  2. Otherwise WFM looks for the worker's shifts that are not started, not ended, not cancelled, with a scheduled start within searchRangeMinutes of the event. The first upcoming one wins; if all are in the past, the earliest one wins. Its b3s__Actual_Start_Time__c is set to the event time.
  3. With no match, an ad hoc shift is created: Contact, actual start and site, no scheduled times (the same shape the Clock app creates). With allowAdhoc: false the event is refused instead.

Clock out

The worker's ongoing shift (latest actual start in the 24 hours before the event, no actual end) gets b3s__Actual_End_Time__c. With no ongoing shift the event is refused: The worker has no ongoing shift to clock out of.

Site. When you send a site and the shift has none, the site is set on the shift. A planned site is never overwritten.

Geo Tag. Every successful event inserts a b3s__Geo_Tag__c of type Clock In or Clock Out with the event time and any coordinates or location error. The standard Geo Tag automation then copies the coordinates onto the shift's Clock In / Clock Out Location, which drives the distance formulas and the Time and Attendance dashboards.

One transaction. The shift save and the Geo Tag insert succeed or fail together.

Locks and validation

Saves go through every normal shift rule. A shift that is already payrolled, invoiced or posted is protected by the shift lifecycle lock: the event fails with the lock message (for example that the shift's times need the Edit Payrolled Shifts permission) and nothing is written. Your own validation rules and triggers apply the same way.

What the endpoint does not do: it does not change b3s__Status__c or the approval status, does not record breaks, and does not run the Clock app's exception forms or clockOutFieldsSet. Breaks are still generated by the break engine from the actual times.

Examples

Clock in by badge value at a site, with a position:

{
  "eventType": "in",
  "timestamp": "2026-11-05T08:58:00Z",
  "contactExternalId": "BADGE-1042",
  "siteId": "a0B5g00000XyZabEAF",
  "latitude": 51.5072,
  "longitude": -0.1276
}

Response, matched to a scheduled shift:

{
  "success": true,
  "statusCode": 200,
  "statusType": "OK",
  "message": null,
  "responseObject": {
    "shiftId": "a0D5g00000Shf01EAB",
    "geoTagId": "a0E5g00000Geo01EAB",
    "eventType": "Clock In",
    "isAdhoc": false,
    "created": false
  }
}

Clock out by payroll number, no position available:

{
  "eventType": "out",
  "timestamp": 1793898000000,
  "contactExternalId": "P-00981",
  "contactExternalIdField": "Payroll_Number__c",
  "locationError": "Reader has no GPS"
}

Error response (HTTP 400 over REST):

{
  "success": false,
  "statusCode": 400,
  "statusType": "ERROR",
  "message": "The worker has no ongoing shift to clock out of",
  "responseObject": null
}

Response fields

Field Meaning
shiftId The shift that was updated or created.
geoTagId The Geo Tag inserted for this event.
eventType Clock In or Clock Out.
isAdhoc true when the shift has no scheduled start (created ad hoc, now or earlier).
created true when this event created the shift.

Error messages

Message Cause
eventType must be "in" or "out" Missing or unknown event type.
timestamp is required / timestamp must be ISO 8601 ... Missing or unreadable time.
contactId or contactExternalId is required No worker identifier.
Contact not found / More than one Contact matches ... Identifier matches no visible contact, or several.
Invalid contactExternalIdField [...] The field name is not a plain field API name.
Site not found / More than one site matches siteTag Site Id not visible, or tag not unique.
latitude and longitude must be sent together / latitude is out of range Bad coordinates.
searchRangeMinutes must be between 1 and 1440 Range outside the allowed window.
The worker is already clocked in on shift ... Clock in while a shift is ongoing. Send a clock out first.
No scheduled shift within N minutes of the clock in and ad hoc shifts are not allowed allowAdhoc: false and nothing scheduled nearby.
The worker has no ongoing shift to clock out of Clock out without a matching clock in in the last 24 hours.
Lifecycle lock or validation rule message The shift is locked or a rule refused the save. Nothing was written.
Time capture requires an authenticated integration user Called as a guest user.

Retries and ordering

Send events in the order they happened. A retried clock in for a worker who is already on shift returns the "already clocked in" error, and a retried clock out returns "no ongoing shift", so a retry never creates a duplicate shift or overwrites a recorded time. Treat those two errors as "already processed" in your middleware when you know the first attempt reached Salesforce.