{
 "openapi": "3.1.0",
 "info": {
  "title": "stl2step API",
  "version": "1.0.0",
  "summary": "Convert STL, OBJ and PLY meshes into STEP solids with real CAD faces.",
  "description": "Anyone can preview a conversion without an account: upload a mesh (or send its URL), poll the status, look at the PNG. The person downloads the STEP at `claim_url` with a purchased credit or a one-off payment of $5. Authentication: https://stl2step.ai/auth.md. Guide for agents: https://stl2step.ai/agents. No commercial conversion, file-size or triangle quota. Large previews are simplified automatically; paid processing uses the original. The legacy file POST accepts 50 MB; larger files use the resumable /v1/uploads routes.",
  "termsOfService": "https://stl2step.ai/legal",
  "contact": {
   "name": "stl2step",
   "url": "https://stl2step.ai/agents"
  }
 },
 "servers": [
  {
   "url": "https://boredinigo--stl2step-api.us-east.modal.run"
  }
 ],
 "externalDocs": {
  "description": "stl2step for AI agents",
  "url": "https://stl2step.ai/agents"
 },
 "tags": [
  {
   "name": "preview",
   "description": "Conversions without an account"
  },
  {
   "name": "account",
   "description": "Operations on a person's account"
  },
  {
   "name": "service",
   "description": "Prices, limits and health"
  }
 ],
 "paths": {
  "/health": {
   "get": {
    "operationId": "health",
    "tags": [
     "service"
    ],
    "summary": "Whether the API is up",
    "security": [],
    "responses": {
     "200": {
      "description": "Up",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/catalog": {
   "get": {
    "operationId": "getCatalog",
    "tags": [
     "service"
    ],
    "summary": "Plans, packs, prices (USD cents) and limits",
    "security": [],
    "responses": {
     "200": {
      "description": "The public catalog",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/preview": {
   "post": {
    "operationId": "createPreview",
    "tags": [
     "preview"
    ],
    "security": [],
    "summary": "Convert a mesh without an account",
    "description": "Send the file as the multipart field `file`, or JSON with a public `url`. The same bytes converted before return the finished result at once (200, `cached: true`) and do not count against the limits.",
    "requestBody": {
     "required": true,
     "content": {
      "multipart/form-data": {
       "schema": {
        "type": "object",
        "properties": {
         "file": {
          "type": "string",
          "format": "binary",
          "description": "STL, OBJ or PLY mesh"
         },
         "url": {
          "type": "string",
          "format": "uri",
          "description": "Instead of `file`: a public URL of the mesh"
         }
        }
       }
      },
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string",
          "format": "uri",
          "description": "Public http(s) URL of the mesh; downloaded with the same limits."
         },
         "filename": {
          "type": "string",
          "description": "Name to keep for the file (optional)."
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Already converted: the finished result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Preview"
        }
       }
      }
     },
     "202": {
      "description": "Queued: poll GET /v1/preview/{code} every 3 seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Preview"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "413": {
      "$ref": "#/components/responses/Error"
     },
     "415": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     }
    }
   }
  },
  "/v1/preview/{code}": {
   "get": {
    "operationId": "getPreview",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "description": "The preview code, e.g. K7P3M9X2QR.",
      "schema": {
       "type": "string",
       "maxLength": 40
      }
     }
    ],
    "summary": "Status of a preview (poll every 3 seconds until done or error)",
    "responses": {
     "200": {
      "description": "The preview",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Preview"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/preview/{code}/png": {
   "get": {
    "operationId": "getPreviewPng",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "description": "The preview code, e.g. K7P3M9X2QR.",
      "schema": {
       "type": "string",
       "maxLength": 40
      }
     }
    ],
    "summary": "Six views of the result coloured by surface type",
    "responses": {
     "200": {
      "description": "PNG",
      "content": {
       "image/png": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/preview/{code}/view": {
   "get": {
    "operationId": "getPreviewView",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "description": "The preview code, e.g. K7P3M9X2QR.",
      "schema": {
       "type": "string",
       "maxLength": 40
      }
     }
    ],
    "summary": "The mesh-and-faces file the stl2step 3D viewer loads",
    "responses": {
     "200": {
      "description": "Binary view file",
      "content": {
       "application/octet-stream": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/preview/{code}/checkout": {
   "post": {
    "operationId": "createPreviewCheckout",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "description": "The preview code, e.g. K7P3M9X2QR.",
      "schema": {
       "type": "string",
       "maxLength": 40
      }
     }
    ],
    "summary": "Stripe Checkout link for the person to buy this STEP without an account ($5)",
    "description": "Returns a URL for the person to open and pay in their browser. After paying, Stripe sends them to the claim page, which downloads the STEP.",
    "requestBody": {
     "required": false,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "email": {
          "type": "string",
          "format": "email",
          "description": "Pre-fills the checkout (optional)"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Checkout URL",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string",
           "format": "uri"
          }
         }
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/preview/{code}/step": {
   "get": {
    "operationId": "getPreviewStep",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "description": "The preview code, e.g. K7P3M9X2QR.",
      "schema": {
       "type": "string",
       "maxLength": 40
      }
     },
     {
      "name": "session_id",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 255
      },
      "description": "Id of the paid Stripe Checkout session for this code"
     }
    ],
    "summary": "Download the STEP after the one-off payment",
    "responses": {
     "200": {
      "description": "STEP file",
      "content": {
       "application/step": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "402": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/claim": {
   "post": {
    "operationId": "claimPreview",
    "tags": [
     "account"
    ],
    "security": [
     {
      "account": []
     }
    ],
    "summary": "Add a preview to the signed-in account (charges its normal credit cost once)",
    "description": "Usually done by the claim page in the person's browser. A second claim of the same code by the same account returns the same job and charges nothing.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "code"
        ],
        "properties": {
         "code": {
          "type": "string",
          "maxLength": 40
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The job in the account",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "status": {
           "type": "string"
          },
          "cost": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "402": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "413": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/mcp": {
   "post": {
    "operationId": "mcp",
    "tags": [
     "preview"
    ],
    "security": [],
    "summary": "Model Context Protocol server (streamable HTTP, stateless, JSON responses)",
    "description": "JSON-RPC messages of MCP. Tools: preview_mesh, get_preview, check_mesh, get_pricing. Server card: https://stl2step.ai/.well-known/mcp.json",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "JSON-RPC response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "202": {
      "description": "Notification accepted"
     }
    }
   }
  },
  "/v1/uploads": {
   "post": {
    "operationId": "startMultipartUpload",
    "tags": [
     "preview"
    ],
    "security": [
     {},
     {
      "account": []
     }
    ],
    "summary": "Start a private resumable upload; file bytes go directly to signed S3 parts",
    "description": "No account required. A bearer JWT assigns the upload to its owner for POST /v1/jobs. Keep the returned capability token private; it expires in 48 hours. The 5 TiB maximum is the S3 protocol ceiling.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "filename",
         "size"
        ],
        "properties": {
         "filename": {
          "type": "string",
          "maxLength": 255
         },
         "size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5497558138880
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Upload capability and required part size",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "token": {
           "type": "string"
          },
          "part_size": {
           "type": "integer"
          },
          "parts": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/uploads/{upload_id}/part": {
   "post": {
    "operationId": "signUploadPart",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "upload_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 36
      }
     }
    ],
    "summary": "Sign one numbered part, then PUT exactly its bytes to the returned URL",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "token",
         "number"
        ],
        "properties": {
         "token": {
          "type": "string",
          "minLength": 32,
          "maxLength": 128
         },
         "number": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Signed URL (part) or upload receipt (complete/status)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string",
           "format": "uri"
          }
         }
        }
       }
      }
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/uploads/{upload_id}/complete": {
   "post": {
    "operationId": "completeMultipartUpload",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "upload_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 36
      }
     }
    ],
    "summary": "Verify uploaded parts and start anonymous ingestion; safe to retry",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "token"
        ],
        "properties": {
         "token": {
          "type": "string",
          "minLength": 32,
          "maxLength": 128
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Signed URL (part) or upload receipt (complete/status)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "status": {
           "type": "string"
          },
          "code": {
           "type": [
            "string",
            "null"
           ]
          },
          "error": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/uploads/{upload_id}/status": {
   "post": {
    "operationId": "getUploadStatus",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "upload_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 36
      }
     }
    ],
    "summary": "Poll ingestion; once code is present, poll the normal preview route",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "token"
        ],
        "properties": {
         "token": {
          "type": "string",
          "minLength": 32,
          "maxLength": 128
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Signed URL (part) or upload receipt (complete/status)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "status": {
           "type": "string"
          },
          "code": {
           "type": [
            "string",
            "null"
           ]
          },
          "error": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/preview/{code}/delivery": {
   "get": {
    "operationId": "getOriginalDelivery",
    "tags": [
     "preview"
    ],
    "security": [],
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "description": "The preview code, e.g. K7P3M9X2QR.",
      "schema": {
       "type": "string",
       "maxLength": 40
      }
     },
     {
      "name": "session_id",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 255
      }
     }
    ],
    "summary": "Confirm payment and poll original-resolution fulfillment",
    "responses": {
     "200": {
      "description": "pending, ready, refund_pending or refunded; only ready permits download",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "state": {
           "type": "string",
           "enum": [
            "pending",
            "ready",
            "refund_pending",
            "refunded"
           ]
          },
          "result": {
           "anyOf": [
            {
             "$ref": "#/components/schemas/Preview"
            },
            {
             "type": "null"
            }
           ]
          }
         }
        }
       }
      }
     },
     "402": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "account": {
    "type": "http",
    "scheme": "bearer",
    "bearerFormat": "JWT",
    "description": "A 15-minute JWT of the person's stl2step account, created by the signed-in web app. Agents do not get accounts: see https://stl2step.ai/auth.md."
   }
  },
  "schemas": {
   "Preview": {
    "type": "object",
    "properties": {
     "code": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "queued",
       "running",
       "done",
       "error"
      ]
     },
     "cached": {
      "type": "boolean"
     },
     "filename": {
      "type": [
       "string",
       "null"
      ]
     },
     "triangles": {
      "type": [
       "integer",
       "null"
      ]
     },
     "phase": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "queued",
       "loading",
       "segmenting",
       "fitting",
       "building",
       "writing",
       "publishing",
       null
      ],
      "description": "Where a queued / running conversion is; null once done or failed"
     },
     "started_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "phase_started_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "phase_percent": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 0,
      "maximum": 100,
      "description": "Percentage of CAD faces processed in the building phase, when available"
     },
     "estimated_seconds": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Expected duration, with a margin"
     },
     "decimated_from": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Uploaded triangle count when the mesh was decimated before converting"
     },
     "decimate_offered": {
      "type": "boolean",
      "description": "The mesh is big enough that `decimate` on upload would speed it up"
     },
     "original_required": {
      "type": "boolean",
      "description": "This simplified preview starts original-resolution processing after payment; poll its delivery route before downloading"
     },
     "step_built": {
      "type": "boolean",
      "description": "Done with a STEP file; false while running, on error, or when only the faces could be delivered"
     },
     "step_error": {
      "type": [
       "string",
       "null"
      ],
      "description": "Why there is no STEP (done without one)"
     },
     "report": {
      "type": [
       "object",
       "null"
      ],
      "description": "Faces, faces and area by surface type, deviation, seconds"
     },
     "png_url": {
      "type": [
       "string",
       "null"
      ],
      "format": "uri"
     },
     "view_url": {
      "type": [
       "string",
       "null"
      ],
      "format": "uri"
     },
     "claim_url": {
      "type": "string",
      "format": "uri",
      "description": "Where the person gets the STEP"
     },
     "price_single_usd": {
      "type": "number"
     },
     "error": {
      "type": [
       "string",
       "null"
      ]
     },
     "error_code": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "Error": {
    "type": "object",
    "properties": {
     "detail": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      }
     }
    }
   }
  },
  "responses": {
   "Error": {
    "description": "Error with a machine-readable code",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "RateLimited": {
    "description": "`rate_limited` (per IP) or `busy` (all slots in use)",
    "headers": {
     "Retry-After": {
      "schema": {
       "type": "integer"
      },
      "description": "Seconds to wait"
     }
    },
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   }
  }
 }
}
