OfficeGest
Workshop/Appointments

Create appointment

When reception_date or delivery_date are sent together with a service_order, those datetimes are also written to the linked service order and meta.service_order_dates_synced reports the outcome (false when the order is closed, invoiced, delivered or cancelled). 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. 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.

POST
/workshop/appointments
AuthorizationBearer <token>

In: header

plan?object

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

subjectstring
startstring
Formatdate-time
endstring
Formatdate-time
employee_id?number
vehicle_plate?string
confirmed?string
completed?string
location?string
priority?string
contact_name?string
contact_phone?string
customer_id?number
observations?string
reception_date?string
delivery_date?string
warehouse_id?number
department_id?number | null

Valid value from departamentos.id.

service_order?string
rescheduled_from?number

Valid value from relcontacto.numrel.

checklists?array<unknown>
notify_send_email?string
notify_send_sms?string
interventions?array<object>

Response Body

curl -X POST "https://og-tenant1.test:8003/api/v2/workshop/appointments" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "string",
    "start": "2019-08-24T14:15:22Z",
    "end": "2019-08-24T14:15:22Z"
  }'
{
  "data": {
    "resource": "string"
  }
}
{
  "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"
  }
}