Update Employee Data

This section focuses on:

  • Structure of PUT requests to the /users endpoint for basic info update:
    • Get familiar with the request you need to make to update basic user data in 7shifts
  • Structure of PUT requests to the /users endpoint for assignment update:
    • Get familiar with the request you need to make to update user assignments
  • Update employee profile in 7shifts

Put structure for updating updating info

Updating user data in 7shifts is handled through a PUT request to the 7shifts /users endpoint.

This particular PUT request structure for updating basic info may only be used when any of the following has been updated for a user that has already been synced/mapped into 7shifts:

  • First name
  • Last name
  • Phone
  • Email (only if the user doesn’t already have one in 7shifts)

Keeping the field values from the POST example in mind, here’s an example PUT request to the /users endpoint to update any of the above fields:

Request URL

PUT https://api.7shifts.com/v1/users/5252552

Request body

{
    "user": {
        "firstname": "Bertram",
        "lastname": "Gilfoyle",
        "mobile_phone": 3065558888
    }
}

Please note the following about the above request:

  • The request URL must specify the user.id of the 7shifts user to be updated.
  • This request may only be used if the user’s role, department or location assignment hasn’t changed.
  • You only need to specify the fields that got updated, although it wouldn’t make a difference if you specified all the fields in the request body.

Note

If the user’s email address got updated in your system, that change should only be pushed to 7shifts if the user doesn’t already have an email address in 7shifts.

Before making a PUT request that involves changing a user’s email address, you should make the following GET request with the user’s ID and check if the email field is empty:
GET https://api.7shifts.com/v1/users/5252552
You should proceed with updating the email address for the 7shifts user only if the email field in the response is empty. You can do so by using the same PUT request mentioned above & modifying the request body as follows:
{
    "user": {
        "firstname": "Bertram",
        "lastname": "Gilfoyle",
        "mobile_phone": 3065558888,
        "email": "[email protected]"
    }
}

PUT Structure for Updating LDR and Wage Assignments

This particular PUT request structure may only be used when any of the following assignments have been updated for a user in your system. Also, the user must have already been synced/mapped into 7shifts and all the required roles, departments & locations have been mapped:

  • Roles
  • Departments
  • Locations
  • Wages

Keeping the field values from the POST example in mind, here’s an example PUT request to the assign the existing user to yet another role with the ID 55555 which exists under department ID 33333 at location 11111, which is another location under the same company, for a $15 wage:

Request URL

PUT https://api.7shifts.com/v1/users/5252552

Request body

{
    "user": {
        "firstname": "Bertram",
        "lastname": "Gilfoyle"
    },
    "role": [
        {
            "id": 135790
        },
        {
            "id": 864280
        },
        {
            "id": 55555
        }
    ],
    "department": [
        {
            "id": 98765
        },
        {
            "id": 33333
        }
    ],
    "location": [
        {
            "id": 12345
        },
        {
            "id": 11111
        }
    ],
    "wages": [
    {
         "role_id": 135790,
         "wage_cents": 2300,
         "effective_date": "2020-12-01",
         "wage_type": "hourly",
         "is_deleted": false
    },
    {
         "role_id": 864280,
         "wage_cents": 1700,
         "effective_date": "2020-12-01",
         "wage_type": "hourly",
         "is_deleted": false
    },
    {
         "role_id": 55555,
         "wage_cents": 1500,
         "effective_date": "2020-12-15",
         "wage_type": "hourly",
         "is_deleted": false
    }
    ]
}

Please note the following about the above request:

  • The request URL must specify the user.id of the 7shifts user to be updated
  • This request may be used if the user’s role, department, location or wage assignment has changed. If just basic info has changed, you can use the other simpler PUT request.
  • You must specify the user object in the request body, and provide at least one field such as firstname therein, even if the user’s basic info didn’t change.
  • You must provide the existing roles, departments, locations & wages that the user is already assigned to as well, and not just the new roles, departments & locations that the user got assigned to. Not doing so will result in the user’s previous assignments, including wage data, being deleted.
  • If any other basic info fields got updated along with the assignments as well, such as phone number, then you may include those fields in the user object within the request body as well.

Switching Wage Type

Did an employee just switch from being on an hourly wage to a weekly salary? When updating the user, just specify one wage object representing the new salary with wage_type = weekly_salary. Ensure that the other existing wage objects aren’t being re-specified to change the wage type unambiguously.

Did an employee just switch from weekly salary to hourly wage? Just specify the new wage object(s) representing the new wage(s) to be assigned to the user, with each object’s wage_type field set to hourly.

Essentially, whatever previously assigned wage/location/department/role object you don’t specify in the PUT request gets removed from the list of assignments for the user, and only the new ones specified in the request get assigned.


Did this page help you?