Shift Assignments

The API- functions for Shift Assignments in Papershift



Assign a User to a Shift

Assign a user to an existing shift in your Papershift account

URL

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

Method

POST

Parameters

ParameterTypeRequired
api_tokenStringrequired
shift_idStringrequired
user_idIntegerrequired
user_external_idStringrequired if user_id is not set
applicationBooleanoptional

Information

Assigning a user to an existing shift requires finding the specific
record in the database. This can be achieved via the shift’s record ID.
You also have to specify the user’s external- or record ID.
By setting application to true, the user is not directly assigned
to the shift, but rather is marked as someone who has applied for
this shift. Already assigned users get re-assigned/re-applied.

Example

{
        "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
        "assignment": {
          "shift_id": 740,
          "user_id": 3,
          "application": true
        }
      }
function createAssignment() {
        var params = {
          "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
          "assignment": {
            "shift_id": 740,
            "user_id": 3,
            "application": true
          }
        };
  
        $.ajax({
          url: "https://app.papershift.com/public_api/v1/assignments",
          type: 'POST',
          headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
          },
          dataType: 'json',
          data: JSON.stringify(params),
          complete: function (data) {
            console.log(data.responseText);
          }
        });
      }
{
        "users": {
          "assigned": [
            {
              "id": 4,
              "username": "User-004"
            }
          ],
          "applied": [
            {
              "id": 3,
              "username": "User-003"
            },
            {
              "id": 5,
              "username": "User-005"
            }
          ]
        }
      }



Get all Shift Assignments

Get all assignments on an existing shift

URL

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

Method

GET

Parameters

ParameterTypeRequired
api_tokenStringrequired
shift_idStringrequired

Information

Getting all assignments on an existing shift requires finding the specific
record in the database. This can be achieved via the shift’s record ID.

Example

{
        "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
        "shift_id": 740
      }
function getAssignments() {
        var api_token = "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK";
        var shift_id = 740;
  
        $.ajax({
          url: "https://app.papershift.com/public_api/v1/assignments?api_token=" + api_token + "&shift_id=" + shift_id,
          type: 'GET',
          dataType: 'json',
          complete: function (data) {
            console.log(data.responseText);
          }
        });
      }
{
        "users": {
          "assigned": [
            {
              "id": 4,
              "username": "User-004"
            }
          ],
          "applied": [
            {
              "id": 3,
              "username": "User-003"
            },
            {
              "id": 5,
              "username": "User-005"
            }
          ]
        }
      }



Delete a User from a Shift

Delete user assignments on an existing shift

URL

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

Method

DELETE

Parameters

ParametersTypeRequired
api_tokenStringrequired
shift_idStringrequired
user_idIntegerrequired
user_external_idStringrequired if user_id is not set

Information

To delete an existing shift requires finding the specific
record in the database. This can be achieved via the shift’s record ID.
You also have to specify the user’s external- or record ID.

Example

{
        "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
        "assignment": {
          "shift_id": 740,
          "user_id": 3
        }
      }
function deleteUserFromShift() {
        var params = {
          "api_token": "6ooIiSZaiBwaFBLxveJkm7pP8uTOPLPSwDL6QsOK",
          "assignment": {
            "shift_id": 740,
            "user_id": 3
          }
        };
  
        $.ajax({
          url: "https://app.papershift.com/public_api/v1/assignments",
          type: 'DELETE',
          headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
          },
          dataType: 'json',
          data: JSON.stringify(params),
          complete: function (data) {
            console.log(data.responseText);
          }
        });
      }
{
        "users": {
          "assigned": [],
          "applied": []
       }
      }