{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/aginera-ai/json-schema/aginera-ai-cad-file-result-schema.json",
  "title": "CadFileResult",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/aginera-ai-openapi.json#/components/schemas/CadFileResult",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "ready"
          ]
        },
        "document_id": {
          "$ref": "#/$defs/DocumentId"
        },
        "format": {
          "$ref": "#/$defs/CadFormat"
        },
        "requested_format": {
          "$ref": "#/$defs/CadFormat"
        },
        "filename": {
          "type": "string"
        },
        "bytes": {
          "type": "integer"
        },
        "watermarked": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "The free file carries an aginera.ai watermark; null when the server did not say."
        },
        "paid_with_credits": {
          "type": "object",
          "properties": {
            "credits": {
              "type": "integer"
            },
            "credits_remaining": {
              "type": [
                "number",
                "null"
              ]
            }
          },
          "required": [
            "credits",
            "credits_remaining"
          ]
        },
        "download": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string",
              "format": "uri"
            },
            "filename": {
              "type": "string"
            },
            "expires_at": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "url",
            "filename",
            "expires_at"
          ]
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "status",
        "document_id",
        "format",
        "requested_format",
        "filename",
        "bytes",
        "watermarked",
        "download"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "purchase_required"
          ]
        },
        "document_id": {
          "$ref": "#/$defs/DocumentId"
        },
        "format": {
          "$ref": "#/$defs/CadFormat"
        },
        "reason": {
          "type": "string",
          "enum": [
            "download_requires_purchase",
            "dwg_requires_purchase",
            "file_too_large",
            "full_set_requires_purchase"
          ]
        },
        "message": {
          "type": "string"
        },
        "sku": {
          "type": "string",
          "enum": [
            "cad_dwg"
          ]
        },
        "price": {
          "type": "object",
          "properties": {
            "usd_cents": {
              "type": "integer"
            },
            "price_usd": {
              "type": "number"
            },
            "local_currency_note": {
              "type": "string"
            }
          },
          "required": [
            "usd_cents",
            "price_usd",
            "local_currency_note"
          ]
        },
        "credits": {
          "type": "integer",
          "description": "Credits the purchase costs when paid from the balance."
        },
        "credits_available": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether this account can pay it from credits right now (null = not checked)."
        },
        "checkout_url": {
          "type": "string",
          "format": "uri",
          "description": "Stripe checkout for the USER to open and complete. Never complete it on their behalf."
        },
        "checkout_expires_in_hours": {
          "type": "number"
        },
        "size_mb": {
          "type": [
            "number",
            "null"
          ]
        },
        "free_alternative": {
          "type": [
            "string",
            "null"
          ]
        },
        "next_step": {
          "type": "string"
        }
      },
      "required": [
        "status",
        "document_id",
        "format",
        "reason",
        "message",
        "sku",
        "price",
        "credits",
        "credits_available",
        "free_alternative",
        "next_step"
      ]
    }
  ],
  "$defs": {
    "CadFormat": {
      "type": "string",
      "enum": [
        "dxf",
        "dwg"
      ],
      "description": "Format actually delivered (a DWG may fall back to DXF if the DWG writer is unavailable)."
    },
    "DocumentId": {
      "type": "string",
      "pattern": "^doc_[0-9A-Za-z]{22}$"
    }
  }
}