Starting/Stopping Timesheets (Clock in and Out)

Whilst the Deputy API does have the ability to have full integration with the timesheet system via the API, it may be more suitable for your application to only interact with particular areas. For example as a POS system, you may only want to interact with the clock in and out process of the timesheet/shift features. Below are some code examples of how to clock an employee in and out via the Deputy API.

Clocking an employee in via the API

The process of clocking an employee in for a shift is relatively simple using the Deputy API. The process utilises the timesheets endpoint with the sub url of start and stop depending on the action. In this case we will be using the start option.

URL

curl --request POST --url 'https://{install}.{geo}.deputy.com/api/v1/supervise/timesheet/start'

Sample request to start a timesheet

{intEmployeeId: 2, intOpunitId: 1}

In this example, an employee with a record of 2 and in the location with a record of 1 is being clocked on for work. This shows how simple it can be to clock an employee into the Deputy system.

Sample response when clocking an employee in

{
    "Id": 258,
    "Employee": 100,
    "EmployeeHistory": 3163,
    "EmployeeAgreement": 102,
    "Date": "2022-09-11T00:00:00+10:00",
    "StartTime": 1662866220,
    "EndTime": 1662869820,
    "Mealbreak": "2022-09-11T00:00:00+10:00",
    "MealbreakSlots": "",
    "Slots": [],
    "TotalTime": 1,
    "TotalTimeInv": 1,
    "Cost": null,
    "Roster": null,
    "EmployeeComment": null,
    "SupervisorComment": null,
    "Supervisor": null,
    "Disputed": false,
    "TimeApproved": false,
    "TimeApprover": null,
    "Discarded": null,
    "ValidationFlag": 0,
    "OperationalUnit": 1,
    "IsInProgress": true,
    "IsLeave": false,
    "LeaveId": null,
    "LeaveRule": null,
    "Invoiced": false,
    "InvoiceComment": null,
    "PayRuleApproved": false,
    "Exported": null,
    "StagingId": null,
    "PayStaged": false,
    "PaycycleId": 79,
    "File": null,
    "CustomFieldData": null,
    "RealTime": true,
    "AutoProcessed": 0,
    "AutoRounded": 0,
    "AutoTimeApproved": 0,
    "AutoPayRuleApproved": 0,
    "Creator": 3,
    "Created": "2022-09-11T13:17:46+10:00",
    "Modified": "2022-09-11T13:17:46+10:00",
    "OperationalUnitObject": {
        "Id": 1,
        "Creator": 1,
        "Created": "2022-05-05T16:43:57+10:00",
        "Modified": "2022-09-02T13:52:01+10:00",
        "Company": 1,
        "WorkType": null,
        "ParentOperationalUnit": 0,
        "OperationalUnitName": "Chef",
        "Active": true,
        "PayrollExportName": "",
        "Address": 158,
        "Contact": null,
        "RosterSortOrder": 0,
        "ShowOnRoster": true,
        "Colour": null,
        "RosterActiveHoursSchedule": null,
        "DailyRosterBudget": null,
        "OperationalUnitType": 1,
        "AddressObject": {
            "Id": 158,
            "ContactName": null,
            "UnitNo": null,
            "StreetNo": null,
            "SuiteNo": null,
            "PoBox": null,
            "Street1": "90 Pacific St, Kiama NSW 2533, Australia",
            "Street2": null,
            "City": null,
            "State": null,
            "Postcode": null,
            "Country": 13,
            "Phone": null,
            "Notes": null,
            "Format": null,
            "Saved": null,
            "Creator": 1,
            "Created": "2022-05-05T16:43:57+10:00",
            "Modified": "2022-05-05T16:43:57+10:00",
            "Print": "90 Pacific St, Kiama NSW 2533, Australia\n"
        },
        "CompanyCode": "Sim",
        "CompanyName": "Simons Sambos",
        "CompanyAddress": 157
    },
    "OnCost": 0,
    "StartTimeLocalized": "2022-09-11T13:17:00+10:00",
    "EndTimeLocalized": "2022-09-11T14:17:00+10:00",
    "_DPMetaData": {
        "System": "Timesheet",
        "CreatorInfo": {
            "Id": 3,
            "DisplayName": "AdamRhys Sapo",
            "EmployeeProfile": 3,
            "Employee": 3,
            "Photo": "https://photo2.deputy.com/deputec_b220505063318_11516/-135x135_45ca58e0db1a271fda5c83c399f7221a.jpg?Expires=1662947704&Key-Pair-Id=APKAINP5UVPK4IGBHXOQ&Signature=aXV4TVZHVAYNoYe6NLvgIkujV6kNjS5jmNkFwzlEhy0fZCS7qHvwBSQK5pMOU2xcpAWv3E6nIPuPxgj-eHOVf3uHWoRAT649EcW94OAPAL6kgdpNIUp8MiO1MNBUUY3ARgZ2gz5pzNKtIVVBToSsqiqW2xQQObH6goTMwPlMlXg_",
            "Pronouns": 4,
            "CustomPronouns": "Carlos"
        },
        "OperationalUnitInfo": {
            "Id": 1,
            "OperationalUnitName": "Chef",
            "Company": 1,
            "CompanyName": "Simons Sambos",
            "LabelWithCompany": "[Sim] Chef"
        },
        "EmployeeInfo": {
            "Id": 100,
            "DisplayName": "Deputy QuickBooks",
            "EmployeeProfile": 100,
            "Employee": 100,
            "Photo": "https://d11hmzhsuwuq9f.cloudfront.net/my/avatar?name=D+Q&width=135&height=135",
            "Pronouns": 0,
            "CustomPronouns": ""
        },
        "CustomFieldData": null
    },
    "ManagerNotified": false

The response is the Timesheet object that is returned when querying timesheets regularly. The only difference being that this timesheet is now in progress as shown by the IsInProgress element.

Clocking an employee out via the API

The process as you would expected is very similar to clocking out an employee. The main difference being the payload includes the timesheet id from the clock in process and also you can define whether a break was taken during the shift.

URL

curl --request POST --url 'https://{install}.{geo}.deputy.com/api/v1/supervise/timesheet/end'

Sample request to clock an employee out via the API

{"intTimesheetId": 3, "intMealbreakMinute": 30}

In this example, the request will stop the timesheet with the id record of 3, and also update the timesheet to include a 30-minute meal break. The response back from the API will be the same as the clock in process, however, isInProgress will now be updated to false.