> ## Documentation Index
> Fetch the complete documentation index at: https://docs.a7manager.se/llms.txt
> Use this file to discover all available pages before exploring further.

# vehicle_out_of_service

> Periods where a vehicle was unavailable.

Periods where a vehicle was unavailable. Delivered daily.

**Update key:** `external_system_id` — one identifier per period, reused to close it

## Columns

| Column               | Type        | Required | Notes                                                                            |
| -------------------- | ----------- | :------: | -------------------------------------------------------------------------------- |
| `external_system_id` | text(100)   |     ●    | One identifier per period, reused to close it                                    |
| `vehicle_number`     | text(100)   |     ●    | Must exist in project                                                            |
| `out_of_service_at`  | timestamptz |     ●    |                                                                                  |
| `in_service_at`      | timestamptz |     ○    | Empty means still out of service. Must be **strictly after** `out_of_service_at` |
| `reason`             | enum        |     ●    | See values below                                                                 |
| `depot`              | text(100)   |     ○    |                                                                                  |
| `notes`              | text        |     ○    |                                                                                  |
| `last_updated`       | timestamptz |     ●    | Staleness key                                                                    |

### `reason` values

`PLANNED_MAINTENANCE` · `UNPLANNED_REPAIR` · `ACCIDENT` · `MODIFICATION` · `OTHER`

## Closing a period

Closing works like a dismount: re-send the same `external_system_id` with `in_service_at`
filled in and a newer `last_updated`. Do not send a separate row.

<Warning>
  Re-sending a closed period with `in_service_at` **empty** and a newer `last_updated`
  **re-opens it**, setting the return-to-service time back to nothing. Once a period is
  closed, your exporter must keep carrying that value.
</Warning>

`in_service_at` must be strictly later than `out_of_service_at` — identical timestamps are
rejected, so a period that opened and closed at the same recorded instant needs its
timestamps separated before delivery.

## Example

The first row is a closed period, the second still open:

```csv theme={null}
external_system_id,vehicle_number,out_of_service_at,in_service_at,reason,depot,notes,last_updated
OOS-001,X61001,2026-01-15T06:00:00Z,2026-01-18T14:00:00Z,PLANNED_MAINTENANCE,Raus,Scheduled A-service overhaul,2026-03-14T09:00:00Z
OOS-002,X61001,2026-03-10T07:00:00Z,,UNPLANNED_REPAIR,Hässleholm,Brake system fault detected during operation,2026-03-14T09:00:00Z
```

## Why a file gets rejected

Required fields, the enum and the ordering rule are reported together:

```
Row 3: missing or empty external_system_id
Row 4: missing or empty vehicle_number
Row 5: missing or empty out_of_service_at
Row 6: missing or empty reason
Row 8: invalid reason 'MAINTENANCE' (must be one of: PLANNED_MAINTENANCE, UNPLANNED_REPAIR, ACCIDENT, MODIFICATION, OTHER)
Row 10: in_service_at must be after out_of_service_at
```

Vehicle resolution is checked afterwards, so these appear on a later attempt:

```
Row 12: vehicle_number 'X61099' not found in project
```
