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": []
       }
      }