{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/primateintelligence-ai/json-schema/primateintelligence-ai-video-schema.json",
  "title": "Video",
  "description": "A source video (§13.1).",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/primateintelligence-ai-openapi.json#/components/schemas/Video",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^video_[0-9A-HJKMNP-TV-Z]{26}$",
      "description": "Video resource id (prefixed ULID). Immutable."
    },
    "object": {
      "type": "string",
      "enum": [
        "video"
      ]
    },
    "livemode": {
      "type": "boolean",
      "description": "true when the request used a live key; false for test keys and sandbox. Stripe-style."
    },
    "status": {
      "$ref": "#/$defs/VideoStatus"
    },
    "filename": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 255
    },
    "size_bytes": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "maximum": 2147483648
    },
    "duration_s": {
      "type": [
        "number",
        "null"
      ],
      "exclusiveMinimum": 0
    },
    "width": {
      "type": [
        "integer",
        "null"
      ]
    },
    "height": {
      "type": [
        "integer",
        "null"
      ]
    },
    "fps": {
      "type": [
        "number",
        "null"
      ]
    },
    "content_type": {
      "type": "string",
      "enum": [
        "video/mp4",
        "video/quicktime"
      ]
    },
    "source": {
      "type": "string",
      "enum": [
        "upload",
        "url"
      ]
    },
    "upload": {
      "$ref": "#/$defs/VideoUpload"
    },
    "media": {
      "$ref": "#/$defs/VideoMedia"
    },
    "error": {
      "$ref": "#/$defs/ErrorObject"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "maxLength": 500
      },
      "default": {},
      "description": "Free-form key/value metadata. ≤16 keys, key ≤40 chars [a-zA-Z0-9_.-], value ≤500 chars."
    },
    "expires_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "object",
    "livemode",
    "status",
    "filename",
    "size_bytes",
    "duration_s",
    "width",
    "height",
    "fps",
    "content_type",
    "source",
    "upload",
    "error",
    "expires_at",
    "created_at"
  ],
  "$defs": {
    "ErrorObject": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ]
    },
    "VideoMedia": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "url",
        "expires_at"
      ],
      "description": "Signed 1h playback URL for the source video (sign-on-read — re-fetch for a fresh URL). Null while not ready or when no stored source object exists."
    },
    "VideoStatus": {
      "type": "string",
      "enum": [
        "awaiting_upload",
        "processing",
        "ready",
        "failed"
      ],
      "description": "Video lifecycle state (§14.1)."
    },
    "VideoUpload": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "PUT"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "headers": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "method",
        "url",
        "headers",
        "expires_at"
      ],
      "description": "Presigned upload instructions. Present only while awaiting_upload. URL TTL 1h."
    }
  }
}