{
  "openapi": "3.0.3",
  "info": {
    "title": "ParseFlow Task Submission API",
    "version": "1.0.0",
    "description": "Submit raw developer data for a free preview and optional paid artifact fulfillment."
  },
  "servers": [
    {
      "url": "http://138.68.190.61"
    }
  ],
  "paths": {
    "/api/v1/submit-task": {
      "post": {
        "summary": "Submit a task for parsing and transformation",
        "operationId": "submitTask",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitTaskRequest"
              },
              "example": {
                "title": "Normalize nested JSON",
                "description": "Flatten customer orders into rows",
                "raw_data": {
                  "customers": [
                    {
                      "id": "c1",
                      "orders": [
                        {
                          "id": "o1"
                        }
                      ]
                    }
                  ]
                },
                "artifact": "json"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Task accepted with free preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SubmitTaskRequest": {
        "type": "object",
        "required": [
          "title",
          "description",
          "raw_data"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 160
          },
          "description": {
            "type": "string",
            "maxLength": 4000
          },
          "raw_data": {
            "description": "Raw JSON-compatible data to ingest and analyze",
            "oneOf": [
              {
                "type": "object"
              },
              {
                "type": "array"
              },
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "artifact": {
            "type": "string",
            "description": "Optional artifact family, such as json or csv"
          }
        }
      },
      "FreePreview": {
        "type": "object",
        "required": [
          "status",
          "summary",
          "sample"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "preview"
            ]
          },
          "summary": {
            "type": "string"
          },
          "sample": {
            "description": "A bounded, sanitized sample of the proposed result"
          },
          "limitations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PaymentGate": {
        "type": "object",
        "required": [
          "status",
          "amount_usd",
          "tokens",
          "network",
          "standard"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "payment_required",
              "verified"
            ]
          },
          "amount_usd": {
            "type": "string",
            "example": "19.99"
          },
          "tokens": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "USDT",
                "USDC"
              ]
            }
          },
          "network": {
            "type": "string",
            "example": "BSC"
          },
          "standard": {
            "type": "string",
            "example": "BEP-20"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "TaskResponse": {
        "type": "object",
        "required": [
          "ok",
          "task_id",
          "preview",
          "payment_gate"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "task_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "preview_ready"
            ]
          },
          "preview": {
            "$ref": "#/components/schemas/FreePreview"
          },
          "payment_gate": {
            "$ref": "#/components/schemas/PaymentGate"
          }
        }
      }
    }
  }
}
