{
  "openapi": "3.1.0",
  "info": {
    "title": "TryFive Human Feedback",
    "version": "1.0.0",
    "description": "Order one or five independent human responses to the same brief, up to five questions, and an optional sandbox task."
  },
  "servers": [
    {
      "url": "https://tryfive.dev"
    }
  ],
  "paths": {
    "/api/v1/availability": {
      "get": {
        "operationId": "getPaymentAvailability",
        "summary": "Check enabled payment methods before submitting a brief",
        "responses": {
          "200": {
            "description": "Enabled Stripe and x402 methods",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "stripe": {
                      "type": "boolean"
                    },
                    "x402": {
                      "type": "boolean"
                    },
                    "stripeMode": {
                      "enum": [
                        null,
                        "test",
                        "live"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/{orderId}": {
      "get": {
        "operationId": "getHumanFeedbackOrder",
        "summary": "Check order status and retrieve individual responses",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Private, client-generated random UUID v4. Reuse when retrying the same request."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order status and completed results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "404": {
            "description": "Unknown order"
          }
        }
      }
    },
    "/api/v1/x402/first-try": {
      "post": {
        "operationId": "purchaseFirstTry",
        "summary": "Buy 1 independent human response(s) for 1 USDC",
        "description": "Check availability first. Send the same JSON brief before and after the x402 challenge. The first try is limited to one per paying Base address. Do not start a second payment while settlement is pending.",
        "parameters": [
          {
            "in": "header",
            "name": "PAYMENT-SIGNATURE",
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment authorization on retry."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Brief"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payment settled, human test queued",
            "headers": {
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "202": {
            "description": "Settlement pending, poll the existing order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "400": {
            "description": "Invalid order input"
          },
          "402": {
            "description": "Base USDC payment required",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "Existing trial, reused authorization, or conflicting order ID"
          },
          "503": {
            "description": "Checkout disabled or temporarily unavailable"
          }
        }
      }
    },
    "/api/v1/x402/full-round": {
      "post": {
        "operationId": "purchaseFullRound",
        "summary": "Buy 5 independent human response(s) for 9 USDC",
        "description": "Check availability first. Send the same JSON brief before and after the x402 challenge. The first try is limited to one per paying Base address. Do not start a second payment while settlement is pending.",
        "parameters": [
          {
            "in": "header",
            "name": "PAYMENT-SIGNATURE",
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment authorization on retry."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Brief"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payment settled, human test queued",
            "headers": {
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "202": {
            "description": "Settlement pending, poll the existing order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "400": {
            "description": "Invalid order input"
          },
          "402": {
            "description": "Base USDC payment required",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "Existing trial, reused authorization, or conflicting order ID"
          },
          "503": {
            "description": "Checkout disabled or temporarily unavailable"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Brief": {
        "type": "object",
        "required": [
          "orderId",
          "context",
          "questions"
        ],
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid",
            "description": "Private, client-generated random UUID v4. Reuse when retrying the same request."
          },
          "context": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2500
          },
          "questions": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 350
            }
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "description": "Optional public HTTPS endpoint receiving a signed round.completed event."
          },
          "sandbox": {
            "type": "object",
            "required": [
              "url",
              "task"
            ],
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              "task": {
                "type": "string",
                "minLength": 1,
                "maxLength": 700
              }
            }
          }
        }
      },
      "Order": {
        "type": "object",
        "required": [
          "orderId",
          "plan",
          "participants",
          "status"
        ],
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid",
            "description": "Private, client-generated random UUID v4. Reuse when retrying the same request."
          },
          "plan": {
            "enum": [
              "first-try",
              "full-round"
            ]
          },
          "participants": {
            "enum": [
              1,
              5
            ]
          },
          "status": {
            "enum": [
              "awaiting_payment",
              "settlement_pending",
              "paid",
              "completed",
              "expired"
            ]
          },
          "statusUrl": {
            "type": "string",
            "format": "uri"
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri"
          },
          "webhookSecret": {
            "type": "string",
            "description": "Private HMAC-SHA256 signing secret when a completion webhook is configured."
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri",
            "description": "Stripe continuation URL on an awaiting card order."
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "answers"
              ],
              "properties": {
                "answers": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "completed": {
                  "type": "boolean"
                },
                "blocker": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
