Create appointments batch
Creates one appointment per intervention group in a single transaction. All created appointments share one service order: an explicit service_order number is validated and reused. Without a service_order, the service_order_creation agenda parameter decides what is created when customer_id and vehicle_plate are both present and the user holds oficinas:ordservico:new: none creates nothing, draft (the default) a replaceable draft order in status RAS, and issued a numbered service order in the service_order_initial_status agenda status, or without one in the status configured as initial, carrying the interventions with their minutes and extra description. Otherwise the appointments are created unlinked, which is not an error. A created order keeps the status it was created with. A rescheduled_from without a service_order carries on the order of the rescheduled appointment, as if it had been sent, unless that order is cancelled, belongs to another plate or is in a status that does not allow scheduling; the parameter then decides as for a new appointment. reception_date/delivery_date are written to the service order once per batch, never once per group, and meta.service_order_dates_synced reports the outcome. With the split_planning_enabled agenda parameter on and a plan confirmed after POST /workshop/appointments/plan, the plan is recalculated under a lock per mechanic and day and in the same transaction as the write: when it still matches, its segments are written as confirmed; when the space is no longer free, nothing is written and the response is 409 with the recalculated plan in data.appointments, in the plan endpoint format. A recalculation that hits a limit is rejected with 422 as the plan endpoint does. With the parameter off, plan is still validated but not used, and the appointment is written as requested, in one block. Each group is recalculated with its own allow_split when it carries one, else with plan.allow_split: send the same groups that were sent to the plan endpoint.
In: header
The plan confirmed after POST /workshop/appointments/plan. Always validated, but only used when the split_planning_enabled agenda parameter is on: allow_split (the option chosen; in the grouped body, of every group without its own allow_split), simultaneous (grouped body) and appointments, the data.appointments of the plan response echoed back, one per appointment and in the same order. The plan is recalculated under a lock per mechanic and day; when it no longer matches, nothing is written and the response is 409 with the recalculated plan.
Empty Object
Valid value from relcontacto.numrel.
Response Body
curl -X POST "https://og-tenant1.test:8003/api/v2/workshop/appointments/batch" \
-H "Content-Type: application/json" \
-d '{
"subject": "string"
}'{
"data": {
"service_order": {
"number": 0,
"document_number": "string"
},
"appointments": [
{}
]
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
},
"appointments": [
{
"start": "2019-08-24T14:15:22Z",
"end": "2019-08-24T14:15:22Z",
"allow_split": true,
"segments": [
{
"start": "2019-08-24T14:15:22Z",
"end": "2019-08-24T14:15:22Z",
"interventions": [
{
"intervention_id": 0,
"minutes": 0
}
]
}
]
}
]
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}