{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/peaka/main/json-schema/peaka-export-job-response-schema.json",
  "title": "ExportJobResponse",
  "description": "Status and result of an export job",
  "x-generated": "2026-10-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/peaka-api-openapi.json#/components/schemas/ExportJobResponse",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Export job id"
    },
    "status": {
      "type": "string",
      "description": "Job status. EXPIRED is derived when the artifacts have been removed by the lifecycle rule; exports are point-in-time snapshots and are never regenerated.",
      "enum": [
        "PENDING",
        "RUNNING",
        "SUCCEEDED",
        "FAILED",
        "CANCELLED",
        "EXPIRED"
      ]
    },
    "format": {
      "type": "string",
      "description": "Output format"
    },
    "compression": {
      "type": "string",
      "description": "Output compression"
    },
    "rowCount": {
      "type": "integer",
      "description": "Number of exported rows",
      "format": "int64"
    },
    "bytes": {
      "type": "integer",
      "description": "Total output size in bytes",
      "format": "int64"
    },
    "durationMs": {
      "type": "integer",
      "description": "Execution time in milliseconds",
      "format": "int64"
    },
    "files": {
      "type": "array",
      "description": "Downloadable artifacts (only for the owner of a SUCCEEDED job)",
      "items": {
        "$ref": "#/$defs/ExportFile"
      }
    },
    "expiresAt": {
      "type": "string",
      "description": "Expiry of the presigned URLs (ISO-8601); re-call GET for fresh links"
    },
    "downloadable": {
      "type": "boolean",
      "description": "Whether the calling user may download this export (owner-only access)"
    },
    "error": {
      "type": "string",
      "description": "Error message when the job failed"
    },
    "createdAt": {
      "type": "string",
      "description": "Submission time (ISO-8601)"
    },
    "queryId": {
      "type": "string",
      "description": "Source query id (query exports)"
    },
    "catalogId": {
      "type": "string",
      "description": "Source catalog id (table exports)"
    },
    "schemaName": {
      "type": "string",
      "description": "Source schema name (table exports)"
    },
    "tableName": {
      "type": "string",
      "description": "Source table name (table exports)"
    },
    "source": {
      "type": "string",
      "description": "Quoted, fully-qualified source name for display"
    },
    "userId": {
      "type": "string",
      "description": "Initiator user id"
    },
    "userName": {
      "type": "string",
      "description": "Initiator user name"
    },
    "apiKeyPrefix": {
      "type": "string",
      "description": "Public prefix of the initiator's API key"
    },
    "clientSource": {
      "type": "string",
      "description": "Client source (X-Trino-Source, falling back to User-Agent)"
    }
  },
  "$defs": {
    "ExportFile": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "File name"
        },
        "url": {
          "type": "string",
          "description": "Presigned download URL (short-lived)"
        },
        "bytes": {
          "type": "integer",
          "description": "Object size in bytes",
          "format": "int64"
        }
      },
      "description": "A downloadable export artifact with a freshly-minted presigned URL"
    }
  }
}