Users

The API- functions for Users in Papershift



Create a new User

Create a new User in your Papershift Account

URL

https://app.papershift.com/public_api/v1/users

Method

POST

Parameters

Parameters

Type

Required

api_token

String

required

location_ids

Integer or comma-separated string for multiple IDs

required

location_external_ids

String, comma-separated for multiple external IDs

required if location_ids is not set

working_area_ids

Integer, comma-separated string for multiple IDs

optional

working_area_external_ids

String, comma-separated for multiple external IDs

optional if working_area_ids is not set

username

String

required

email

String (valid format, unique)

optional

abbrev

String

optional

initial_time_account

Float

optional

salary

Float

optional

home_office

Boolean

optional

working_sessions_creator

Boolean

optional

staff_number

String

optional

external_id

String

optional

locale

‚de‘ | ‚en‘

optional

tags

String, must contain comma-separated tag IDs

optional

data_profiles

Hash

optional

Information

Creating Users requires one or more valid Locations and optionally one or more
Working Areas within the authorized Enterprise. You either get these through
the External-ID you simply set by yourself or the Record’s ID from the Database.

Example

{
  "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
  "user": {
    "location_ids": "1",
    "working_area_ids": "2,3",
    "username": "User 1",
    "tags": "1,2,3",
    "locale": "de",
    "home_office": true,
    "salary": "11.9",
    "email": "[email protected]",
    "data_profiles": {
      "birthday": "1980-06-20",
      "desc": "Sample description"
    }
  }
}
function createUser() {
  var params = {
    "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
    "user": {
      "location_ids": "1",
      "working_area_ids": "2,3",
      "username": "User 1",
      "tags": "1,2,3",
      "locale": "de",
      "home_office": true,
      "salary": "11.9",
      "email": "[email protected]",
      "data_profiles": {
        "birthday": "1980-06-20",
        "desc": "Sample description"
      }
    }
  };

  $.ajax({
    url: "https://app.papershift.com/public_api/v1/users",
    type: 'POST',
    dataType: 'json',
    data: JSON.stringify(params),
    complete: function (data) {
      console.log(data.responseText);
    }
  });
}
{
  "id": 115,
  "abbrev": null,
  "email": "[email protected]",
  "external_id": null,
  "home_office": true,
  "initial_time_account": 0,
  "locale": "de",
  "salary": 11.9,
  "staff_number": null,
  "username": "User 1",
  "working_sessions_creator": false,
  "enterprise_id": 1,
  "location_ids": [1],
  "working_area_ids": [2, 3],
  "tags": [3, 2, 1],
  "data_profiles": {
    "birthday": {
      "label": "Geburtstag",
      "value": "1980-06-20"
    }
  }
}



Update an existing User

Update an existing User in your Papershift Account

URL

https://app.papershift.com/public_api/v1/users

Method

PUT

Parameters

Parameters

Type

Required

api_token

String

required

id

Integer

required

external_id

String

required if id not set

working_area_ids

Integer, comma-separated string for

optional

working_area_external_ids

String, comma-separated for multiple external IDs

optional if working_area_ids is not set

username

String

optional

email

String (valid format, unique)

optional

abbrev

String

optional

initial_time_account

Float

optional

salary

Float

optional

home_office

Boolean

optional

working_sessions_creator

Boolean

optional

staff_number

String

optional

locale

‚de‘ | ‚en‘

optional

tags

String, must contain comma-separated tag IDs

optional

data_profiles

Hash

optional

Information

To update an existing User requires finding the specific record
in the Database. This can be achieved via the User’s
External-ID or Record-ID.

Example

{
  "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
  "user": {
    "id": 112,
    "working_area_ids": "7,3",
    "tags": "1,2",
    "home_office": false,
    "salary": 23,
    "username": "User 2",
    "email": "[email protected]",
    "data_profiles": {
      "birthday": "1980-06-20",
      "desc": "Sample description"
    }
  }
}
function updateUser() {
  var params = {
    "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
    "user": {
      "id": 112,
      "working_area_ids": "7,3",
      "tags": "1,2",
      "home_office": false,
      "salary": 23,
      "username": "User 2",
      "email": "[email protected]",
      "data_profiles": {
        "birthday": "1980-06-20",
        "desc": "Sample description"
      }
    }
  };

  $.ajax({
    url: "https://app.papershift.com/public_api/v1/users",
    type: 'PUT',
    dataType: 'json',
    data: JSON.stringify(params),
    complete: function (data) {
      console.log(data.responseText);
    }
  });
}
{
  "abbrev": null,
  "desc": null,
  "email": "[email protected]",
  "external_id": null,
  "home_office": false,
  "id": 112,
  "initial_time_account": 0,
  "locale": "de",
  "salary": 23,
  "staff_number": null,
  "username": "User 2",
  "working_sessions_creator": false,
  "enterprise_id": 1,
  "location_ids": [1],
  "working_area_ids": [7, 3],
  "tags": [2, 1],
  "data_profiles": {
    "birthday": {
      "label": "Geburtstag",
      "value": "1980-06-20"
    }
  }
}



Get User by ID

Get User by its unique ID or external ID

URL

https://app.papershift.com/public_api/v1/users

Method

GET

Parameters

Parameters

Type

Required

api_token

string

required

id

integer

required (if external_id not set)

external_id

string

required (if id not set)

Example

{
    "api_token": "XXXX",
    "id": 327066
}
{
    "abbrev": "cc",
    "email": "[email protected]",
    "external_id": "user_42",
    "home_office": true,
    "id": 327066,
    "initial_time_account": 0,
    "locale": null,
    "salary": 0,
    "staff_number": null,
    "status": "active",
    "username": "Carol",
    "working_sessions_creator": false,
    "enterprise_id": 39246,
    "location_ids": [
        72214
    ],
    "working_area_ids": [
        164359,
        159948,
        159949,
        159950
    ],
    "tags": [],
    "data_profiles": {
        "birthday": {
            "label": "Geburtstag",
            "value": "1994-02-14"
        }
    }
}



Get Users

Get User(s) from your Papershift Account

URL

https://app.papershift.com/public_api/v1/users

Method

GET

Parameters

Parameters

Type

Required

api_token

String

required

location_ids

Integer, comma-separated for multiple IDs

optional

location_external_ids

String, comma-separated for multiple external IDs

optional if location_ids is not set

working_area_ids

Integer, comma-separated for multiple IDs

optional

working_area_external_ids

String, comma-separated for multiple external IDs

optional if working_area_ids is not set

tags

String, must contain comma-separated tag IDs and/or zero for shifts without tags

optional

page

Integer

optional

Information

A Successful Request returns an Array of the n-th 25 Users
depending on the Page-Param. You can also pass one or more
Working Area’s External- or Record-IDs to only query for Users of these
specific Working Areas. The same for locations: You can pass one or more
Location’s External- or Record-IDs to only query for Users in these
specific Locations.

It is possible to pass a list of tag IDs to only query Users
with tags specified by the given IDs. The list of tags IDs can also
contain a zero to include Users without any tags. The list of
tag IDs must be a comma-separated string that must contain positive
integers including zero, e.g. ‚3,7,15,0,8‘.

Example

{
  "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",

  "location_external_ids": "AAA,BBB",
  "working_area_external_ids": "XYZ1,XYZ2",
  "tags": "35,67,158",
  "page": 2
}
function getUsers() {
  var api_token = "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK";
  var location_external_ids = "AAA,BBB";
  var working_area_external_ids = "XYZ1,XYZ2";
  var tags = "35,67,158";
  var page = 2

  $.ajax({
    url: "https://app.papershift.com/public_api/v1/users?api_token=" + api_token + "&location_external_ids=" + location_external_ids + "&working_area_external_ids=" + working_area_external_ids + "&tags=" + tags + "&page=" + page,
    type: 'GET',
    dataType: 'json',
    complete: function (data) {
      console.log(data.responseText);
    }
  });
}
{
  "users": [
    {
      "abbrev": "",
      "email": "[email protected]",
      "external_id": null,
      "home_office": false,
      "id": 1,
      "initial_time_account": 0,
      "locale": "",
      "salary": 0,
      "staff_number": "",
      "username": "User 10",
      "working_sessions_creator": false,
      "enterprise_id": 371,
      "location_ids": [55, 98],
      "working_area_ids": [235, 375],
      "tags": [35, 67, 158],
      "data_profiles": {
        "birthday": {
          "label": "Geburtstag",
          "value": null
        }
      }
    },
    {
      "abbrev": null,
      "email": "",
      "external_id": null,
      "home_office": false,
      "id": 4,
      "initial_time_account": 0,
      "locale": null,
      "salary": 0,
      "staff_number": null,
      "username": "User 25",
      "working_sessions_creator": false,
      "enterprise_id": 371,
      "location_ids": [55, 98],
      "working_area_ids": [235, 375],
      "tags": [35, 67, 158],
      "data_profiles": {
        "birthday": {
          "label": "Geburtstag",
          "value": "1980-06-20"
        }
      }
    }
  ],
  "next_page": "http://localhost:5000/public_api/v1/users?api_token=6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK&location_external_ids=AAA,BBB&page=3&working_area_external_ids=XYZ1,XYZ2&tags=35,67,158"
}



Delete an existing User

Delete an existing User in you Paprshift account.

URL

https://app.papershift.com/public_api/v1/users

Method

DELETE

Parameters

Parameter

Type

Required

api_token

String

required

id

Integer

required

external_id

String

required if id not set

Information

To delete an existing User requires finding the specific record
in the Database. This can be achieved via the User’s
External-ID or Record-ID.

Example

{
  "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
  "user": {
    "id": 145
  }
}
function deleteUser() {
  var params = {
    "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
    "user": {
      "id": 145
    }
  };

  $.ajax({
    url: "https://app.papershift.com/public_api/v1/users",
    type: 'DELETE',
    dataType: 'json',
    data: JSON.stringify(params),
    complete: function (data) {
      console.log(data.responseText);
    }
  });
}
Response 200 (application/json)