{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api.itch.io/schemas/build.json",
  "title": "Build",
  "description": "A specific versioned build pushed via butler (the itch.io command-line upload tool). Part of the wharf versioned distribution system.",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "description": "Site-wide unique identifier generated by itch.io"
    },
    "parentBuildId": {
      "type": "integer",
      "description": "Identifier of the previous build on the same channel; -1 if this is the initial build"
    },
    "state": {
      "type": "string",
      "enum": ["started", "queued", "processing", "completed", "failed"],
      "description": "Current state of the build in the processing pipeline"
    },
    "uploadId": {
      "type": "integer",
      "description": "ID of the upload (channel) this build belongs to"
    },
    "gameId": {
      "type": "integer",
      "description": "ID of the game this build belongs to"
    },
    "userId": {
      "type": "integer",
      "description": "ID of the user who pushed this build"
    },
    "version": {
      "type": "integer",
      "description": "Auto-incremented version number starting at 1"
    },
    "userVersion": {
      "type": "string",
      "description": "Developer-specified version string from --userversion flag; not necessarily unique"
    },
    "files": {
      "type": "array",
      "description": "Files associated with this build (archive, signature, patch, etc.)",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "size": { "type": "integer" },
          "state": { "type": "string", "enum": ["created", "uploading", "uploaded", "failed"] },
          "type": { "type": "string", "enum": ["patch", "archive", "signature", "manifest", "unpacked"] },
          "subType": { "type": "string", "enum": ["default", "gzip", "optimized"] },
          "createdAt": { "type": "string", "format": "date-time" },
          "updatedAt": { "type": "string", "format": "date-time" }
        }
      }
    },
    "user": {
      "$ref": "user.json",
      "description": "User who pushed the build"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": ["id", "state", "version"]
}
