Setting Data in Deputy

There are two main ways to interact with the Deputy API

  • Using some of the more structured endpoints such as /supervise
  • Using the Resource API to join data and perform more structured requests

For adding or updating data in Deputy we recommend that you use the management endpoints. These are more targeted endpoints for specific areas of the Deputy product and have many guard rails in place to ensure you do not enter invalid data.

The management endpoints are more traditional in what you would see in a RESTful-based API, with endpoints to add or update employees (Add an employee ), add new locations (Add a location ) and update rosters and timesheets just to name a few.

For the most part these endpoints do not support bulk additions. This is especially true of the update endpoints which are targeting a specific record for changes. The one exception to this is the Adding Sales Data to Deputy endpoint. This endpoint supports both single objects and bulk data via an array.

Below we've stepped through a few examples of adding and updating data within Deputy to get you started.

Adding an employee

For our adding sample, we will use one of the most common use cases, adding an employee

URL

curl --location --request POST 'https://{install}.{geo}.deputy.com/api/v1/supervise/employee'

Authorization

Header - Authorization: Bearer {Token}

Sample Payload

{
    "strFirstName": "John",
    "strLastName": "Doe",
    "intCompanyId": 1,
    "intGender": 2,
    "strCountryCode": "AU",
    "strDob": "1971-01-01",
    "strStartDate": "2022-01-01",
    "strMobilePhone": "0441234567",
    "strPayrollId": "1234",
    "fltWeekDayRate": 30,
}

As you can see unlike the Resource API it's a much more targeted endpoint when adding data. This sample does not cover all data and is a subset of whats available. For more information about adding employees see Adding an Employee.

Response
When you successfully add an employee to Deputy via the API, the response will contain a summary of the information which has been saved.

{
    "Id": 112,
    "Company": 1,
    "FirstName": "John",
    "LastName": "Doe",
    "DisplayName": "John Doe",
    "OtherName": null,
    "Salutation": null,
    "MainAddress": null,
    "PostalAddress": null,
    "Contact": 101371,
    "EmergencyAddress": null,
    "DateOfBirth": "1971-01-01T00:00:00+10:00",
    "Gender": 2,
    "Pronouns": 0,
    "CustomPronouns": null,
    "Photo": null,
    "UserId": 112,
    "JobAppId": null,
    "Active": true,
    "StartDate": "2022-01-01T00:00:00+11:00",
    "TerminationDate": null,
    "StressProfile": 1,
    "Position": null,
    "HigherDuty": null,
    "Role": 50,
    "AllowAppraisal": true,
    "HistoryId": 105823,
    "CustomFieldData": null,
    "Creator": 1,
    "Created": "2022-07-18T14:31:36+10:00",
    "Modified": "2022-07-18T14:31:37+10:00",
    "_DPMetaData": {
        "System": "Employee",
        "CreatorInfo": {}
    },
    "IsSubordinate": true,
    "WorkplaceArray": [
        {
            "Id": 118,
            "EmployeeId": 112,
            "Company": 1,
            "SortOrder": 0,
            "Agreement1": 117,
            "Agreement2": null,
            "Agreement3": null,
            "Creator": 1,
            "Created": "2022-07-18T14:31:36+10:00",
            "Modified": "2022-07-18T14:31:36+10:00",
            "_DPMetaData": {
                "System": "EmployeeWorkplace",
                "CreatorInfo": {}
            }
        }
    ],
    "TrainingArray": "",
    "TrainingFileArray": [],
    "LeaveAccrualArray": [],
    "PayrollId": "1234",
    "Contract": "",
    "SalaryDistributionConfig": null,
    "Email": null,
    "Mobile": "0441234567",
    "PhotoLinkId": "",
    "Img": "https://d11hmzhsuwuq9f.cloudfront.net/my/avatar?name=J+D&width=30&height=30",
    "Status": 3,
    "CanAskToShowPin": true,
    "HasIPhoneToken": false,
    "HasAndroidToken": false,
    "HasEnabled2FA": false,
    "AnalyticsID": "d41d8cd98f00b204e9800998ecf8427e",
    "UserName": "jdoe",
    "AllowLogin": true,
    "OnboardingStatus": 1001,
    "isNew": true
}

Updating a location

In our sample for updating data in Deputy, we will cover how to update a location. Locations in Deputy can be a variety of places for work. For example delivery trucks might be considered a location, even though they are constantly moving. Deputy users often come up with amazing ways to use the location functionality in Deputy, and as such integration in this area may be key to your success.

URL

curl --location --request POST 'https://{install}{geo}.deputy.com/api/v1/supervise/company/{id}

Authorization

Header - Authorization: Bearer {Token}

Sample Payload

{
  "strWorkplaceCode": "ABC123", 
  "strPayrollExportCode": "EXPORT"
}

Again this is a much more targeted endpoint. This is determined by the fact the integer id of the Location you wish to update is required in the URL. In this example we are updating the Workplace Code to ABC123 and the Payroll Export code to EXPORT. For payroll developers especially, the export code can be important as that may assist you match up timesheets to various cost centres in your application. More information on the update location endpoint can be found here Update a location.

Response

{
    "Id": 6,
    "Portfolio": null,
    "Code": "ABC",
    "Active": true,
    "ParentCompany": 0,
    "CompanyName": "Asims' Avocado's",
    "TradingName": null,
    "BusinessNumber": null,
    "CompanyNumber": null,
    "IsWorkplace": true,
    "IsPayrollEntity": true,
    "PayrollExportCode": "XYZ123",
    "Address": 199,
    "Contact": null,
    "Creator": 1,
    "Created": "2022-07-27T11:22:17+10:00",
    "Modified": "2022-07-27T11:22:34+10:00",
    "_DPMetaData": {
        "System": "Company",
        "CreatorInfo": {
            "Id": 1,
            "DisplayName": "John Doe",
            "EmployeeProfile": 1,
            "Employee": 1,
            "Photo": "https://photo2.deputy.com/deputec_b220505063318_11516/-135x135_1e4417bce8404f8facdfe89990f3bedb.jpg?Expires=1662425965&Key-Pair-Id=APKAINP5UVPK4IGBHXOQ&Signature=GQ8pU0X4jv04HEYLZEdImY9HYkkmPUX3hY0weeGSqlMhGdvlL9JGjsMVGGBrsaNAclgNDOYhahDkWJv4mb--3s2iel42LIqzzrDC0rwSX0n3~ZU4WbTqZBySfryS0hcl3p5hkrn-68ZtrRfjK3psSPxfUluYo3Z51DUIW4MCouo_",
            "Pronouns": 0,
            "CustomPronouns": ""
        },
        "AddressObject": {
            "Id": 199,
            "ContactName": null,
            "UnitNo": null,
            "StreetNo": null,
            "SuiteNo": null,
            "PoBox": null,
            "Street1": "Ultimo, Sydney",
            "Street2": null,
            "City": null,
            "State": "150",
            "Postcode": null,
            "Country": 13,
            "Phone": null,
            "Notes": "This is an address note",
            "Format": null,
            "Saved": null,
            "Creator": 1,
            "Created": "2022-07-27T11:22:17+10:00",
            "Modified": "2022-07-27T11:22:17+10:00",
            "Print": "Ultimo, Sydney\n"
        },
        "Geo": {
            "Id": 103,
            "Orm": "DeputecCompany",
            "RecId": 6,
            "Longitude": 151.1985587,
            "Latitude": -33.8796842,
            "Accuracy": null,
            "No": null,
            "Street": null,
            "Suburb": null,
            "State": null,
            "Postcode": null,
            "Country": null,
            "Action": null,
            "Creator": 1,
            "Created": "2022-07-27T11:22:17+10:00",
            "Modified": "2022-07-27T11:22:17+10:00"
        },
        "CustomData": {
            "GooglePlaceId": null
        }
    }
}