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
URLhttps://app.papershift.com/public_api/v1/assignments
MethodPOST
ParametersParameter | Type | Required |
---|---|---|
api_token | String | required |
shift_id | String | required |
user_id | Integer | required |
user_external_id | String | required if user_id is not set |
application | Boolean | optional |
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.
{
"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
URLhttps://app.papershift.com/public_api/v1/assignments
MethodGET
ParametersParameter | Type | Required |
---|---|---|
api_token | String | required |
shift_id | String | required |
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.
{
"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
URLhttps://app.papershift.com/public_api/v1/assignments
MethodDELETE
ParametersParameters | Type | Required |
---|---|---|
api_token | String | required |
shift_id | String | required |
user_id | Integer | required |
user_external_id | String | required if user_id is not set |
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.
{
"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": []
}
}
Updated 24 days ago