Update an incidence

This endpoint allows updating the information of a previously registered incidence for an employee.

PUT /api/v1/import/incidence

Below is a detailed explanation of each of the fields that can make up the request body, with some being mandatory for the request to be successful.

Mandatory fields are marked with an asterisk (*).

Request body

JSON Analysis
{
  "business": "string",
  "employeeId": "string",
  "type": "string",
  "initTime": "string",
  "endTime": "string",
  "workedMinutes": 0,
  "from": "string",
  "to": "string",
  "id": "string",
  "orquestId": 0
}
Details
  • business*: identifier configured in Orquest for the business.

  • employeeId*: identifier of the employee linked to the incidence.

  • type*: identifier of the incidence type. It must be previously configured in Orquest.

  • initTime: start time of the incidence. It must be in HH:mm format with the following regular expression: ^([01]\d|2[0-3]):[0-5]\d$. Refers to local time, that is, the time zone of the service.

  • endTime: end time of the incidence. It must be in HH:mm format with the following regular expression: ^([01]\d|2[0-3]):[0-5]\d$. Refers to local time, that is, the time zone of the service.

  • workedMinutes*: time, in minutes, that the incidence computes.

  • from*: date when the incidence starts. It must be in yyyy-MM-dd format.

  • to*: date when the incidence ends. It must be in yyyy-MM-dd format.

  • id: external identifier of the incidence.

  • orquestId: identifier of the incidence in Orquest.

Request example

Once the analysis of the different fields has been carried out, an example of the request body is shown:

{
  "business": "BUSINESSID",
  "employeeId": "C14A658",
  "type": "01",
  "initTime": "08:30",
  "endTime": "09:30",
  "workedMinutes": 30,
  "from": "2024-04-15",
  "to": "2024-04-15",
  "id": "C14-12545"
}

Considerations

This request will generate an atomic operation that can be automatically reverted if there are errors: the error will be displayed in the response of the request.

If the indicated id does not correspond to any existing incidence, this request will create it instead of returning a "not found" error.

If there are incidences of the employee within the range between from and to of the new incidence, all of them will be removed before registering the new one, not only the one that directly overlaps.

If the indicated employee identifier does not exist in the business, the request will return a 200 OK status, indicating the not_valid_person error in the response.

Error codes

In addition to the common errors, this endpoint can return the following codes:

Code Message Description

406 Not Acceptable

Business in incidence cannot be null

The business field is missing.

EmployeeId in incidence cannot be null

The employeeId field is missing.

Type in incidence cannot be null

The type field is missing.

Worked minutes cannot be null / Worked minutes should be positive or zero

The workedMinutes field is missing, or it has a negative value.

From in incidence cannot be null / To in incidence cannot be null

The from or to field is missing.

Init Time is invalid. Format should be: HH:mm / End Time is invalid. Format should be: HH:mm

The initTime or endTime field does not have the expected HH:mm format.

Incidence range is invalid

The range defined between from and to is not valid.

400 Bad Request

has_not_type

The incidence type indicated in type is not defined in the business’s incidence catalog.

error.incidence_overlapped

The incidence overlaps with another incidence previously registered in the system.

error.incidence_time_mandatory

The incidence type requires start and end times (initTime/endTime), which have not been provided.

validation.error.incidence_input_type_not_allowed

The indicated incidence type does not support being created through this request.

409 Conflict

-

A conflict occurred while saving the incidence. It is recommended to review that the data sent does not violate any integrity constraint.