{
  "openapi": "3.1.1",
  "info": {
    "title": "Voxel Height Grid Builder API",
    "version": "1.0.0",
    "summary": "Build an editable voxel model from rows of integer heights.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://renderloomvoxelheightgrid.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Build an editable voxel model from rows of integer heights.",
        "description": "Turn a rectangular grid of integer heights into a colored voxel model. Download a transparent isometric SVG, an OBJ/MTL mesh, a single-model VOX file, and an editable project for Renderloom Voxel Desk.\n\nMethodology:\n- Each cell specifies the number of voxels in a solid vertical column. Zero leaves a column empty. Values must be integers from 0 to 64; rows must have equal widths.\n- The highest voxel in each nonempty column uses the top color and all lower voxels use the base color.\n- A voxel occupies one integer grid cell; X and Y span each row and Z is the vertical axis. The preview is a transparent orthographic isometric illustration with fixed face shading.\n- The model supports dimensions of 1–64 cells per axis, up to 32,768 occupied cells and up to 64 opaque palette colors.\n- The VOX export is a single-model VOX 150 file with opaque palette colors. The OBJ mesh contains outward-facing quads only where a voxel has no occupied neighbor. It uses palette-based MTL diffuse colors; it does not include textures, animation or physically based material properties.\n\nThis creates solid vertical columns from the grid. The preview uses fixed illustration shading; it is not a physically based render.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "renderloom_voxel_height_grid",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderloomVoxelHeightGridInput"
              },
              "examples": {
                "example1": {
                  "summary": "A small stepped hill",
                  "value": {}
                },
                "example2": {
                  "summary": "A terraced platform",
                  "value": {
                    "grid": "1, 1, 1, 1\n1, 3, 3, 1\n1, 3, 3, 1\n1, 1, 1, 1",
                    "base": "#687886",
                    "top": "#eed5a3"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenderloomVoxelHeightGridResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RenderloomVoxelHeightGridInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "grid": {
            "title": "Height grid (0–64; one row per line)",
            "type": "string",
            "maxLength": 16000,
            "default": "0, 1, 2, 1, 0\n1, 2, 3, 2, 1\n2, 3, 4, 3, 2\n1, 2, 3, 2, 1\n0, 1, 2, 1, 0"
          },
          "base": {
            "title": "Base color (#rrggbb)",
            "type": "string",
            "maxLength": 7,
            "default": "#8b5e3c"
          },
          "top": {
            "title": "Top color (#rrggbb)",
            "type": "string",
            "maxLength": 7,
            "default": "#7ba85c"
          }
        },
        "required": []
      },
      "RenderloomVoxelHeightGridResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "project",
              "report",
              "preview",
              "mesh",
              "projectFile",
              "openInApp"
            ],
            "properties": {
              "project": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "format",
                  "version",
                  "name",
                  "width",
                  "height",
                  "depth",
                  "palette",
                  "voxels"
                ],
                "properties": {
                  "format": {
                    "const": "renderloom-voxel"
                  },
                  "version": {
                    "const": 1
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 64
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 64
                  },
                  "depth": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 64
                  },
                  "palette": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 64,
                    "items": {
                      "type": "string",
                      "pattern": "^#[0-9a-fA-F]{6}$"
                    }
                  },
                  "voxels": {
                    "type": "array",
                    "maxItems": 32768,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "x",
                        "y",
                        "z",
                        "color"
                      ],
                      "properties": {
                        "x": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 63
                        },
                        "y": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 63
                        },
                        "z": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 63
                        },
                        "color": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 63
                        }
                      }
                    }
                  }
                }
              },
              "report": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "width",
                  "height",
                  "depth",
                  "voxels",
                  "surfaceFaces",
                  "usedColors",
                  "paletteColors"
                ],
                "properties": {
                  "width": {
                    "type": "integer"
                  },
                  "height": {
                    "type": "integer"
                  },
                  "depth": {
                    "type": "integer"
                  },
                  "voxels": {
                    "type": "integer"
                  },
                  "surfaceFaces": {
                    "type": "integer"
                  },
                  "usedColors": {
                    "type": "integer"
                  },
                  "paletteColors": {
                    "type": "integer"
                  }
                }
              },
              "preview": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "mesh": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "projectFile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}