{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codai-ro/json-schema/codai-ro-device-list-item-schema.json",
  "title": "Device",
  "description": "One registered device. Keys are camelCase for the timestamps, snake_case for `has_push_token` — exactly as the API returns them.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codai-ro-devices-api-openapi.yml#/components/schemas/DeviceListItem",
  "type": "object",
  "required": [
    "id",
    "name",
    "platform",
    "capabilities",
    "has_push_token",
    "lastSeenAt",
    "createdAt",
    "online"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Client-chosen device UUID."
    },
    "name": {
      "type": "string",
      "maxLength": 120,
      "description": "Display name from `x-codai-device-name` at registration, or `<platform> device`."
    },
    "platform": {
      "$ref": "#/$defs/DevicePlatform"
    },
    "capabilities": {
      "type": "array",
      "description": "Free-form capability labels set via PATCH (max 64 entries, 1–64 chars each).",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64
      }
    },
    "has_push_token": {
      "type": "boolean",
      "description": "Whether an FCM registration token is stored. The token itself is never returned."
    },
    "app_version": {
      "type": [
        "string",
        "null"
      ],
      "description": "Last client version this device reported in `x-codai-client`, as `<app>/<semver>` (e.g. `desktop/0.7.0`). `null` until the device sends it."
    },
    "lastSeenAt": {
      "type": "string",
      "format": "date-time",
      "description": "Bumped on every request carrying this device id and on every PATCH."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "online": {
      "type": "boolean",
      "description": "`true` when `lastSeenAt` is within the last 2 minutes (any request carrying this device id bumps it). A future `lastSeenAt` (clock skew) counts as online."
    }
  },
  "$defs": {
    "DevicePlatform": {
      "type": "string",
      "description": "Client platform; anything else sent in `x-codai-device-platform` is stored as `agent`.",
      "enum": [
        "android",
        "ios",
        "web",
        "desktop",
        "cli",
        "agent"
      ]
    }
  }
}