{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usestring-ai/json-schema/usestring-ai-context-schema.json",
  "title": "Context",
  "description": "A saved browser profile. See https://portal.usestring.ai/docs/browser/contexts#the-profile-object",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usestring-ai-openapi.json#/components/schemas/Context",
  "type": "object",
  "required": [
    "id",
    "name",
    "status",
    "sizeBytes",
    "failureReason",
    "latestSaveOperation",
    "lastSavedAt",
    "lastUsedAt",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Opaque UUID used to reconnect (`/wss?contextId=`), inspect, or delete."
    },
    "name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Optional label."
    },
    "status": {
      "$ref": "#/$defs/ContextStatus"
    },
    "sizeBytes": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Compressed size of the saved profile. Null before the first successful save."
    },
    "failureReason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Most recent save failure, cleared by a successful save."
    },
    "latestSaveOperation": {
      "oneOf": [
        {
          "$ref": "#/$defs/ContextSaveOperation"
        },
        {
          "type": "null"
        }
      ]
    },
    "lastSavedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Time of the last successful save."
    },
    "lastUsedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Last connection, saving or read-only. Reading status does not update it."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "ContextSaveOperation": {
      "type": "object",
      "description": "The most recent save.",
      "properties": {
        "id": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "PENDING",
            "COMMITTED",
            "FAILED",
            "EXPIRED",
            "SUPERSEDED"
          ],
          "description": "`PENDING`: not finished. `COMMITTED`: succeeded. `FAILED`: failed; read `failureReason`. `EXPIRED`: the session ended before anything was saved. `SUPERSEDED`: another session saved first; not a success."
        },
        "failureReason": {
          "type": [
            "string",
            "null"
          ]
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "ContextStatus": {
      "type": "string",
      "enum": [
        "EMPTY",
        "IN_USE",
        "UPLOADING",
        "READY",
        "FAILED",
        "DELETING"
      ],
      "description": "`EMPTY`: no saved data. `IN_USE`: a saving session is using the profile. `UPLOADING`: a save is finishing. `READY`: saved data is available. `FAILED`: a save failed; earlier saved data remains. `DELETING`: returned only by DELETE."
    }
  }
}