{
  "$defs": {
    "SignedPut": {
      "additionalProperties": false,
      "description": "A signed PUT URL for exactly one object name.\n\n``headers`` must be sent verbatim (they are part of the signature): typically\n``content-type``, ``x-goog-if-generation-match: 0`` (write-once) and\n``x-goog-content-length-range: 0,<max_bytes>``.",
      "examples": [
        {
          "expires_at": "2026-10-15T10:30:00Z",
          "headers": {
            "content-type": "application/json",
            "x-goog-content-length-range": "0,1048576",
            "x-goog-if-generation-match": "0"
          },
          "max_bytes": 1048576,
          "method": "PUT",
          "name": "t/default/runs/run_01jabc/a1/manifest.json",
          "url": "http://127.0.0.1:4443/upload/storage/v1/b/mapi-local-runs/o/t%2Fdefault%2Fruns%2Frun_01jabc%2Fa1%2Fmanifest.json?X-Goog-Signature=..."
        }
      ],
      "properties": {
        "expires_at": {
          "format": "date-time",
          "title": "Expires At",
          "type": "string"
        },
        "headers": {
          "additionalProperties": {
            "type": "string"
          },
          "maxProperties": 32,
          "title": "Headers",
          "type": "object"
        },
        "max_bytes": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Max Bytes"
        },
        "method": {
          "const": "PUT",
          "default": "PUT",
          "title": "Method",
          "type": "string"
        },
        "name": {
          "maxLength": 1024,
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "url": {
          "maxLength": 8192,
          "minLength": 8,
          "title": "Url",
          "type": "string"
        }
      },
      "required": [
        "url",
        "name",
        "expires_at"
      ],
      "title": "SignedPut",
      "type": "object"
    }
  },
  "$id": "https://schemas.mapi.dev/v1/api-UploadSession.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Where to PUT the file. ``upload.headers`` must be sent verbatim; the URL expires.",
  "examples": [
    {
      "content_type": "text/csv",
      "created_at": "2026-10-15T09:30:00Z",
      "dataset_id": "ds_01jaf3a1b2c3d4e5f6g7h8j9k0",
      "expires_at": "2026-10-15T10:30:00Z",
      "filename": "eu_media_daily.csv",
      "id": "upl_01jaf3d1e2f3g4h5j6k7m8n9p0",
      "project_id": "default",
      "size_bytes": 5242880,
      "status": "pending",
      "tenant_id": "default",
      "upload": {
        "expires_at": "2026-10-15T10:30:00Z",
        "headers": {
          "content-type": "text/csv",
          "x-goog-content-length-range": "0,5242880",
          "x-goog-if-generation-match": "0"
        },
        "max_bytes": 5242880,
        "method": "PUT",
        "name": "t/default/uploads/upl_01jaf3d1e2f3g4h5j6k7m8n9p0",
        "url": "http://127.0.0.1:4443/upload/storage/v1/b/mapi-local-quarantine/o?name=t%2Fdefault%2Fuploads%2Fupl_01&X-Goog-Signature=\u2026"
      }
    }
  ],
  "properties": {
    "content_type": {
      "title": "Content Type",
      "type": "string"
    },
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "dataset_id": {
      "examples": [
        "run_01jaf3q2x8m9v7k5h4g3f2e1d0"
      ],
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.\\-]{0,127}$",
      "title": "Dataset Id",
      "type": "string"
    },
    "expires_at": {
      "format": "date-time",
      "title": "Expires At",
      "type": "string"
    },
    "filename": {
      "title": "Filename",
      "type": "string"
    },
    "id": {
      "examples": [
        "run_01jaf3q2x8m9v7k5h4g3f2e1d0"
      ],
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.\\-]{0,127}$",
      "title": "Id",
      "type": "string"
    },
    "project_id": {
      "pattern": "^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$",
      "title": "Project Id",
      "type": "string"
    },
    "received": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "v0.15 (get_upload, renew_upload): the file arrived in the quarantine bucket",
      "title": "Received"
    },
    "size_bytes": {
      "title": "Size Bytes",
      "type": "integer"
    },
    "status": {
      "enum": [
        "pending",
        "uploaded",
        "consumed",
        "expired"
      ],
      "title": "Status",
      "type": "string"
    },
    "tenant_id": {
      "pattern": "^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$",
      "title": "Tenant Id",
      "type": "string"
    },
    "upload": {
      "$ref": "#/$defs/SignedPut"
    }
  },
  "required": [
    "id",
    "tenant_id",
    "project_id",
    "dataset_id",
    "filename",
    "content_type",
    "size_bytes",
    "status",
    "upload",
    "expires_at",
    "created_at"
  ],
  "title": "UploadSession",
  "type": "object",
  "x-mapi-contract-version": "0.2"
}
