swagger: '2.0'

info:
  version: '1.0'
  title: "Sage HR API"
  description: 'All requests are required to be sent to your subdomain. To learn how to enable API in your Sage HR account, please visit https://support.sage.hr/en/articles/3246469-how-does-cakehr-api-work'

host: subdomain.sage.hr

basePath: /api

schemes:
  - https

consumes:
  - application/json

produces:
  - application/json

securityDefinitions:
  api_key:
    type: apiKey
    name: X-Auth-Token
    in: header
    description: All request are required to pass a `X-Auth-Token` header.

paths:
  /employees:
    x-summary: Employees
    get:
      summary: List active employees in company
      tags:
        - Employee
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: team_history
          in: query
          type: boolean
          x-example: true
        - name: employment_status_history
          in: query
          type: boolean
          x-example: true
        - name: position_history
          in: query
          type: boolean
          x-example: true
      responses:
        '200':
          description: Successful Response, team_history/employment_status_history/position_history collections are returned only if regarding optional paramters are provided in query
          examples:
            application/json:
              data:
                - id: 19
                  email: john@example.com
                  first_name: John
                  last_name: Doe
                  picture_url: https://example.com/john.png
                  employment_start_date: '2014-08-25'
                  date_of_birth: '1991-02-13'
                  team: Sage HR
                  team_id: 1
                  position: Api developer
                  position_id: 123
                  reports_to_employee_id: 5
                  work_phone: '555-0505'
                  home_phone: '555-0506'
                  mobile_phone: '555-0507'
                  gender: 'Male'
                  street_first: '84 Glenwood Street'
                  street_second: 'Peoria'
                  city: "London"
                  post_code: 99999
                  country: "GB"
                  employee_number: "A01"
                  employment_status: "Full-time"
                  nationality: "Spanish"
                  marital_status: "Married"
                  personal_identification_number: "1"
                  tax_number: "1"
                  irregular_contract_worker: true
                  team_history:
                    - team_id: 1
                      start_date: '2018-01-01'
                      end_date: '201-01-01'
                      team_name: 'Some Team'
                  employment_status_history:
                    - employment_status_id: 1
                      start_date: '2018-01-01'
                      end_date: '201-01-01'
                      employment_statu_name: 'Full time'
                  position_history:
                    - position_id: 1
                      start_date: '2018-01-01'
                      end_date: '201-01-01'
                      position_name: 'Developer'
                      position_code: '1234'
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75
    post:
      summary: Create new employee
      tags:
        - Employee
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: formData
          name: email
          type: string
          required: true
          description: Employees email
        - in: formData
          name: first_name
          type: string
          required: true
          description: Employees first name
        - in: formData
          name: last_name
          type: string
          required: true
          description: Employees last name
        - in: formData
          name: work_start_date
          type: string
          required: false
          description: "Employees work start date, format: YYYY-MM-DD, leave empty to use todays date"
        - in: formData
          name: send_email
          type: string
          required: false
          description: "'true' to send welcome email to employee"
        - in: formData
          name: date_of_birth
          type: string
          required: false
          description: "Employees date of birth, format: YYYY-MM-DD"
        - in: formData
          name: gender
          type: string
          required: false
          description: "Employees gender, Must be one of: Male, Female, Other"
        - in: formData
          name: marital_status
          type: string
          required: false
          description: "Employees marital status, Must be one of: Married, Single, Divorced, Widower, In a relationship, Other"  
        - in: formData
          name: nationality
          type: string
          required: false
          description: "Employees nationalty in long form, example: Canadian"
        - in: formData
          name: country
          type: string
          required: false
          description: Employees country two character ISO code
        - in: formData
          name: state
          type: string
          required: false
          description: "Employees address: state"
        - in: formData
          name: post_code
          type: string
          required: false
          description: "Employees address: zip or postal code"
        - in: formData
          name: street_first
          type: string
          required: false
          description: Employees address first line 
        - in: formData
          name: street_second
          type: string
          required: false
          description: Employees address second line
        - in: formData
          name: city
          type: string
          required: false
          description: Employees address city
        - in: formData
          name: position_title
          type: string
          required: false
          description: Employees position    
        - in: formData
          name: home_phone
          type: string
          required: false
          description: Home phone
        - in: formData
          name: work_phone
          type: string
          required: false
          description: Work phone
        - in: formData
          name: mobile_phone
          type: string
          required: false
          description: Mobile phone 
        - in: formData
          name: personal_identification_number
          type: string
          required: false
          description: Personal Identification number
        - in: formData
          name: tax_number
          type: string
          required: false
          description: Tax number  
        - in: formData
          name: irregular_contract_worker
          type: boolean
          required: false
          description: "Irregular hour or part-year worker"  
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1

  /employees/{id}:
    x-summary: Employee
    put:
      summary: Update Employee
      tags:
        - Employee
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user to update.
        - name: parameters
          in: body
          schema:
            type: object
            properties:
              first_name:
                type: string
                example: 'Jane'
              last_name:
                type: string
                example: 'Doe'
              work_start_date:
                type: string
                example: '2020-01-28'
              location_id:
                type: integer
                example: 1
              team_id:
                type: integer
                example: 2
              leader_id:
                type: integer
                example: 3
              date_of_birth:
                type: string
                example: '2000-01-28' 
              gender:
                type: string
                example: 'Male' 
              marital_status:
                type: string
                example: 'Married'
              nationality:
                type: string
                example: 'Canadian'
              country:
                type: string
                example: 'US'
              state:
                type: string
                example: 'Nevada'
              post_code:
                type: string
                example: '90210'
              street_first:
                type: string
                example: '1486 Frog Street'
              street_second:
                type: string
                example: 'Apartment 2, first floor'
              city:
                type: string
                example: 'New York'
              position_id:
                type: integer
                example: 101
              employee_number:
                type: string
                example: '0123456'
              home_phone:
                type: string
                example: '1234567'
              work_phone:
                type: string
                example: '1234567'  
              mobile_phone:
                type: string
                example: '1234567'  
              personal_identification_number:
                type: string
              tax_number:
                type: string
              approver_ids:
                type: array
                items:
                  type: integer
                  example: 1
              selected_leave_types:
                type: array
                items:
                  type: integer
                  example: 2
              irregular_contract_worker:
                type: boolean
                example: true
                description: "Irregular hour or part-year worker"    
      responses:
        '202':
          description: Accepted
          examples:
            application/json:
              data:
                id: 1711
        '404':
          description: Not Found
          examples:
            application/json:
              error_code: 'not_found'
              errors: []
    get:
      summary: Single active employee in company
      tags:
        - Employee
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: team_history
          in: query
          type: boolean
          x-example: true
        - name: employment_status_history
          in: query
          type: boolean
          x-example: true
        - name: position_history
          in: query
          type: boolean
          x-example: true
      responses:
        200:
          description: Successful Response, team_history/employment_status_history/position_history collections are returned only if regarding optional paramters are provided in query
          examples:
            application/json:
              data:
                id: 19
                email: john@example.com
                first_name: John
                last_name: Doe
                picture_url: https://example.com/john.png
                employment_start_date: '2014-08-25'
                date_of_birth: '1991-02-13'
                team: Sage HR
                team_id: 6742
                position: Api developer
                position_id: 123
                reports_to_employee_id: 5
                work_phone: '555-0505'
                home_phone: '555-0506'
                mobile_phone: '555-0507'
                gender: 'Male'
                street_first: '84 Glenwood Street'
                street_second: 'Peoria'
                city: "London"
                post_code: 99999
                country: "GB"
                employee_number: "A1"
                irregular_contract_worker: true
                employment_status: Full-time
                nationality: "Spanish"
                marital_status: "Married"
                personal_identification_number: "1"
                tax_number: "1"
                team_history:
                  - team_id: 1
                    start_date: '2018-01-01'
                    end_date: '201-01-01'
                    team_name: 'Some Team'
                employment_status_history:
                  - employment_status_id: 1
                    start_date: '2018-01-01'
                    end_date: '201-01-01'
                    employment_statu_name: 'Full time'
                position_history:
                  - position_id: 1
                    start_date: '2018-01-01'
                    end_date: '201-01-01'
                    position_name: 'Developer'
                    position_code: '1234'
  
  /employees/{id}/custom-fields:
    x-summary: Custom fields
    get:
      summary: Employee custom fields
      tags:
        - Employee
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 1
                  label: Hobby
                  type: CustomDropdownField
                  value: Hockey
                  options:
                    - Hockey
                    - Football
                    - Voleyball
                - id: 2
                  label: Languages
                  type: CustomTags
                  options: null
                  value:
                    - English
                    - Latvian
                    - Estonian

  /employees/{id}/custom-fields/{custom_field_id}:
    x-summary: Custom field
    put:
      summary: Update custom field
      description: Update employee custom field
      tags:
        - Employee
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Employee identifier
        - in: path
          name: custom_field_id
          type: integer
          required: true
          description: Custom field identifier
        - in: formData
          name: value
          type: string
          required: true
          description: String or array (for tags)
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
        '422':
          description: Unprocessable entity
          examples:
            application/json:
              error_code: validation_failed
              errors:
                - Custom field text too long (max 250 characters)

  /employees/{id}/terminations:
    x-summary: Terminate employee
    post:
      summary: Terminate employee
      tags:
        - Employee
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - in: formData
          name: date
          type: string
          required: true
          description: "Last working day; format: YYYY-MM-DD"
        - in: formData
          name: termination_reason_id
          type: number
          required: true
          description: Termination reason ID
        - in: formData
          name: comments
          type: string
          required: false
          description: Comments
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data: {}

  /employees/{id}/rehire:
    x-summary: Rehire employee           
    post:
      summary: Rehire employee
      tags:
        - Employee
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - in: formData
          name: date
          type: string
          required: true
          description: "New start working day; format: YYYY-MM-DD"
        - in: formData
          name: comments
          type: string
          required: false
          description: Comments
        - in: formData
          name: start_fresh
          type: boolean
          required: false
          default: true
          description: "This parameter is used to start the employee record clean, resetting the employee’s leave balances."  
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data: {}
        '404':
          description: Error Response when Employee ID non existing or non terminated
          examples:
            application/json:
              error_code: not_found
              errors: []     
        '422':
          description: Error Response because of invalid params
          examples:
            application/json:
              error_code: validation_failed
              errors: ["Settings work start date can't be blank"]               

  /terminated-employees:
    x-summary: Terminated employees
    get:
      summary: List terminated employees in company
      tags:
        - Employee
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: team_history
          in: query
          type: boolean
          x-example: true
        - name: employment_status_history
          in: query
          type: boolean
          x-example: true
        - name: position_history
          in: query
          type: boolean
          x-example: true  
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 19
                  termination_date: "2015-05-28"
                  employee_number: "123"
                  email: john@example.com
                  first_name: John
                  last_name: Doe
                  picture_url: https://example.com/john.png
                  employment_start_date: '2014-08-25'
                  date_of_birth: '1991-02-13'
                  position: Api developer
                  personal_identification_number: "1"
                  tax_number: "1"
                  team_history:
                    - team_id: 1
                      start_date: '2018-01-01'
                      end_date: '201-01-01'
                      team_name: 'Some Team'
                  employment_status_history:
                    - employment_status_id: 1
                      start_date: '2018-01-01'
                      end_date: '201-01-01'
                      employment_statu_name: 'Full time'
                  position_history:
                    - position_id: 1
                      start_date: '2018-01-01'
                      end_date: '201-01-01'
                      position_name: 'Developer'
                      position_code: '1234'
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75

  /terminated-employees/{id}:
    x-summary: Terminated employee
    get:
      summary: Single terminated employee in company
      tags:
        - Employee
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 19
                email: john@example.com
                first_name: John
                last_name: Doe
                picture_url: https://example.com/john.png
                employment_start_date: '2014-08-25'
                date_of_birth: '1991-02-13'
                position: Api developer
                position_id: 1234
                reports_to_employee_id: 1000
                work_phone: "867-5309"
                home_phone: "555-5555"
                mobile_phone: "555-1234"
                gender: "Male"
                street_first: "123 some Street"
                stree_second: "3A"
                city: "London"
                post_code: "E8 1LA"
                country: "GB"
                employee_number: 123
                personal_identification_number: "1"
                tax_number: "1"
                termination_date: "2015-05-28"
                termination:
                  reason: Moving location
                  comments: Moving to

  /leave-management/policies:
    x-summary: Time off policies
    get:
      summary: List time off policies
      tags:
        - Leave management
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 1
                  name: Vacation
                  color: "#49B284"
                  do_not_accrue: false
                  unit: "days"
                  default_allowance: "26"
                  max_carryover: "100.0"
                  accrue_type: "yearly"
                - id: 2
                  name: Sickday
                  color: "#DB263F"
                  do_not_accrue: true
                  unit: "days"
                  default_allowance: "0.0"
                  max_carryover: "0.0"
                  accrue_type: "no_tracking"

  /leave-management/policies/{id}:
    x-summary: Time off policy
    get:
      summary: Details about a time off policy
      tags:
        - Leave management
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the policy to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 1
                  name: "Vacation"
                  color: "#3a7dd8"
                  do_not_accrue: false
                  unit: "days"
                  default_allowance: "25.0"
                  max_carryover: "100.0"
                  accrue_type: "yearly"
                  enable_employee_access: true
                  only_full_days: false
                  enable_probation_period: false
                  dont_allow_negative_amount: false
                  requests_in_advance_required: false
                  enable_minimum_days: false
                  enable_limited_days: false
                  enable_dependent_policy": false
                  blocks_enabled: false
                  no_reset: false
                  termination_recalculation: true
                  enable_service_accruals: false
                  child_allowance_enabled: false
                  enable_negative_carryover: false
                  max_accrual: false
                  accrue_at_start: true
                  enable_monthly_expiration: false
                  starter_monthly_accrual_limitation: false
                  starter_yearly_accrual_limitation: false
                  auto_approves: false
                  enable_specific_approvers: false
                  override_approvers_enabled: false
                  enable_duplicate_time_offs: false
                  enable_replacement: false
                  replacement_required: false
                  enable_scopped_replacement: false
                  enable_replacement_away: false
                  enable_details: true
                  require_details: false
                  additional_field: true
                  enable_attachment: false
    patch:
      summary: Update KIT days configuration of a time off policy
      tags:
        - Leave management
        - Kit Days
      consumes:
        - application/x-www-form-urlencoded        
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the policy to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - in: formData
          name: kit_days_enabled
          type: boolean
          required: true
          enum: [true, false]
          x-example: true
          description: "Whether the policy allows Kit days or not"
        - in: formData
          name: kit_days_quantity
          type: integer
          required: true
          x-example: 5
          description: "Maximum number of Kit days allowed in the policy"                  
      responses:
        '200':
          description: Successful Response
        '422':
          description: Unprocessable entity
          examples:
            application/json:
              error_code: invalid_policy_type
              errors: ['The policy specified is not an event-based policy']          

  /leave-management/kit-days:
    x-summary: KIT days
    get:
      summary: View all the KIT days of an employee in a policy
      tags:
        - Leave management
        - KIT days
        - Policies
      parameters:
        - in: header
          name: X-Auth-Token
          description: an authorization header
          required: true
          type: string
        - in: query
          name: policy_id
          type: integer
          required: true
          description: "Time-off policy identifier"
          x-example: 1
        - in: query
          name: employee_id
          type: integer
          required: true
          description: "Employee identifier"
          x-example: 2
      responses:
        '200':
          description: Successful Response
          examples:            
            application/json:
              data:
                - id: 1
                  status: "declined"
                  start_date: "2021-03-09"
                  end_date: "2021-03-10"
                - id: 2
                  status: "approved"
                  start_date: "2021-03-09"
                  end_date: "2021-03-10"
    post:
      summary: Create a KIT day in a leave
      tags:
        - Leave management
        - KIT days
        - Policies
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: header
          name: X-Auth-Token
          description: an authorization header
          required: true
          type: string
        - in: formData
          name: policy_id
          type: integer
          required: true
          description: "Time-off policy identifier"
        - in: formData
          name: employee_id
          type: integer
          required: true
          description: "Employee identifier"
        - in: formData
          name: date
          required: false
          description: "Date of single-day KIT day"
          type: string
          x-example: '2020-01-01'
        - in: formData
          name: date_from
          required: false
          description: "Start date of a multi-day KIT day"
          type: string
          x-example: '2020-01-01'
        - in: formData
          name: date_to
          required: false
          description: "End date of a multi-day KIT day"
          type: string
          x-example: '2020-01-01'
      responses:
        '200':
          description: Successful Response
          examples:            
            application/json:
              data:
                - id: 1
        '422':
          description: Unprocessable entity
          examples:
            application/json:
              error_code: validation_failed
              errors: ['First error', 'Second error']                

  /leave-management/kit-days/{id}:
    x-summary: KIT days
    patch:
      summary: Approve, decline or cancel a KIT day
      tags:
        - Leave management
        - KIT days
        - Policies
      consumes:
        - application/x-www-form-urlencoded        
      parameters:
        - in: header
          name: X-Auth-Token
          description: an authorization header
          required: true
          type: string
        - in: path
          name: id
          type: integer
          required: true
          description: "KIT day identifier"
        - in: formData
          name: status
          type: string
          required: true
          description: "Action to apply to the specified KIT day"
          enum: [cancel, approve, decline]
      responses:
        '200':
          description: Successful Response

  /leave-management/reports/individual-allowances:
    x-summary: Individual Allowances
    get:
      summary: Report with individual allowances
      tags:
        - Leave management
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: per_page
          in: query
          type: integer
          x-example: 25
        - name: location_ids
          in: query
          type: array
          items:
            type: integer
          x-example: [14, 13]
          description: "Limit the reports to employees in specified location ids"
        - name: employee_ids
          in: query
          type: array
          items:
            type: integer
          x-example: [1, 2, 3]
          description: "Limit the reports to selected employee ids"
        - name: team_ids
          in: query
          type: array
          items:
            type: integer
          x-example: [1]
          description: "Limit the reports to employees in specified team ids"
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - full_name: Joe Doe
                  id: 11
                  eligibilities:
                    - policy:
                        name: Sickday
                        id: 2
                      quantity: '0.0'
                      unit: days
                      carryover: '0.0'
                    - policy:
                        name: Vacation
                        id: 1
                      quantity: '25.0'
                      unit: days
                      carryover: '100.0'
                - full_name: Jane Doe
                  id: 13
                  eligibilities:
                    - policy:
                        name: Custom Policy
                        id: 4
                      quantity: '0.0'
                      unit: days
                      carryover: '0.0'
                    - policy:
                        name: Vacation
                        id: 1
                      quantity: '25.0'
                      unit: days
                      carryover: '100.0'
              meta:
                current_page: 1
                next_page: null
                previous_page: null
                total_pages: 1
                per_page: 25
                total_entries: 1

  /employees/{id}/leave-management/balances:
    x-summary: Employee time off balances
    get:
      summary: Employee time off balances
      tags:
        - Leave management
        - Employee
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - policy_id: 1
                  used: 5.6
                  available: 2
                - policy_id: 2
                  used: 75
                  available: null

  /leave-management/requests:
    x-summary: Time off requests
    get:
      summary: List time off requests
      tags:
        - Leave management
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: from
          in: query
          type: string
          x-example: "2018-05-20"
          description: "If not specified defaults to beginning of current month"
        - name: to
          in: query
          type: string
          x-example: "2018-06-20"
          description: "If not specified defaults to end of current month. Days between from date and to date must be less than 65. If you need info for larger period of time make multiple requests;"
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 2902504
                  status: Approved
                  status_code: approved
                  policy_id: 1
                  employee_id: 1
                  replacement: {
                    id: 2,
                    full_name: 'John Doe'
                  }
                  details: Birthday lunch
                  is_multi_date: false
                  is_single_day: true
                  is_part_of_day: true
                  first_part_of_day: false
                  second_part_of_day: true
                  start_date: "2018-05-24"
                  end_date: "2018-05-24"
                  request_date: "2018-05-22"
                  approval_date: null
                  hours: 3.5
                  fields:
                    - title: Approved by manager?
                      answer: 'yes'
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75
    post:
      summary: Create new time off request
      tags:
        - Leave management
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: formData
          name: type
          type: string
          required: true
          enum: [single, multi]
        - in: formData
          name: time_off_policy_id
          type: integer
          required: true
        - in: formData
          name: employee_id
          type: integer
          required: true
        - in: formData
          name: replacement_id
          type: integer
        - in: formData
          name: date
          type: string
          description: "format: YYYY-MM-DD; required if type is single"
        - in: formData
          name: date_from
          type: string
          description: "format: YYYY-MM-DD; required if type is multi"
        - in: formData
          name: date_to
          type: string
          description: "format: YYYY-MM-DD; required if type is multi"
        - in: formData
          name: part_of_day
          type: string
          required: true
          enum: [all_day, first_part_of_day, second_part_of_day, specific_timespan]
          description: "required if type is single"
        - in: formData
          name: hours
          type: number
          description: "required if type is single & part_of_day is first_part_of_day or second_part_of_day"
        - in: formData
          name: time_from
          type: string
          x-example: "07:30"
          description: "format: H:M; required if part_of_day is specific_timespan"
        - in: formData
          name: time_to
          type: string
          x-example: "15:00"
          description: "format: H:M; required if part_of_day is specific_timespan"
        - in: formData
          name: details
          type: string
          description: "required based on policy settings"
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1
        '422':
          description: Validation Failed Response
          examples:
            application/json:
              error_code: validation_failed
              errors:
                - Error message

  /leave-management/out-of-office-today:
    x-summary: Out of office today
    get:
      summary: List employees out of office today
      tags:
        - Leave management
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: date
          in: query
          type: string
          x-example: "2018-11-23"
          description: "Optional date, defauls to today"
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 2902504
                  policy_id: 2
                  policy:
                    name: Vacation
                  employee_id: 5
                  employee:
                    first_name: John
                    last_name: Doe
                  details: Birthday lunch
                  is_multi_date: false
                  is_single_day: true
                  is_part_of_day: true
                  first_part_of_day: false
                  second_part_of_day: true
                  start_date: "2018-05-24"
                  end_date: "2018-05-24"
                  hours: 3.5

  /documents/categories:
    x-summary: Document categories
    get:
      summary: List document categories
      tags:
        - Documents
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 1
                  name: General
                  documents_count: 10
                - id: 2
                  name: Job contracts
                  documents_count: 1

  /documents:
    x-summary: Documents
    get:
      summary: List Documents
      description: View all documents for company
      tags:
        - Documents
      parameters:
        - in: query
          name: category_id
          type: integer
          required: false
          description: Optional ID of the document category to filter by.  
        - in: query
          name: employee_id
          type: integer
          required: false
          description: Optional id of employee to filter documents.
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 18
                  document_category_id: 15
                  description: ''
                  company_id: 5
                  file_name: 'test_pdf.pdf'
                  file_content_type: 'application/pdf'
                  file_size: 6193
                  file_updated_at: '2021-06-09T07:32:16.562-07:00'
                  shared_with_team_manager: true
                  shared_with_direct_manager: false
                  created_by: 5
                  source: 'web'
                  created_at: '2021-06-09T14:32:20Z'
                  updated_at: '2021-06-09T14:32:20Z'
                  shared_with_everyone: false
                  last_edited_by: 5
                  document_template_pattern_id: null
                  acceptance_required: false
                  acceptance_deadline: null
                  file_scan_started_at: null
                  file_scan_result: 'Pass'
                  document_type: ''
                  document_type_other: ''
                  right_to_work_number: ''
                  expiration_date: null
                  document_expires: false
                - id: 19
                  document_category_id: 15
                  description: ''
                  company_id: 5
                  file_name: 'test_pdf2.pdf'
                  file_content_type: 'application/pdf'
                  file_size: 6193
                  file_updated_at: '2021-06-09T07:59:56.762-07:00'
                  shared_with_managers: true
                  created_by: 5
                  source: 'web'
                  created_at: '2021-06-09T15:00:20Z'
                  updated_at: '2021-06-09T15:00:20Z'
                  shared_with_direct_manager: false
                  shared_with_team_manager: true
                  last_edited_by: 5
                  document_template_pattern_id: null
                  acceptance_required: false
                  acceptance_deadline: null
                  file_scan_started_at: null
                  file_scan_result: 'Pass'
                  document_type: ''
                  document_type_other: ''
                  right_to_work_number: ''
                  expiration_date: null
                  document_expires: false
    post:
      summary: Create new document
      description: Document will only be visible to employee themselves
      tags:
        - Documents
      consumes:
        - multipart/form-data
      parameters:
        - in: formData
          name: file
          type: file
          required: true
          description: The file to upload.
        - in: formData
          name: employee_id
          type: integer
          required: true
          description: Employee Identifier; also accepts and array of integers to share with multiple employees
        - in: formData
          name: category_id
          type: integer
          required: false
          description: Category identifier, leave empty for default category
        - in: formData
          name: description
          type: string
          required: false
          description: Document description
        - in: formData
          name: notify
          type: string
          required: false
          description: "'true' to notify employee by email"
        - in: formData
          name: source
          type: string
          required: false
          description: "API"  
        - in: formData
          name: shared_with_everyone
          type: string
          required: false
          description: "'true' to share with all employees"
        - in: formData
          name: shared_with_team_manager
          type: string
          required: false
          description: "'true' to share with all team manager"
        - in: formData
          name: shared_with_direct_manager
          type: string
          required: false
          description: "'true' to share with all direct manager"
        - in: formData
          name: status
          type: string
          required: false
          enum: [empty, valid, expired]
        - in: formData
          name: right_to_work_document_type
          type: string
          required: false
          enum: ['residence_card', 'national_id', 'passport', 'other']
        - in: formData
          name: right_to_work_document_number
          type: string
          required: false
        - in: formData
          name: expires
          type: string
          required: false
          description: "if 'true' expiration_date is also required"
        - in: formData
          name: expiration_date
          type: string
          required: false
          description: "2022-06-01"
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1
                
  
  /documents/{id}:
    x-summary: Document
    get:
      summary: View Document
      description: View Document Details
      tags:
        - Documents
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: ID of document
      responses:
        '200':
          description: Succesful Response
          examples: 
            application/json:
              data:
                id: 18
                document_category_id: 15
                description: ''
                company_id: 5
                file_name: 'test_pdf.pdf'
                file_content_type: 'application/pdf'
                file_size: 6193
                file_updated_at: '2021-06-09T07:32:16.562-07:00'
                shared_with_direct_manager: false
                shared_with_team_manager: true
                created_by: 5
                source: 'web'
                created_at: '2021-06-09T14:32:20Z'
                updated_at: '2021-06-09T14:32:20Z'
                shared_with_everyone: false
                last_edited_by: 5
                document_template_pattern_id: null
                acceptance_required: false
                acceptance_deadline: null
                file_scan_started_at: null
                file_scan_result: 'Pass'
                document_type: ''
                document_type_other: ''
                right_to_work_number: ''
                expiration_date: null
                document_expires: false
    delete:
      summary: Delete a document
      description: Allows admin to delete document
      tags:
        - Documents
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: ID of document to be deleted
      responses:
        '200':
          description: Succesful Response
          examples: 
            application/json:
              data:
                id: 1
    put:
      summary: Update a document
      description: Document will only be visible to employee themselves
      tags:
        - Documents
      consumes:
        - multipart/form-data
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: ID of document to be updated
        - in: formData
          name: file
          type: file
          required: true
          description: The file to upload.
        - in: formData
          name: employee_id
          type: integer
          description: Can also accept and array of integers to share with multiple employees
          required: true
        - in: formData
          name: category_id
          type: integer
          required: false
          description: Category identifier, leave empty for default category
        - in: formData
          name: description
          type: string
          required: false
          description: Document description
        - in: formData
          name: notify
          type: string
          required: false
          description: "'true' to notify employee by email"
        - in: formData
          name: source
          type: string
          required: false
          description: "API"  
        - in: formData
          name: shared_with_everyone
          type: string
          required: false
          description: "'true' to share with all employees"
        - in: formData
          name: shared_with_team_manager
          type: string
          required: false
          description: "'true' to share with all team manager"
        - in: formData
          name: shared_with_direct_manager
          type: string
          required: false
          description: "'true' to share with all direct manager"
        - in: formData
          name: status
          type: string
          required: false
          enum: [empty, valid, expired]
        - in: formData
          name: right_to_work_document_type
          type: string
          required: false
          enum: ['residence_card', 'national_id', 'passport', 'other']
        - in: formData
          name: right_to_work_document_number
          type: string
          required: false
        - in: formData
          name: expires
          type: string
          required: false
          description: "if 'true' expiration_date is also required"
        - in: formData
          name: expiration_date
          type: string
          required: false
          description: "2022-06-01"  
      responses:
        '202':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1            
              

  /positions:
    x-summary: Positions
    get:
      summary: List positions in company
      tags:
        - Positions
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 19
                  title: "CFO"
                  description: "..."
                  code: "X2"
                - id: 20
                  title: "CEO"
                  description: null
                  code: null
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75

  /teams:
    x-summary: Teams
    get:
      summary: List teams in company
      tags:
        - Teams
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 19
                  name: "Sales"
                  manager_ids:
                    - 1
                    - 2
                  employee_ids:
                    - 5
                    - 7
                    - 90
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75

  /performance/goals/quarterly-progress/overall:
    x-summary: Overview of quarterly goal progress
    get:
      summary: Overview of quarterly goal progress
      tags:
        - Performance
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                company:
                  adjusted: 18
                  actual: 15
                individual:
                  adjusted: 31
                  actual: 26
                team:
                  adjusted: 42
                  actual: 37

  /performance/goals/quarterly-progress/company-goals:
    x-summary: Quarterly company goals
    get:
      summary: Quarterly company goals
      tags:
        - Performance
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - title: Optimize data storage
                  progress:
                    actual: 10
                    to_date: 34

  /performance/goals/quarterly-progress/team-goals:
    x-summary: Quarterly team goals
    get:
      summary: Quarterly team goals
      tags:
        - Performance
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - name: HR team
                  progress:
                    actual: 10
                    to_date: 34
                  goals:
                    - title: Optimize data storage
                      progress:
                        actual: 10
                        to_date: 34

  /performance/goals/quarterly-progress/individual-goals:
    x-summary: Quarterly individual goals
    get:
      summary: Quarterly individual goals
      tags:
        - Performance
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - name: John Doe
                  progress:
                    actual: 10
                    to_date: 34
                  goals:
                    - title: Optimize data storage
                      progress:
                        actual: 10
                        to_date: 34

  /employees/{id}/compensations:
    x-summary: Compensation
    get:
      summary: Employee compensations
      tags:
        - Employee
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of the user to get.
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - start_date: "2017-01-01"
                  end_date: "2019-01-01"
                  currency: EUR
                  amount: 1234
                  period: monthly
                  comment: Starting salary
                  category: Salary
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75

  /recruitment/positions:
    x-summary: Positions
    get:
      summary: List recruitment positions
      description: >
        Posible recruitment position statuses: `draft`, `published`, `internal`, `completed`, `cancelled`
      tags:
        - Recruitment
      parameters:
        - name: status
          in: query
          type: string
          x-example: 'completed'
          description: |
            Filter by status, see list of possible statuses
            `?status=open`
        - name: hiring_manager_ids
          description: |
            Filter by hiring manager id, can appear multiple times
            `hiring_manager_ids[]=251&hiring_manager_ids[]=121`
          x-example: 
            - '251'
            - '121'
          in: query
          type: array
          items: 
            type: string             
        - name: group_ids
          description: |
            Filter by group id, can appear multiple times
            `group_ids[]=27&group_ids[]=761`
          x-example: 
            - '27'
            - '761'
          in: query
          type: array
          items: 
            type: string            
        - name: location_ids
          description: |
            Filter by location id, can appear multiple times
            `location_ids[]=1&location_ids[]=12`
          x-example: 
            - '1'
            - '12'
          in: query
          type: array
          items: 
            type: string
        - name: page
          description: "Pagination: fetch page at given offset"
          in: query
          type: integer
          x-example: 2
        - name: per_page
          description: |
            Pagination: amount of positions to return in 1 call, default: 30, max: 100
          in: query
          type: integer
          x-example: 25
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 2902504
                  title: CEO
                  status: published
                  visibility: Published
                  created_at: "2019-09-01"
                  internal_date: "2019-10-01"
                  completed_at: null
                  link: "https://talent.sage.hr/jobs/xxx"
                  team: "Management"
                  applicants_required: 1
                  applicants_count: 3
                  employment_type: "Full-time"
                  location: "London"
                  location_id: 9182712
                  group: "Hiring Group"
                  group_id: 871621
                  priority: 1
                  description_blocks:
                    - title: Requirements
                      content: "Html content goes here"
                - id: 212
                  title: CFO
                  status: completed
                  visibility: Completed
                  created_at: "2019-09-01"
                  internal_date: "2019-10-21"
                  completed_at: "2019-10-12"
                  link: null
                  team: ""
                  applicants_required: 2
                  applicants_count: 4
                  employment_type: null
                  location: null
                  location_id: null
                  group: "Hiring Group"
                  group_id: 871621
                  priority: 9800
                  description_blocks: 
                    - title: Description
                      content: "<p>This is a CFO position.</p>"
                    - title: Requirements
                      content: '<p>Be a CFO</p>'
                    - title: Benefits
                      content: "<p>iPhone 12</p>"                  
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 20
                total_entries: 34

  /recruitment/positions/{id}:
    x-summary: Position details
    get:
      summary: Position details
      tags:
        - Recruitment
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of position
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1
                title: CTO
                status: completed
                visibility: Completed
                created_at: '2020-10-15'
                internal_date: '2020-10-31'
                completed_at: '2020-10-28'
                link: null
                team: ''
                applicants_required: 1
                applicants_count: 2
                employment_type: Full-time
                location: "New York"
                location_id: 4
                group: Hiring Group
                group_id: 1
                priority: 1
                description_blocks:
                - title: Description
                  content: "<h1>This Is A CTO Position</h1>"
                - title: Requirements
                  content: "<p>This is what we required.</p>"
                - title: Benefits
                  content: "<p>Here are some benefits.</p>"
                - title: More Details
                  content: "<p>A custom block.</p>"
                applicants:
                - id: 1
                  full_name: Jon Vondrak
                  email: jon.vondrak@example.com
                - id: 2
                  full_name: Samantha Cross
                  email: sam.cross@example.com
                hiring_team:
                - id: 12
                  full_name: Manel Lopez-Bru
                  role: hiring_manager
                - id: 1
                  full_name: Pau Capdevilla
                  role: interviewer

  /recruitment/positions/{id}/applicants:
    x-summary: Applicants
    get: 
      summary: List applicants
      tags:
        - Recruitment
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of position
        - name: stage_id
          in: query
          type: integer
          x-example: 25
          description: Optional filter by stage e.g. `?stage_id=25`
        - name: page
          description: "Pagination: fetch page at given offset, default 1"
          in: query
          type: integer
          x-example: 2
        - name: per_page
          description: |
            Pagination: amount of applicants to return in 1 call, default: 30, max: 100
          in: query
          type: integer
          x-example: 25          
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
              - id: 1
                full_name: Jon Vondrak
                first_name: Jon
                last_name: Vondrak
                email: jon.vondrak@example.com
                address: 
                summary: 
                phone_number: 
                source: recruiters
                created_at: '2020-10-15T10:58:57Z'
                disqualified_date: 
                hired_date: 
                stage:
                  id: 6
                  title: Reference check
                  created_at: '2020-10-15T10:57:34Z'
                tags: []  
                scores:
                - score: 0
                  author:
                    full_name: Jane Doe
                - score: 2
                  author:
                    full_name: John Doe
              - id: 2
                full_name: Samantha Cross
                first_name: Samantha
                last_name: Cross
                email: sam.cross@example.com
                address: 
                summary: 
                phone_number: 
                source: recruiters
                created_at: '2020-10-15T11:02:34Z'
                disqualified_date: 
                hired_date: '2020-10-28'
                stage:
                  id: 10
                  title: Hired
                  created_at: '2020-10-15T10:57:34Z'
                tags: ["php", "ruby"]  
                scores:
                - score: 0
                  author:
                    full_name: Jane Doe
                - score: 2
                  author:
                    full_name: John Doe
              meta:
                current_page: 1
                next_page: 
                previous_page: 
                total_pages: 1
                per_page: 30
                total_entries: 3

    post:
      summary: Create new applicant
      description: |
        Tracking applicant's source:
         * if left blank, source will be automatically set to `api`
         * set source to a special keyword (`company_marketing`, `recruiters`, `referral`, `sourced`) to have it mapped to corresponding values 
         * set source to a desired reference to create a custom source, e.g. `source=linkedin` will create a custom source called linkedin if it does not exist already
         * passing a referral object as a parameter will set the source to `referral`
         
        Example of creating an applicant with a refferal object:
        ```
        curl -X POST -H 'X-AUTH-TOKEN:***' -H 'Content-Type:application/json' \
          "https://***/api/recruitment/positions/2/applicants" \
          -d '{"applicant": \
                  {"referral": {"email": "recruitment@example.com", "full_name": "Alice L"}, \
                   "address": "BD23 8UL", "summary":"An applicant", \
                   "first_name": "Applicant Name"}}'
        ```
      tags:
        - Recruitment
      consumes:
        - multipart/form-data
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of position (must not be closed or completed).
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - in: formData
          name: send_thank_you_email
          type: string
          required: false
          description: "'true' to send thank you email to applicant"
        - in: formData
          name: applicant[first_name]
          type: string
          required: true
        - in: formData
          name: applicant[last_name]
          type: string
          required: false
        - in: formData
          name: applicant[email]
          type: string
          required: false
        - in: formData
          name: applicant[referral]
          type: string
          required: false
        - in: formData
          name: applicant[phone_number]
          type: string
          required: false
        - in: formData
          name: applicant[source]
          type: string
          required: false
        - in: formData
          name: applicant[address]
          type: string
          required: false
        - in: formData
          name: applicant[summary]
          type: string
          required: false
        - in: formData
          name: applicant[attachment]
          type: file
          required: false
          description: The file to upload.
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1
        '422':
          description: Validation
          examples:
            application/json:
              error_code: validation_failed
              errors:
                - Email has already been taken

  /recruitment/applicants/{id}:
    x-summary: Applicant details
    get: 
      summary: Applicant details
      tags:
        - Recruitment
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of applicant
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 3
                full_name: Fritzgerard Stachie
                first_name: Fritzgerard
                last_name: Stachie
                email: fritzgerard@example.com
                address: 
                summary: 
                phone_number: 
                source: referral
                created_at: '2020-10-21T12:58:43Z'
                disqualified_date: '2020-10-28'
                hired_date: 
                stage:
                  id: 4
                  title: Interview
                  created_at: '2020-10-15T10:57:34Z'
                position_id: 1
                added_by:
                  id: 1
                  full_name: Vlad Hendrik
                  email: vlad@example.com
                referrer:
                  id: 1
                  full_name: Josh Pascuale
                  email: josh@example.com
                  phone_number: 67876162
                tags: ["php", "ruby"]
                scores:
                - score: 0
                  author:
                    full_name: Jane Doe
        '422':
          description: Unsuccessful response
          examples:
            application/json:
              error_code: validation_failed
              errors:
              - Email has already been taken
                  
  /recruitment/applicants/{id}/actions:
    x-summary: Applicant actions
    get: 
      summary: Applicant actions
      description: >
        List applicant's process throught the recruitment pipeline.
        Newest, first.
      tags:
        - Recruitment
      parameters:
        - in: path
          name: id
          type: integer
          required: true
          description: Numeric ID of applicant
        - name: page
          description: "Pagination: fetch page at given offset"
          in: query
          type: integer
          x-example: 2
        - name: per_page
          description: |
            Pagination: amount of actions to return in 1 call, default: 30, max: 100
          in: query
          type: integer
          x-example: 25          
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
              - action: moved_between_stages
                message: Applicant moved from "Interview" to "Reference check"
                created_at: '2020-10-28T09:05:45Z'
              - action: moved_between_stages
                message: Applicant moved from "CV review" to "Interview"
                created_at: '2020-10-27T10:59:23Z'
              - action: moved_between_stages
                message: Applicant moved from "New" to "CV review"
                created_at: '2020-10-15T11:01:39Z'
              - action: document_created
                message: Uploaded "empty-document.pdf"
                created_at: '2020-10-15T10:59:15Z'
              - action: applicant_created
                message: Applicant created
                created_at: '2020-10-15T10:58:57Z'
              meta:
                current_page: 1
                next_page: 
                previous_page: 
                total_pages: 1
                per_page: 30
                total_entries: 5
               
  /timesheets/clock-in:
    x-summary: Time clocking
    post:
      summary: Clock in & out employees on specific days
      description: Employees will be only clocked in & out if API time clocking is enabled for Timesheet group
      tags:
        - Timesheets
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: parameters
          in: body
          required: true
          description: Times on specific dates for specific employees as json
          schema:
            type: object
            properties:
              override:
                type: string
                description: "'true' if override provided days clocked entries"
              clocked_time:
                type: object
                properties:
                  'YYYY/MM/DD':
                    type: object
                    properties:
                      employee_id:
                        type: array
                        items:
                          type: object
                          properties:
                            clock_in:
                              type: string
                              description: 'YYYY/MM/DD HH:MM'
                            clock_out:
                              type: string
                              description: 'YYYY/MM/DD HH:MM'

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']

  /timesheets/projects:
    x-summary: Create project
    post:
      summary: Create project
      description: Create a project
      tags:
        - Projects
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: parameters
          in: body
          required: true
          description: Code should be uniq or empty
          schema:
            type: object
            properties:
              projects:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      description: "name of the project"
                    code:
                      type: string
                      description: "code of the project"
                    start_date:
                      type: string
                      description: "start date"
                    end_date:
                      type: string
                      description: "end date"
                    limit_total_hours:
                      type: boolean
                      description: "activate the limit of hours"
                    max_limit_total_hours:
                      type: integer
                      description: "the limit number of hours"

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']

  /timesheets/projects/:
    x-summary: Projects
    get:
      summary: Get projects
      description: Get projects
      tags:
        - Projects
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']
    patch:
      summary: Update project
      description: Update a project
      tags:
        - Projects
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: parameters
          in: body
          required: true
          description: Code should be uniq or empty
          schema:
            type: object
            properties:
              projects:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      description: "id of the project"
                    name:
                      type: string
                      description: "name of the project"
                    code:
                      type: string
                      description: "code of the project"
                    start_date:
                      type: string
                      description: "start date"
                    end_date:
                      type: string
                      description: "end date"
                    limit_total_hours:
                      type: boolean
                      description: "activate the limit of hours"
                    max_limit_total_hours:
                      type: integer
                      description: "the limit numbers of hours"

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']


  /timesheets/working_packages:
    x-summary: Get working packages
    get:
      summary: Get working packages
      description: Get working packages
      tags:
        - Working Packages
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: project_id
          in: query
          required: true
          description: Code should be uniq or empty
          type: integer

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']

  /timesheets/working_packages/:
    x-summary: Create working packages
    post:
      summary: Create working packages
      description: Create a working packages
      tags:
        - Working Packages
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: parameters
          in: body
          required: true
          description: Code should be uniq or empty
          schema:
            type: object
            properties:
              project_id:
                type: string
              working_packages:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      description: "name of the working package"
                    code:
                      type: string
                      description: "code of the working package"
                    start_date:
                      type: string
                      description: "start date"
                    end_date:
                      type: string
                      description: "end date"

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']

  /timesheets/workdays/:
    x-summary: Get workdays
    get:
      summary: Get workdays
      description: Get workdays
      tags:
        - Workdays
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: employe_id
          in: query
          required: true
          description: Employee id
          type: integer
        - name: from
          in: query
          required: true
          description: From date
          type: string
        - name: to
          in: query
          required: true
          description: To date
          type: string

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']
              
  /timesheets/workdays:
    x-summary: Create a Workday
    post:
      summary: Create a Workday
      description: Create a Workday
      tags:
        - Workdays
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: employee_id
          in: formData
          type: integer
          required: true
          description: Id of employee
        - name: date
          in: formData
          type: string
          required: true
          description: Day
        - name: from
          in: formData
          type: integer
          required: true
          description: Starting time, in seconds
        - name: to
          in: formData
          type: integer
          required: true
          description: Ending time, in seconds
        - name: break_start
          in: formData
          type: integer
          description: Break starting time, in seconds
        - name: break_end
          in: formData
          type: integer
          description: Break ending time, in seconds
        - name: break_length
          in: formData
          type: integer
          description: Break duration
      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 192
                  from: 32400
                  to: 46800
                  break_start: 0
                  break_end: 0
                  break_length: 0
                  employee_id: 601
                  date: "2021-12-20"
        401:
          description: Unauthorized
          examples:
            application/json:
              error_code: validation_failed
              errors: ["Company uses clock in"]
        422:
          description: Unprocessable entity
          examples:
            application/json:
              error_code: validation_failed
              errors: ["Break time not enabled"]
          
  /timesheets/projects/{project_id}/close:
    x-summary: Close project
    delete:
      summary: Close project
      description: Close project
      tags:
        - Project
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: project_id
          in: path
          required: true
          description: Code should be uniq or empty
          type: integer

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']

  /timesheets/working_packages/{project_id}/close:
    x-summary: Close working packages
    delete:
      summary: Close working packages
      description: Close working packages
      tags:
        - Project
      parameters:
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
        - name: project_id
          in: path
          required: true
          description: Code should be uniq or empty
          type: integer
        - name: parameters
          in: body
          description: working packages ids
          schema:
            type: object
            properties:
              working_package_ids:
                type: array
                items:
                  type: integer
                  example: 1

      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              errors: ['error 1', 'error 2']

  /termination-reasons:
    x-summary: Termination reasons
    get:
      summary: List termination reasons in company
      tags:
        - Terminations reasons
      parameters:
        - name: page
          in: query
          type: integer
          x-example: 2
        - name: X-Auth-Token
          in: header
          description: an authorization header
          required: true
          type: string
      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 19
                  name: "New job"
                  code: 'NJ'
                  type: 'voluntary'
                - id: 20
                  name: "End of Internship"
                  code: null
                  type: 'involuntary'
              meta:
                current_page: 1
                next_page: 2
                previous_page:
                total_pages: 2
                per_page: 50
                total_entries: 75

  /onboarding/categories:
    x-summary: Onboarding task categories
    get:
      summary: List onboarding task categories
      tags:
        - Onboarding
      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 1
                  title: General
                - id: 2
                  title: Platform

  /onboarding/tasks:
    x-summary: Onboarding task
    post:
      summary: Create new onboarding task
      tags:
        - Onboarding
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: formData
          name: title
          type: string
          required: true
        - in: formData
          name: boarding_task_template_category_id
          type: number
          required: true
        - in: formData
          name: due_in
          type: number
          required: true
          description: "Due date in days after employee start date"
          'x-example': 30
        - in: formData
          name: description
          type: string
          required: false
        - in: formData
          name: default_assignee_type
          type: string
          required: false
          enum: [self, leader, employee]
          description: "Default: self; leader - direct manager; employee - specific employee via assignee_id"
        - in: formData
          name: assignee_id
          type: number
          required: false
          description: "Specific assignee if default_assignee_type is 'employee'"
        - in: formData
          name: require_attachment
          type: string
          required: false
          description: "'true' to enabled required attachment"
        - in: formData
          name: add_after
          type: number
          required: false
          description: "Task start date in days after employee start date"
          'x-example': 0
      responses:
        201:
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1

  /offboarding/categories:
    x-summary: Offboarding task categories
    get:
      summary: List offboarding task categories
      tags:
        - Offboarding
      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              data:
                - id: 1
                  title: General
                - id: 2
                  title: Platform

  /offboarding/tasks:
    x-summary: Offboarding task
    post:
      summary: Create new offboarding task
      tags:
        - Offboarding
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: formData
          name: title
          type: string
          required: true
        - in: formData
          name: boarding_task_template_category_id
          type: number
          required: true
        - in: formData
          name: due_in
          type: number
          required: true
          description: "Due date in days before employee last working day"
          'x-example': 30
        - in: formData
          name: description
          type: string
          required: false
        - in: formData
          name: default_assignee_type
          type: string
          required: false
          enum: [self, leader, employee]
          description: "Default: self; leader - direct manager; employee - specific employee via assignee_id"
        - in: formData
          name: assignee_id
          type: number
          required: false
          description: "Specific assignee if default_assignee_type is 'employee'"
        - in: formData
          name: require_attachment
          type: string
          required: false
          description: "'true' to enabled required attachment"
      responses:
        '201':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1

  /vikarina/job-positions:
    x-summary: Vikarina job positions
    post:
      summary: Job position transfer from Sage HR to Vikarina
      tags:
        - Integrations
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                id: 1
                title: Job title
                status: 1

  /vikarina/organization-structure:
    x-summary: Vikarina organization data
    post:
      summary: Organizational structure transfer from Sage HR to Vikarina
      tags:
        - Integrations
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                department_code: department code (custom_field)
                department_name: department name (custom_field)
                section_code: section code (custom_field)
                section_title: section title (custom_field)
                subsection_code: subsection code (custom_field)
                subsection_title: Test Team
                cost_center_code: cost center code (custom_field)
                cost_center_title: cost center tile (custom_field)
                work_address: employee address (custom_field)
                work_city: employee city (custom_field)
                status: 1

  /vikarina/newstarter-employees:
    x-summary: Vikarina new employees
    post:
      summary: New starters list from Sage HR to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                work_start_date: 2020-10-10
                first_name: John
                last_name: Doe
                gender: male
                personal_code: personal code (custom_field)
                social_security_code: social security code (custom_field)
                address: Street 1, City
                home_city: employee home city (custom_field)
                country_id: country id (GB)
                npd: NPD
                email: test@test.com
                status: 1

  /vikarina/contract-information:
    x-summary: Vikarina employee contracts
    post:
      summary: Contract (custom field) information transfer from Sage HR to Vikarina
      tags:
        - Integrations
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                work_start_date: 2020-10-10
                contract_number: contract number (custom_field)
                termination_date: 2020-10-11
                employment_status: Full-time
                contract_type: contract type (custom_field)
                status: 1

  /vikarina/appointments:
    x-summary: Vikarina employees appointments
    post:
      summary: New appointment (position changes) information transfer from Sage HR to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                work_start_date: '2020-01-10'
                position_start_date: '2020-10-10'
                last_position_end_date: '2020-09-10'
                cost_center_code: cost center code (custom_field)
                position_id: 1
                schedule_id: scheduled id (custom_field)
                employment_status: Full-time
                job_type: job type (custom_field)
                status: 1

  /vikarina/salaries:
    x-summary: Vikarina employees salaries
    post:
      summary: Salary information transfer from Sage HR to Vikarina to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                compensation_id: 1
                employee_number: 123
                contract_number: contract number (custom_field)
                type: Salary
                start_date: '2020-09-10'
                end_date: '2020-10-10'
                amount: 1000
                status: 1

  /vikarina/bank-accounts:
    x-summary: Vikarina employees bank accounts
    post:
      summary: Bank account information transfer (Custom field) from Sage HR to Vikarina
      tags:
        - Integrations
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                bank_code: bank code (custom_field)
                bank_account: bank account (custom_field)
                last_change: '2020-09-10'
                status: 1

  /vikarina/terminated-employees:
    x-summary: Vikarina terminated employees
    post:
      summary: Termination information transfer from Sage HR to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                contract_number: contract number (custom_field)
                termination_date: '2020-09-10'
                termination_reason: New job
                unused_days: 5
                termination_comment: Was good employee
                compensation: 1000
                status: 1

  /vikarina/unused-days:
    x-summary: Vikarina employee unused days
    post:
      summary: Unused vacation days transfer from Sage HR to Vikarina
      tags:
        - Integrations
      responses:
        200:
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                unused_days: 5
                date: '2020-10-10'
                status: 1

  /vikarina/leave-types:
    x-summary: Vikarina employees time offs
    post:
      summary: Leaves information transfer from Sage HR to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                calendar_event_id: 1
                employee_number: 123
                leave_type: Vacation
                days: 2
                start_date: '2020-10-10'
                end_date: '2020-10-10'
                status: 1

  /vikarina/timesheets:
    x-summary: Vikarina employee timesheets
    post:
      summary: Time Schedule information transfer from Sage HR to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                employee_id: 1
                employee_number: 123
                date: '2020-10-10'
                stand_by: 8
                hours: 8.5
                nightours: 0.5
                cost_center_code: cost center code (custom field)
                overtime_title: 0.5
                status: 1

  /vikarina/bonuses:
    x-summary: Vikarina employees bonuses
    post:
      summary: Sending bonuses [payed once] to Vikarina
      tags:
        - Integrations
      parameters:
        - name: start_date
          in: query
          type: string
          x-example: '2020-01-01'
        - name: end_date
          in: query
          type: string
          x-example: '2020-02-01'
      responses:
        '200':
          description: Successful Response
          examples:
            application/json:
              data:
                compensation_id: 1
                employee_number: 123
                contract_number: contract number (custom_field)
                type: Bonus
                start_date: '2020-09-10'
                end_date: '2020-10-10'
                amount: 1000
                status: 1
                