{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/officina-it/json-schema/officina-it-checkin-schema.json",
  "title": "Checkin",
  "description": "A vehicle intake / inspection snapshot. Belongs to one\ncompany, one customer, and one vehicle. List responses omit\n`line_items` to keep payloads small; detail responses\npopulate it.\n",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/officina-it-openapi.json#/components/schemas/Checkin",
  "type": "object",
  "required": [
    "object",
    "id",
    "work_category_ids",
    "work_categories",
    "seq_number",
    "status",
    "customer_id",
    "vehicle_id",
    "customer_name",
    "vehicle_name",
    "created_by",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "x-since": "2026-10-22",
      "description": "Detail, create and write responses only (lists omit it). Send it\nback as `If-Match` on PATCH (and on the line-items batch): a save\nfrom an older copy is refused with 409. Required from revision\n2026-10-22.\n"
    },
    "object": {
      "type": "string",
      "const": "checkin"
    },
    "id": {
      "type": "string"
    },
    "seq_number": {
      "type": "integer",
      "description": "Per-company human-readable sequence (e.g. \"Checkin #142\").\nAssigned at create time and stable afterwards.\n"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "completed"
      ],
      "description": "Lifecycle state. Mutated only through\n`POST /v1/checkins/{id}/transitions`, never via PATCH.\n"
    },
    "title": {
      "type": [
        "string",
        "null"
      ]
    },
    "comments": {
      "type": [
        "string",
        "null"
      ]
    },
    "internal_comments": {
      "type": [
        "string",
        "null"
      ],
      "description": "Notes visible only to workshop staff."
    },
    "customer_id": {
      "type": "string"
    },
    "vehicle_id": {
      "type": "string"
    },
    "work_category_id": {
      "type": [
        "string",
        "null"
      ],
      "deprecated": true,
      "description": "The first category's id. Served only to revisions before\n2026-11-02; from 2026-11-02 the key is absent: read\n`work_category_ids`.\n"
    },
    "worksheet_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Set when the checkin has been converted into a worksheet."
    },
    "quote_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Set when the checkin has been converted into a quote."
    },
    "fuel_level": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Free-form integer captured at intake. Convention is\n0–100 (percentage) but the API enforces no bounds today.\n"
    },
    "section1": {
      "type": [
        "string",
        "null"
      ]
    },
    "section2": {
      "type": [
        "string",
        "null"
      ]
    },
    "section3": {
      "type": [
        "string",
        "null"
      ]
    },
    "section4": {
      "type": [
        "string",
        "null"
      ]
    },
    "section5": {
      "type": [
        "string",
        "null"
      ]
    },
    "section6": {
      "type": [
        "string",
        "null"
      ]
    },
    "section7": {
      "type": [
        "string",
        "null"
      ]
    },
    "section8": {
      "type": [
        "string",
        "null"
      ]
    },
    "km": {
      "type": [
        "number",
        "null"
      ],
      "description": "Odometer reading at intake."
    },
    "created_by": {
      "type": "string",
      "description": "User id of the staff member who created the checkin."
    },
    "customer_name": {
      "type": "string",
      "description": "Denormalized display string of the linked customer.\nPre-computed on the entity for list-row rendering\nwithout a second request.\n"
    },
    "vehicle_name": {
      "type": "string",
      "description": "Denormalized display string of the linked vehicle."
    },
    "vehicle_license": {
      "type": [
        "string",
        "null"
      ]
    },
    "work_category_name": {
      "type": [
        "string",
        "null"
      ],
      "deprecated": true,
      "description": "The first category's name. Served only to revisions before\n2026-11-02; from 2026-11-02 the key is absent: read\n`work_categories`.\n"
    },
    "work_category_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "x-since": "2026-10-03",
      "description": "Every work category (\"categoria\") of the document, in\nthe order chosen. `work_category_id` (revisions before 2026-11-02)\nalways equals the first. `[]` when the document has none, never\nnull. Available since revision 2026-10-03.\n"
    },
    "work_categories": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WorkCategory"
      },
      "x-since": "2026-10-03",
      "description": "The same list as `work_category_ids` with each category's\nname, same order. `work_category_name` (revisions before 2026-11-02) is the first one's\nname. Available since revision 2026-10-03.\n"
    },
    "delivered_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "deleted_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Soft-deletion timestamp. Populated on the response from\nDELETE /v1/checkins/{id}. Checkins with a non-null\ndeleted_at are not returned by list/detail endpoints —\nthis field appears for the delete response only.\n"
    },
    "line_items": {
      "type": [
        "array",
        "null"
      ],
      "description": "Embedded line items (description-only notes). Populated on\ndetail / batch responses; list GET emits `null` to keep\npayloads small. Mutate via\nPOST /v1/checkins/{id}/line-items/batch.\n",
      "items": {
        "$ref": "#/$defs/CheckinLineItem"
      }
    }
  },
  "$defs": {
    "CheckinLineItem": {
      "type": "object",
      "required": [
        "object",
        "id",
        "description",
        "created_at"
      ],
      "description": "A description-only line item (note) on a checkin. Returned\nread-only on checkin responses; mutate via\nPOST /v1/checkins/{id}/line-items/batch.\n",
      "properties": {
        "object": {
          "type": "string",
          "const": "checkin_line_item"
        },
        "id": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "WorkCategory": {
      "type": "object",
      "required": [
        "object",
        "id",
        "name"
      ],
      "properties": {
        "object": {
          "type": "string",
          "const": "work_category"
        },
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        }
      }
    }
  }
}