{
  "openapi": "3.1.0",
  "info": {
    "title": "Roosterplaats API",
    "version": "1.0.0",
    "summary": "Rosters, employees, availability, worked hours, leave and sick leave of a Roosterplaats account.",
    "description": "REST API of Roosterplaats, Dutch online rostering software. Every response is JSON with a \"[request]\" object (path, arguments, date, status) and a data key named after the endpoint, for example \"[employees]\". The API is available in the Business and Enterprise packages: an account administrator switches it on under Instellingen > API-toegang, creates the token there and adds the IP addresses that may call the API (whitelist). Each token belongs to one company (vestiging). Documentation in Dutch: https://www.roosterplaats.nl/support/api-toegang/algemeen-api-toegang/roosterplaats-api",
    "contact": { "name": "Roosterplaats", "url": "https://www.roosterplaats.nl/contact/", "email": "info@roosterplaats.nl" }
  },
  "externalDocs": { "description": "Endpoint documentation (Dutch)", "url": "https://www.roosterplaats.nl/support/api-toegang" },
  "servers": [ { "url": "https://roosterplaats.nl/api/v1", "description": "Production (HTTPS only; plain HTTP is refused)" } ],
  "security": [ { "apiKeyHeader": [] }, { "apiKeyQuery": [] } ],
  "tags": [
    { "name": "Schedule", "description": "Rosters per ISO week" },
    { "name": "Employees", "description": "Employees of the company" },
    { "name": "Availability", "description": "Availability entered by employees" },
    { "name": "Reporting", "description": "Worked hours, sick leave and leave requests over a period" }
  ],
  "paths": {
    "/schedule/details/{year}/{week}/": {
      "get": {
        "tags": ["Schedule"], "operationId": "getScheduleDetails",
        "summary": "Roster of a week",
        "description": "Id, status and start and end date of the roster of an ISO week.",
        "parameters": [ { "$ref": "#/components/parameters/year" }, { "$ref": "#/components/parameters/week" } ],
        "responses": {
          "200": { "description": "The roster", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[schedule]": { "type": "object", "properties": {
                "id": { "type": "string", "description": "Roster (session) id" },
                "week": { "type": ["string", "integer"] }, "year": { "type": ["string", "integer"] },
                "status": { "type": "string", "description": "For example \"In bewerking\" (draft) or \"Gepubliceerd\" (published)" },
                "startDate": { "type": "string", "format": "date" }, "endDate": { "type": "string", "format": "date" } } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/schedule/employees/{year}/{week}/": {
      "get": {
        "tags": ["Schedule"], "operationId": "getScheduleEmployees",
        "summary": "Shifts per employee in a week",
        "description": "Every scheduled shift per employee for an ISO week, with scheduled hours, breaks and costs.",
        "parameters": [ { "$ref": "#/components/parameters/year" }, { "$ref": "#/components/parameters/week" } ],
        "responses": {
          "200": { "description": "Shifts per employee", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[employeeSchedule]": { "type": "array", "items": { "type": "object", "properties": {
                "id": { "type": "integer", "description": "Employee id" },
                "firstName": { "type": "string" }, "lastName": { "type": "string" },
                "hourlyRate": { "type": ["number", "string"] },
                "contractType": { "type": "string", "enum": ["vast", "flex"] },
                "contractHours": { "type": ["number", "string"] },
                "totalScheduledHours": { "type": "number" }, "totalScheduledCosts": { "type": "number" },
                "scheduledShifts": { "type": "array", "items": { "type": "object", "properties": {
                  "departmentName": { "type": "string" }, "departmentId": { "type": "integer" },
                  "shiftName": { "type": "string" }, "shiftId": { "type": "integer" },
                  "AllowancePercentage": { "type": "number", "description": "100 = normal rate, 150 = 50% allowance" },
                  "scheduledStart": { "type": "string", "description": "YYYY-MM-DD HH:MM" },
                  "scheduledEnd": { "type": "string", "description": "YYYY-MM-DD HH:MM" },
                  "scheduledHours": { "type": "number" }, "scheduledBreakTime": { "type": "number", "description": "Hours" },
                  "scheduledCosts": { "type": "number" } } } } } } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/employees/": {
      "get": {
        "tags": ["Employees"], "operationId": "listEmployees",
        "summary": "All employees",
        "description": "All employees of the company that are not marked as left (uit dienst), sorted by first name. Inactive employees are included; contractStatus tells whether someone can be scheduled today. With no employees the value of [employees] is the text \"no result found\".",
        "responses": {
          "200": { "description": "The employees", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[employees]": { "oneOf": [ { "type": "array", "items": { "$ref": "#/components/schemas/Employee" } }, { "type": "string", "const": "no result found" } ] } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/employees/add/": {
      "post": {
        "tags": ["Employees"], "operationId": "addEmployee",
        "summary": "Add an employee",
        "description": "Creates one new employee on every call. Look the employee up with listEmployees first (for example by externalReference) to avoid duplicates. Note the field names differ from listEmployees: tariff instead of hourlyRate, notes instead of note, and contractType vast/flexibel.",
        "requestBody": { "required": true, "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/NewEmployee" } },
          "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/NewEmployee" } } } },
        "responses": {
          "200": { "description": "The new employee, or [request].status \"failure\" with a reason (for example missing mandatory fields)", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "allOf": [ { "$ref": "#/components/schemas/RequestInfo" }, { "type": "object", "properties": { "reason": { "type": "string" } } } ] },
              "[employee]": { "allOf": [ { "type": "object", "properties": { "id": { "type": "integer" } } }, { "$ref": "#/components/schemas/NewEmployee" } ] } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/availability/employees/{year}/{week}/": {
      "get": {
        "tags": ["Availability"], "operationId": "getAvailability",
        "summary": "Availability per employee in a week",
        "description": "The availability employees entered for an ISO week: per date one or more time ranges, plus their note and the maximum number of shifts they want to work.",
        "parameters": [ { "$ref": "#/components/parameters/year" }, { "$ref": "#/components/parameters/week" } ],
        "responses": {
          "200": { "description": "Availability per employee", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[availability]": { "type": "array", "items": { "type": "object", "properties": {
                "id": { "type": "integer" }, "firstName": { "type": "string" }, "lastName": { "type": "string" },
                "availabilityNote": { "type": ["string", "null"] },
                "availabilityMaxShifts": { "type": ["integer", "null"], "description": "Maximum number of shifts this week, as entered by the employee" },
                "availability": { "type": "array", "items": { "type": "object", "description": "Keys are dates (YYYY-MM-DD)",
                  "additionalProperties": { "type": "array", "items": { "type": "object", "properties": {
                    "startAvailability": { "type": "string", "description": "HH:MM" }, "endAvailability": { "type": "string", "description": "HH:MM" } } } } } } } } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/reporting/hours-registration/{startDate}/{endDate}/": {
      "get": {
        "tags": ["Reporting"], "operationId": "getHoursRegistration",
        "summary": "Scheduled versus worked hours",
        "description": "Per employee, shift and day: the scheduled times, hours and costs next to the worked times, hours and costs from the hours registration (the scheduled time when nothing was registered), with travel and expenses.",
        "parameters": [ { "$ref": "#/components/parameters/startDate" }, { "$ref": "#/components/parameters/endDate" }, { "$ref": "#/components/parameters/contractPermanent" }, { "$ref": "#/components/parameters/contractFlex" }, { "$ref": "#/components/parameters/sort" }, { "$ref": "#/components/parameters/order" } ],
        "responses": {
          "200": { "description": "Hours per shift", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[hoursRegistration]": { "type": "array", "items": { "type": "object", "properties": {
                "firstName": { "type": "string" }, "lastName": { "type": "string" }, "externalReference": { "type": ["string", "null"] },
                "contractType": { "type": "string", "enum": ["vast", "flex"] },
                "locationName": { "type": "string", "description": "Company (vestiging)" }, "departmentName": { "type": "string" }, "shiftName": { "type": "string" },
                "date": { "type": "string", "format": "date" },
                "scheduledStart": { "type": "string", "description": "HH:MM" }, "scheduledEnd": { "type": "string", "description": "HH:MM" },
                "scheduledHours": { "type": "number" }, "scheduledCosts": { "type": "number" },
                "actualStart": { "type": "string", "description": "HH:MM" }, "actualEnd": { "type": "string", "description": "HH:MM" },
                "actualHours": { "type": "number" }, "actualCosts": { "type": "number" }, "differenceHours": { "type": "number" },
                "travelTime": { "type": ["string", "number"] }, "travelDistance": { "type": ["string", "number"] },
                "travelExpenses": { "type": ["string", "number"] }, "generalExpenses": { "type": ["string", "number"] },
                "notes": { "type": ["string", "null"] },
                "status": { "type": "string", "enum": ["open", "ingediend", "verwerkt"], "description": "open = not submitted, ingediend = submitted by the employee, verwerkt = processed" } } } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/reporting/sick-leave/{startDate}/{endDate}/": {
      "get": {
        "tags": ["Reporting"], "operationId": "getSickLeave",
        "summary": "Sick leave in a period",
        "parameters": [ { "$ref": "#/components/parameters/startDate" }, { "$ref": "#/components/parameters/endDate" }, { "$ref": "#/components/parameters/contractPermanent" }, { "$ref": "#/components/parameters/contractFlex" }, { "$ref": "#/components/parameters/sort" }, { "$ref": "#/components/parameters/order" } ],
        "responses": {
          "200": { "description": "Sick leave per employee", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[sickLeave]": { "type": "array", "items": { "type": "object", "properties": {
                "firstName": { "type": "string" }, "lastName": { "type": "string" }, "externalReference": { "type": ["string", "null"] },
                "contractType": { "type": "string", "enum": ["vast", "flex"] },
                "startDate": { "type": "string", "format": "date" }, "startTime": { "type": ["string", "null"], "description": "HH:MM, null for a whole day" },
                "endDate": { "type": ["string", "null"], "format": "date", "description": "null while the sick leave is ongoing" }, "endTime": { "type": ["string", "null"] } } } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/reporting/leave-requests/{startDate}/{endDate}/": {
      "get": {
        "tags": ["Reporting"], "operationId": "getLeaveRequests",
        "summary": "Leave requests in a period",
        "parameters": [ { "$ref": "#/components/parameters/startDate" }, { "$ref": "#/components/parameters/endDate" }, { "$ref": "#/components/parameters/contractPermanent" }, { "$ref": "#/components/parameters/contractFlex" }, { "$ref": "#/components/parameters/sort" }, { "$ref": "#/components/parameters/order" } ],
        "responses": {
          "200": { "description": "Leave requests per employee", "content": { "application/json": { "schema": {
            "type": "object", "properties": {
              "[request]": { "$ref": "#/components/schemas/RequestInfo" },
              "[leaveRequests]": { "type": "array", "items": { "type": "object", "properties": {
                "firstName": { "type": "string" }, "lastName": { "type": "string" }, "externalReference": { "type": ["string", "null"] },
                "contractType": { "type": "string", "enum": ["vast", "flex"] },
                "startDate": { "type": "string", "format": "date" }, "startTime": { "type": ["string", "null"] },
                "endDate": { "type": "string", "format": "date" }, "endTime": { "type": ["string", "null"] },
                "requestedHours": { "type": ["string", "number"] },
                "compensationHours": { "type": ["string", "number"], "description": "Hours taken as time off in lieu (tijd-voor-tijd) instead of leave" },
                "leaveType": { "type": "string" },
                "status": { "type": "string", "enum": ["open", "akkoord", "afgewezen"], "description": "open, akkoord (approved) or afgewezen (rejected)" },
                "notes": { "type": ["string", "null"] } } } } } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }, "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKeyHeader": { "type": "apiKey", "in": "header", "name": "X-API-KEY", "description": "The token from Instellingen > API-toegang (preferred: not logged in URLs)" },
      "apiKeyQuery": { "type": "apiKey", "in": "query", "name": "token", "description": "The same token as a query parameter; takes precedence over the header" }
    },
    "parameters": {
      "year": { "name": "year", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 2000 }, "description": "ISO year" },
      "week": { "name": "week", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "maximum": 53 }, "description": "ISO week number" },
      "startDate": { "name": "startDate", "in": "path", "required": true, "schema": { "type": "string", "format": "date" } },
      "endDate": { "name": "endDate", "in": "path", "required": true, "schema": { "type": "string", "format": "date" } },
      "contractPermanent": { "name": "contractPermanent", "in": "query", "schema": { "type": "integer", "enum": [0, 1], "default": 1 }, "description": "Include employees with a permanent contract (vast)" },
      "contractFlex": { "name": "contractFlex", "in": "query", "schema": { "type": "integer", "enum": [0, 1], "default": 1 }, "description": "Include flexible employees (flex)" },
      "sort": { "name": "sort", "in": "query", "schema": { "type": "string" }, "description": "Field name of the result to sort on" },
      "order": { "name": "order", "in": "query", "schema": { "type": "string", "enum": ["asc", "desc"], "default": "asc" } }
    },
    "schemas": {
      "RequestInfo": { "type": "object", "properties": {
        "path": { "type": "string" }, "arguments": { "type": ["object", "array"] },
        "date": { "type": "string", "description": "YYYY-MM-DD HH:MM:SS" }, "status": { "type": "string", "enum": ["success", "failure"] } } },
      "Employee": { "type": "object", "properties": {
        "id": { "type": "integer", "description": "Roosterplaats employee id, also used in the schedule and availability endpoints" },
        "externalReference": { "type": ["string", "null"], "description": "Own reference, such as the payroll number" },
        "firstName": { "type": "string" }, "lastName": { "type": "string", "description": "Including prefix (tussenvoegsel)" },
        "emailAddress": { "type": ["string", "null"] }, "phoneNumber": { "type": ["string", "null"] }, "note": { "type": ["string", "null"] },
        "hourlyRate": { "type": ["number", "string"], "description": "Euro" },
        "contractType": { "type": "string", "enum": ["vast", "flex"] },
        "contractStatus": { "type": "string", "enum": ["actief", "inactief", "buiten_contract"], "description": "Status today: actief (can be scheduled), inactief (set inactive) or buiten_contract (today is outside the contract dates)" },
        "contractHours": { "type": ["number", "string"], "description": "Contract hours per week" } } },
      "NewEmployee": { "type": "object", "required": ["firstName", "lastName", "contractHours", "tariff"], "properties": {
        "firstName": { "type": "string" }, "lastName": { "type": "string" },
        "emailAddress": { "type": "string", "format": "email" }, "phoneNumber": { "type": "string" },
        "externalReference": { "type": "string" },
        "contractStatus": { "type": "string", "enum": ["actief", "inactief"], "default": "actief" },
        "contractHours": { "type": ["number", "string"], "description": "Per week, at most 2 decimals" },
        "contractType": { "type": "string", "enum": ["vast", "flexibel"], "default": "vast" },
        "contractStart": { "type": "string", "description": "Start date of the contract, for example 22-01-2018" },
        "contractEnd": { "type": "string" },
        "tariff": { "type": ["number", "string"], "description": "Hourly rate in euro, at most 2 decimals" },
        "preference": { "type": ["string", "integer"], "description": "Preference (1-5 stars) for automatic planning; default 3" },
        "notes": { "type": "string" } } }
    },
    "responses": {
      "Unauthorized": { "description": "No token or an invalid token", "content": { "application/json": { "schema": { "type": "string" } } } },
      "Forbidden": { "description": "Valid token, but the request comes from an IP address that is not on the whitelist of the account" }
    }
  }
}
