{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codebase-design/json-schema/codebase-design-build-handoff-schema.json",
  "title": "BuildHandoff",
  "description": "Links an agent can hand to its human.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codebase-design-openapi.yml#/components/schemas/BuildHandoff",
  "type": "object",
  "properties": {
    "previewUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Live preview on the project origin (https://p-<projectId>.<preview domain>/preview/<projectId>/?pt=...). A browser link: the short-lived pt token is swapped for a cookie on the preview origin and the response redirects, so a client that drops cookies gets 403 Private preview. Scripts must keep cookies across the redirect, e.g. curl -c jar -b jar -L \"$PREVIEW_URL\". Open it before previewExpiresAt and the preview stays usable for hours; after that, POST /api/v1/builds/{sessionId}/preview for a fresh link. Only returned to the project owner with builds:read; null otherwise."
    },
    "previewExpiresAt": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Epoch ms after which previewUrl must be re-fetched"
    },
    "workspaceUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "The project in the Codebase workspace (owner sign-in required)"
    },
    "sourceUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Zip of the project source. GET with your X-API-Key (projects:read)."
    },
    "failure": {
      "$ref": "#/$defs/BuildFailure"
    }
  },
  "$defs": {
    "BuildFailure": {
      "type": [
        "object",
        "null"
      ],
      "description": "Why the build did not succeed; null while it runs or after it succeeds.",
      "properties": {
        "code": {
          "type": "string",
          "description": "Machine reason, e.g. build-timeout, budget-exceeded, credit_limit, rolled-back, incomplete (the agent stopped before finishing; ask it to continue), PROV-CAP-01"
        },
        "message": {
          "type": "string",
          "description": "One plain sentence to show a human"
        },
        "retryable": {
          "type": "boolean",
          "description": "Whether the same request can succeed later without a human changing anything (false for out of credits or a blocked account)"
        },
        "detail": {
          "type": "string",
          "description": "The backend error text, when it adds something"
        }
      }
    }
  }
}