Create or update a request

This endpoint allows to update or create a request for an employee.

PUT /api/v1/businesses/{businessId}/requests

Below are the fields that make up the request body, some of which are mandatory for the request to be successful.

Mandatory fields are marked with an asterisk (*).

Request body

JSON Analysis
{
  "employeeId": "string",
  "status": "string",
  "type": "string",
  "from": "string",
  "to": "string",
  "fromHour": "string",
  "toHour": "string",
  "comments": "string",
  "recover": "string"
}
Details
  • employeeId*: identifier of the employee.

  • status*: status of the request. The accepted values are REQUESTED, GRANTED and DENIED.

  • type*: type of availability that applies to the request. The accepted values are MANDATORY, MAYBE and NON_WORKED.

  • from*: start date of the request in yyyy-MM-dd format.

  • to*: end date of the request in yyyy-MM-dd format.

  • fromHour: start time of the request in HH:mm format. Refers to local time, that is, the time zone of the service.

  • toHour: end time of the request in HH:mm format. Refers to local time, that is, the time zone of the service.

  • comments: reason or explanation for making the request.

  • recover: type of recovery indicating how the employee’s request could be compensated. The options are FREE (free day) or NONE.

Request example

After analyzing the different fields, here is an example of the request body:

{
  "employeeId": "1006349",
  "status": "REQUESTED",
  "type": "MAYBE",
  "from": "2024-07-25",
  "to": "2024-07-25",
  "fromHour": "10:00",
  "toHour": "12:00",
  "comments": "I could work at this time, depending on my other shifts.",
  "recover": "NONE"
}

If all data is correct, a request will be generated with the following characteristics:

  • Status: requested.

  • Day: July 25, 2024.

  • Availability from 10:00 to 12:00.

  • Worked? Maybe.

Additionally, the reason for making the request will be added.

Considerations

The NON_WORKED type does not accept the fromHour or toHour fields, as it is a request for a full day off. If data is sent for any of these fields, the request will return a 406 Not Acceptable error indicating Non worked request cannot have fromHour or toHour. However, the NON_WORKED request type is accepted if these fields are sent as null.

If the employee identifier is incorrect, the request will return a 404 Not Found error indicating Employee not found.

What is a request?