{
  "openapi": "3.0.0",
  "paths": {
    "/v1/tools": {
      "get": {
        "description": "Lists the workspace's published shared tools. Unpublished workflows and tools kept in a member's personal space are not listed.",
        "operationId": "listTools",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalToolListResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "List the tools available to the workspace",
        "tags": ["external-api"]
      }
    },
    "/v1/tools/{toolId}/runs": {
      "post": {
        "description": "Call GET inspect first to discover the tool's input ids, types, and allowed values — the inputs in this request are matched to that surface by id.",
        "operationId": "run",
        "parameters": [
          {
            "name": "toolId",
            "required": true,
            "in": "path",
            "description": "Workflow tool ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunToolRequestDto"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunToolResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query parameters failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "No tool with this id is accessible to the caller, or the workflow is not configured as a tool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Start one or more runs of a tool",
        "tags": ["external-api"]
      },
      "get": {
        "operationId": "getRunsStatus",
        "parameters": [
          {
            "name": "toolId",
            "required": true,
            "in": "path",
            "description": "Workflow tool ID",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "run_ids",
            "required": true,
            "in": "query",
            "description": "Comma-separated run IDs to fetch (?run_ids=a,b)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalRunStatusResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query parameters failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "No tool with this id is accessible to the caller, or the workflow is not configured as a tool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Batch poll run status for a tool",
        "tags": ["external-api"]
      }
    },
    "/v1/tools/{toolId}/cost": {
      "post": {
        "description": "Takes the same body as POST runs, so a caller can price the exact request it is about to run. Nothing is run and no credits are spent.",
        "operationId": "getCost",
        "parameters": [
          {
            "name": "toolId",
            "required": true,
            "in": "path",
            "description": "Workflow tool ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolCostRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalToolCostResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query parameters failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "No tool with this id is accessible to the caller, or the workflow is not configured as a tool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Estimate the credit cost of running a tool",
        "tags": ["external-api"]
      }
    },
    "/v1/tools/{toolId}/runs/cancel": {
      "post": {
        "operationId": "cancelRuns",
        "parameters": [
          {
            "name": "toolId",
            "required": true,
            "in": "path",
            "description": "Workflow tool ID",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "run_ids",
            "required": true,
            "in": "query",
            "description": "Comma-separated run IDs to cancel (?run_ids=a,b)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalRunStatusResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query parameters failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "No tool with this id is accessible to the caller, or the workflow is not configured as a tool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Cancel one or more runs of a tool",
        "tags": ["external-api"]
      }
    },
    "/v1/tools/{toolId}/inspect": {
      "get": {
        "description": "Describes the latest published version, or the version given by `tool_version`.",
        "operationId": "inspect",
        "parameters": [
          {
            "name": "toolId",
            "required": true,
            "in": "path",
            "description": "Workflow tool ID",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tool_version",
            "required": false,
            "in": "query",
            "description": "Published tool version to describe. Defaults to the latest published version.",
            "schema": {
              "minimum": 1,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalInspectResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query parameters failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "No tool with this id is accessible to the caller, or the workflow is not configured as a tool.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Describe a tool's input and output surface",
        "tags": ["external-api"]
      }
    },
    "/v1/assets/uploads": {
      "post": {
        "description": "PUT the file to upload_url with exactly the declared file_size and content_type, and the header If-None-Match: *. The URL works once. Then commit the upload to make asset_id usable on a run.",
        "operationId": "initiate",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InitiateAssetsUploadRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitiateAssetsUploadResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query parameters failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Start an upload and get a write URL",
        "tags": ["external-api"]
      }
    },
    "/v1/assets/uploads/{asset_id}/commit": {
      "post": {
        "description": "Call this once the PUT to upload_url has succeeded. Verifies the file landed as declared and marks the asset committed, after which asset_id can be used as a media input on a run. Idempotent.",
        "operationId": "commit",
        "parameters": [
          {
            "name": "asset_id",
            "required": true,
            "in": "path",
            "description": "Asset ID returned by the initiate call",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommitAssetsUploadResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "asset_id is not a valid UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid workspace API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "No asset with this id belongs to the workspace the API token resolves to.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "409": {
            "description": "The file has not been uploaded yet, so retry once the PUT to upload_url succeeds; or the asset was rejected because what landed did not match what was declared, and a new upload must be started.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalApiErrorResponseDto"
                }
              }
            }
          }
        },
        "summary": "Finish an upload and make the asset usable",
        "tags": ["external-api"]
      }
    }
  },
  "info": {
    "title": "Weave External API",
    "description": "Public API for running and inspecting Weave tools.",
    "version": "1.0.0",
    "contact": {}
  },
  "tags": [],
  "servers": [
    {
      "url": "https://developer.api.weavy.ai"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Figma-Token",
        "description": "Workspace API Token, sent in the `X-Figma-Token` header."
      }
    },
    "schemas": {
      "ExternalToolDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Tool id — pass it to the inspect, run, status and cancel endpoints."
          },
          "name": {
            "type": "string",
            "description": "Tool name, as shown in the Weave editor."
          }
        },
        "required": ["id", "name"]
      },
      "ExternalToolListResponseDto": {
        "type": "object",
        "properties": {
          "tools": {
            "description": "The workspace's published tools, ordered by name. Unpublished workflows and tools kept in a member's personal space are not listed.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalToolDto"
            }
          }
        },
        "required": ["tools"]
      },
      "RunToolStringValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "type": "string"
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolIntegerValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "type": "number"
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolBooleanValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "type": "boolean"
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolSeedValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "is_random": {
                "type": "boolean",
                "description": "Randomize the seed per run"
              },
              "value": {
                "type": "number",
                "description": "Fixed seed value (used when is_random is not true)"
              }
            }
          }
        ]
      },
      "RunToolMediaValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "type": "string",
                "description": "Public URL or base64 data URI; dimensions are probed server-side. Provide this or asset_id, not both."
              },
              "asset_id": {
                "type": "string",
                "format": "uuid",
                "description": "Handle returned by a committed asset upload. Provide this or value, not both."
              },
              "kind": {
                "type": "string",
                "enum": ["image", "video", "audio", "3d"],
                "description": "Inferred from the URL extension when omitted"
              }
            }
          }
        ]
      },
      "RunToolSelectorValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "number"
                  }
                ],
                "description": "The chosen option (one of the node values)"
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolIteratorValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "maxItems": 100,
                "description": "Values to iterate over (the run fans out per value). Max 100.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "run_mode": {
                "type": "string",
                "enum": ["parallel", "matrix"],
                "description": "Not yet honored (follow-up); mode is fixed by the tool."
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolFileRef": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Public URL of the file. Provide this or asset_id, not both."
          },
          "asset_id": {
            "type": "string",
            "format": "uuid",
            "description": "Handle returned by a committed asset upload. Provide this or url, not both."
          },
          "kind": {
            "type": "string",
            "enum": ["image", "video", "audio", "3d"]
          }
        }
      },
      "RunToolMediaIteratorValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "maxItems": 100,
                "description": "Files to iterate over (the run fans out per file). Max 100.",
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RunToolFileRef"
                }
              },
              "run_mode": {
                "type": "string",
                "enum": ["parallel", "matrix"],
                "description": "Not yet honored (follow-up); mode is fixed by the tool."
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolArrayValue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          },
          {
            "type": "object",
            "properties": {
              "value": {
                "description": "The list of strings this Array input produces",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": ["value"]
          }
        ]
      },
      "RunToolInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the input to set (from the inspect endpoint)"
          },
          "use_default": {
            "type": "boolean",
            "description": "Run this input with the value the tool was published with, instead of supplying one. Mutually exclusive with `value`."
          },
          "value": {
            "$ref": "#/components/schemas/RunToolInputDtoValue"
          }
        },
        "required": ["id"]
      },
      "WebhookDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "HTTPS URL to POST run status to when a run completes or fails."
          }
        },
        "required": ["url"]
      },
      "RunToolRequestDto": {
        "type": "object",
        "properties": {
          "tool_version": {
            "type": "number",
            "description": "Tool version to run. Defaults to the latest published version."
          },
          "count": {
            "type": "number",
            "minimum": 1,
            "maximum": 10,
            "default": 1,
            "description": "Number of runs to start (1-10)."
          },
          "inputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunToolInputDto"
            }
          },
          "webhook": {
            "description": "Optional per-request webhook",
            "allOf": [
              {
                "$ref": "#/components/schemas/WebhookDto"
              }
            ]
          }
        },
        "required": ["inputs"]
      },
      "ExternalRunRefDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Run ID; poll GET /v1/tools/{tool_id}/runs?run_ids=... for status and outputs"
          },
          "tool_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["running", "completed", "failed", "canceled"],
            "description": "Always \"running\" — runs start asynchronously"
          }
        },
        "required": ["id", "tool_id", "status"]
      },
      "RunToolResponseDto": {
        "type": "object",
        "properties": {
          "runs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalRunRefDto"
            }
          }
        },
        "required": ["runs"]
      },
      "ToolCostRequestDto": {
        "type": "object",
        "properties": {
          "tool_version": {
            "type": "number",
            "description": "Tool version to price. Defaults to the latest published version."
          },
          "inputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunToolInputDto"
            }
          }
        },
        "required": ["inputs"]
      },
      "ExternalToolCostResponseDto": {
        "type": "object",
        "properties": {
          "estimated_credit_cost": {
            "type": "number",
            "nullable": true,
            "description": "Estimated credit cost of a single run of the tool with the inputs in this request. null when the cost depends on values only known at run time — an iterator whose item count this request does not pin, or a priced model parameter fed by an upstream node whose output is not yet known."
          }
        },
        "required": ["estimated_credit_cost"]
      },
      "ExternalImageAssetDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["image"]
          },
          "url": {
            "type": "string"
          }
        },
        "required": ["type", "url"]
      },
      "ExternalVideoAssetDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["video"]
          },
          "url": {
            "type": "string"
          }
        },
        "required": ["type", "url"]
      },
      "ExternalAudioAssetDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["audio"]
          },
          "url": {
            "type": "string"
          }
        },
        "required": ["type", "url"]
      },
      "External3dAssetDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["3d"]
          },
          "url": {
            "type": "string"
          }
        },
        "required": ["type", "url"]
      },
      "ExternalTextAssetDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["text"]
          },
          "text": {
            "type": "string"
          }
        },
        "required": ["type", "text"]
      },
      "ExternalUnknownAssetDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["unknown"]
          },
          "url": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        },
        "required": ["type"]
      },
      "ExternalOutputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Workflow output ID that produced this output; matches inspect.outputs[].id."
          },
          "name": {
            "type": "string",
            "description": "Output name from the WorkflowOutput node; \"default\" if unset"
          },
          "iteration_index": {
            "type": "number",
            "description": "Iterator fan-out index for this output branch, matching the order of the iterator values in the run request. Absent for non-iterator runs. Encodes all iterators for the branch (base-100) when the run has more than one iterator."
          },
          "assets": {
            "type": "array",
            "description": "Output assets; each is one of the typed asset variants, discriminated by `type`.",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/ExternalImageAssetDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalVideoAssetDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalAudioAssetDto"
                },
                {
                  "$ref": "#/components/schemas/External3dAssetDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalTextAssetDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalUnknownAssetDto"
                }
              ]
            }
          }
        },
        "required": ["id", "name", "assets"]
      },
      "ExternalErrorDto": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": ["message"]
      },
      "ExternalRunStatusDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "tool_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["running", "completed", "failed", "canceled"]
          },
          "progress_percentage": {
            "type": "number",
            "description": "0–100; omitted for terminal statuses"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Set when the run completed or failed"
          },
          "canceled_at": {
            "type": "string",
            "format": "date-time",
            "description": "Set when the run was canceled"
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalOutputDto"
            }
          },
          "error": {
            "$ref": "#/components/schemas/ExternalErrorDto"
          }
        },
        "required": ["id", "tool_id", "status", "created_at"]
      },
      "ExternalRunStatusResponseDto": {
        "type": "object",
        "properties": {
          "runs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalRunStatusDto"
            }
          },
          "workspace_credits_remaining": {
            "type": "number",
            "description": "Workspace-level credits remaining, shared across all runs in the response."
          }
        },
        "required": ["runs"]
      },
      "ExternalInspectStringInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["string"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolStringValue"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectNumberRangeDto": {
        "type": "object",
        "properties": {
          "min": {
            "type": "number"
          },
          "max": {
            "type": "number"
          }
        }
      },
      "ExternalInspectIntegerInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["integer"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolIntegerValue"
              }
            ]
          },
          "number_range": {
            "description": "Min/max bounds (advisory)",
            "allOf": [
              {
                "$ref": "#/components/schemas/ExternalInspectNumberRangeDto"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectBooleanInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["boolean"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolBooleanValue"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectSelectorInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["selector"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolSelectorValue"
              }
            ]
          },
          "values": {
            "description": "Allowed options to choose from",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectIteratorInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["iterator"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolIteratorValue"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectMediaIteratorInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["media_iterator"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolMediaIteratorValue"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectMediaInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["media"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolMediaValue"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectArrayInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["array"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolArrayValue"
              }
            ]
          }
        },
        "required": ["id", "type", "default_value"]
      },
      "ExternalInspectSeedInputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Author-provided description of the input"
          },
          "type": {
            "type": "string",
            "enum": ["seed"]
          },
          "default_value": {
            "description": "The value this input was published with — null if nothing usable is saved",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/RunToolSeedValue"
              }
            ]
          },
          "is_random": {
            "type": "boolean",
            "description": "Whether the seed is randomized per run"
          },
          "seed": {
            "type": "number",
            "description": "Fixed seed value when not random"
          }
        },
        "required": ["id", "type", "default_value", "is_random"]
      },
      "ExternalInspectOutputDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Author-set output name; \"default\" if unset"
          },
          "output_type": {
            "type": "string",
            "enum": ["image", "video", "text", "any"]
          },
          "input_ids": {
            "description": "IDs of inputs[] entries that flow into this output",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": ["id", "name", "output_type", "input_ids"]
      },
      "ExternalInspectResponseDto": {
        "type": "object",
        "properties": {
          "tool_version": {
            "type": "number",
            "description": "The tool version this response describes."
          },
          "inputs": {
            "type": "array",
            "description": "Tool inputs; each is one of the typed input variants, discriminated by `type`.",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/ExternalInspectStringInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectIntegerInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectBooleanInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectSelectorInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectIteratorInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectMediaIteratorInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectMediaInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectArrayInputDto"
                },
                {
                  "$ref": "#/components/schemas/ExternalInspectSeedInputDto"
                }
              ]
            }
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalInspectOutputDto"
            }
          }
        },
        "required": ["tool_version", "inputs", "outputs"]
      },
      "InitiateAssetsUploadRequestDto": {
        "type": "object",
        "properties": {
          "file_name": {
            "type": "string",
            "description": "Original file name, stored for reference only",
            "maxLength": 255
          },
          "file_size": {
            "type": "number",
            "description": "Exact size in bytes, from 1 to 524288000 (500 MiB). The upload URL is signed for this value, so the file you PUT must match it exactly.",
            "minimum": 1,
            "maximum": 524288000
          },
          "content_type": {
            "type": "string",
            "description": "Media type of the file. The upload URL is signed for this value, so the Content-Type you PUT must match it exactly.",
            "enum": [
              "audio/mpeg",
              "audio/wav",
              "image/jpeg",
              "image/jpg",
              "image/png",
              "image/webp",
              "model/fbx",
              "model/gltf-binary",
              "model/obj",
              "model/ply",
              "video/mp4",
              "video/quicktime",
              "video/webm"
            ]
          }
        },
        "required": ["file_name", "file_size", "content_type"]
      },
      "InitiateAssetsUploadResponseDto": {
        "type": "object",
        "properties": {
          "asset_id": {
            "type": "string",
            "description": "Handle for the uploaded asset, used as media.asset_id on a run"
          },
          "upload_url": {
            "type": "string",
            "description": "Single-use write URL. PUT the file to it with the declared size and content type"
          },
          "content_type": {
            "type": "string",
            "description": "The content type the upload URL is signed for. Send exactly this as the Content-Type header"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO timestamp after which the upload URL stops working"
          }
        },
        "required": ["asset_id", "upload_url", "content_type", "expires_at"]
      },
      "CommitAssetsUploadResponseDto": {
        "type": "object",
        "properties": {
          "asset_id": {
            "type": "string",
            "description": "Handle for the uploaded asset, usable as media.asset_id on a run"
          },
          "status": {
            "type": "string",
            "description": "Lifecycle state of the asset",
            "enum": ["committed"]
          }
        },
        "required": ["asset_id", "status"]
      },
      "ExternalApiErrorResponseDto": {
        "type": "object",
        "properties": {
          "internalErrorCode": {
            "type": "number",
            "description": "Numeric internal error code (see AppInternalErrorCode)."
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message."
          },
          "fieldsErrors": {
            "description": "Field-level validation messages; empty for non-validation errors.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When the error was produced."
          },
          "statusCode": {
            "type": "number",
            "description": "HTTP status code, mirroring the response status."
          },
          "correlationId": {
            "type": "string",
            "description": "Request correlation id, when available."
          }
        },
        "required": ["internalErrorCode", "message", "fieldsErrors", "timestamp", "statusCode"]
      },
      "RunToolInputDtoValue": {
        "type": "object",
        "required": ["type"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["string", "integer", "boolean", "seed", "media", "selector", "iterator", "media_iterator", "array"]
          }
        },
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "string": "#/components/schemas/RunToolStringValue",
            "integer": "#/components/schemas/RunToolIntegerValue",
            "boolean": "#/components/schemas/RunToolBooleanValue",
            "seed": "#/components/schemas/RunToolSeedValue",
            "media": "#/components/schemas/RunToolMediaValue",
            "selector": "#/components/schemas/RunToolSelectorValue",
            "iterator": "#/components/schemas/RunToolIteratorValue",
            "media_iterator": "#/components/schemas/RunToolMediaIteratorValue",
            "array": "#/components/schemas/RunToolArrayValue"
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiToken": []
    }
  ]
}
