Shift Scheduling

The shift schedule has simple operations for scheduling who is working when and in which unit

Create Shift

curl -i -X POST "https://example.ziik.io/api/shifts"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 201 Created with a location header for where to find the newly created shift

HTTP/1.0 201 Created
Location: https://example.ziik.io/api/shifts/1234
{
  "data": {
    "id": 1,
    "content_type": "schedule",
    "date": {
      "start": 1540857600,
      "end": 1540861200
    },
    "type": "trade",
    "trade": true,
    "note": null,
    "comment": null,
    "break": null,
    "unit": {
      "content_type": "unit",
      "id": 2,
      "name": "Wyman, Beer and Hane",
      "level": 1,
      "unit_type": "unit",
      "url": "api/units/2"
    },
    "assigned": {
      "content_type": "user",
      "id": 3,
      "name": "Caleigh Breitenberg",
      "first_name": "Caleigh",
      "last_name": "Breitenberg",
      "title": "Postal Service Clerk",
      "avatar": null,
      "active": true,
      "unit": {
        "content_type": "unit",
        "id": 1,
        "name": "HQ",
        "level": 0,
        "unit_type": "unit",
        "url": "api/units/1"
      },
      "url": "api/users/3"
    },
    "creator": {
      "content_type": "user",
      "id": 2,
      "name": "Johan Daniel",
      "first_name": "Johan",
      "last_name": "Daniel",
      "title": "Shear Machine Set-Up Operator",
      "avatar": null,
      "unit": {
        "content_type": "unit",
        "id": 1,
        "name": "HQ",
        "level": 0,
        "unit_type": "unit",
        "url": "api/units/1"
      },
      "url": "api/users/2"
    },
    "applicants": [],
    "permissions": {
      "edit": false,
      "delete": false,
      "take": false,
      "request": false,
      "close": false,
      "apply": false,
      "approve": false
    },
    "url": "api/shifts/1"
  }
}

This endpoint creates a shift.

HTTP Request

POST https://example.ziik.io/api/shifts

Request Parameters

ParameterTypeRequiredDescription
unitIntegerNoUnit to create shift in. Defaults to user's own unit
startIntegerYesUnix timestamp of when the shift begins
endIntegerYesUnix timestamp of when the shift ends
assignedIntegerNoUser ID of shift assignee
tradeBooleanNoWhether the shift should be available for trade

Permissions Required

  • Schedule permission to units and shift's unit equal to user's unit or below

Get Shifts

curl "https://example.ziik.io/api/shifts"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
{
  "data": [
    {
      "id": 1,
      "content_type": "schedule",
      "date": {
        "start": "1541462400",
        "end": "1541469600"
      },
      "type": "taken",
      "trade": false,
      "note": null,
      "comment": "",
      "break": 60,
      "unit": {
        "content_type": "unit",
        "id": 1,
        "name": "HQ",
        "level": 0,
        "unit_type": "unit",
        "url": "api/units/1"
      },
      "assigned": {
        "content_type": "user",
        "id": 3,
        "name": "Kadin Hill",
        "first_name": "Kadin",
        "last_name": "Hill",
        "title": "Financial Analyst",
        "avatar": null,
        "active": true,
        "unit": {
          "content_type": "unit",
          "id": 1,
          "name": "HQ",
          "level": 0,
          "unit_type": "unit",
          "url": "api/units/1"
        },
        "url": "api/users/3"
      },
      "creator": null,
      "applicants": [],
      "permissions": {
        "edit": false,
        "delete": false,
        "take": false,
        "request": false,
        "close": false,
        "apply": false,
        "approve": false
      },
      "url": "api/shifts/1"
    }
  ]
}

This endpoint retrieves a list of shifts.

HTTP Request

GET https://example.ziik.io/api/shifts

Query Parameters

ParameterTypeDefaultDescription
unitIntegerUser's unitUnit to fetch shifts for
userIntegerNULLUser to fetch shifts for. Overrides any unit parameter set
startIntegerNULLUnix timestamp of earliest start time of a shift
endIntegerNULLUnix timestamp of latest start time of a shift
includeVacationsBooleanfalseWhether to include vacations in the returned list
typesArrayAnyOne or more shift types to fetch - 1: taken, 2: trade, 3: open

Get Single Shift

curl "https://example.ziik.io/api/shift/123"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"

The above command returns JSON structured like this:

{
  "data": {
    "id": 1,
    "content_type": "schedule",
    "date": {
      "start": "1540771200",
      "end": "1541469600"
    },
    "type": "taken",
    "trade": false,
    "note": null,
    "comment": "",
    "break": 60,
    "unit": {
      "content_type": "unit",
      "id": 1,
      "name": "HQ",
      "level": 0,
      "unit_type": "unit",
      "url": "api/units/1"
    },
    "assigned": {
      "content_type": "user",
      "id": 3,
      "name": "Winona Schuster",
      "first_name": "Winona",
      "last_name": "Schuster",
      "title": "Political Scientist",
      "avatar": null,
      "active": true,
      "unit": {
        "content_type": "unit",
        "id": 1,
        "name": "HQ",
        "level": 0,
        "unit_type": "unit",
        "url": "api/units/1"
      },
      "url": "api/users/3"
    },
    "creator": null,
    "applicants": [],
    "permissions": {
      "edit": false,
      "delete": false,
      "take": false,
      "request": false,
      "close": false,
      "apply": false,
      "approve": false
    },
    "url": "api/shifts/1"
  }
}

This endpoint returns a single shift

HTTP Request

GET https://example.ziik.io/api/shifts/ID

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the shift

Permissions Required

  • Authenticated user

Edit Shift

curl -i -X PATCH "https://example.ziik.io/api/shifts/123"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on successful update.

HTTP/1.0 204 No Content

This endpoint updates an existing shift.

HTTP Request

PATCH https://example.ziik.io/api/shifts/ID

Request Parameters

ParameterTypeRequiredDescription
unitIntegerNoUnit to create shift in. Defaults to user's own unit
startIntegerNoUnix timestamp of when the shift begins
endIntegerNoUnix timestamp of when the shift ends
assignedIntegerNoUser ID of shift assignee
tradeBooleanNoWhether the shift should be available for trade

Permissions Required

  • Schedule permission to units and shift's unit equal to user's unit or below

Delete Shift

curl -i -X DELETE "https://example.ziik.io/api/shifts/123"
  -H "Authorization: Bearer aaaaaa.bbbbbbb.ccccccc"

The above command returns a 204 No Content header on success:

HTTP/1.0 204 No Content

This endpoint deletes a shift.

HTTP Request

DELETE https://example.ziik.io/api/shifts/ID

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the shift to delete

Permissions Required

  • Schedule permission to units and shift's unit equal to user's unit or below
Last Updated:
Contributors: Christian Gerdes