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 |
|---|
Details
|
Request example
After analyzing the different fields, here is an example of the request body:
{
"employeeId": "00001",
"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
If a request already exists for the same employee, day and concept, the request replaces it instead of returning a duplicate error — hence the endpoint serves both to create and to update.
Error codes
In addition to the common errors, this endpoint can return the following codes:
| Code | Message | Description |
|---|---|---|
|
Employee id is mandatory |
The |
Status is mandatory |
The |
|
Type is mandatory |
The |
|
From date cannot be null |
The |
|
To date cannot be null |
The |
|
Request time range is invalid |
The |
|
Status must be one of REQUESTED, GRANTED or DENIED |
The |
|
Type must be one of MAYBE, MANDATORY, SHIFT or NON_WORKED |
The |
|
Non worked request cannot have fromHour or toHour |
The |
|
Shift request must have from and to hour |
The |
|
|
- |
The request body is not valid JSON or one of its fields does not have the expected format. |
error.request_out_of_service_association |
The request period does not match any of the employee’s current service associations. |
|
error.request_out_of_period |
The request falls outside the period editable by the current user. |
|
error.request_duplicated_concepts |
A request with the same concept already exists in that period. |
|
error.request_overlapped_concepts |
The request overlaps with another one of an incompatible concept. |
|
error.person_request_not_allowed_for_day_type |
The configured day type does not accept this type of request. |
|
error.person_request_weekly_limit_exceeded |
The weekly limit of requests of this type has been exceeded. |
Useful links
What is a request?