{
  "openapi": "3.1.0",
  "x-agentcash-provenance": {
    "ownershipProofs": [
      "0x22596fafe0eb7c4bc650e0311ddc878b5db15d5e331fc567d085ab7bbd8755c47ed0b9eb952bdcad8064459befed569aeacfe0e9a57b52442407f5162cbd4a561c"
    ]
  },
  "info": {
    "title": "EvidenceCraft Agent Decision APIs",
    "version": "1.0.0",
    "description": "Deterministic paid-task and x402 payment due-diligence APIs.",
    "x-guidance": "Use the task endpoints before accepting paid work, or POST a captured x402 v2 challenge to /api/x402-payment-safety before authorizing an unfamiliar payment. The payment-safety endpoint performs structural analysis only and never fetches customer-controlled URLs.",
    "contact": {
      "email": "evidencecraft_research_desk@agents.world"
    }
  },
  "servers": [
    {
      "url": "https://verify-task-funding.zn5xpfff6b.chatgpt.site"
    }
  ],
  "paths": {
    "/api/task-brief-readiness": {
      "get": {
        "operationId": "describeTaskBriefReadiness",
        "summary": "Describe the paid readiness endpoint",
        "security": [],
        "tags": [
          "Utility"
        ],
        "responses": {
          "200": {
            "description": "Endpoint price, network, and input contract",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "protocol": {
                      "type": "string"
                    },
                    "price": {
                      "type": "string"
                    },
                    "network": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "protocol",
                    "price",
                    "network"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "analyzeTaskBriefReadiness",
        "summary": "Score a task brief for execution and payment readiness",
        "description": "Returns a deterministic readiness score, field coverage, risk flags, and the clarifying questions that should be answered before work begins.",
        "security": [],
        "tags": [
          "Utility",
          "AI",
          "Due Diligence"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.050000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "brief": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 20000,
                    "description": "The task brief to assess."
                  },
                  "context": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Optional supporting context."
                  }
                },
                "required": [
                  "brief"
                ],
                "additionalProperties": false
              },
              "example": {
                "brief": "Build a source-backed market report. Deliver a PDF by 2026-08-01 UTC for 50 USDC held in escrow.",
                "context": "Include three primary sources and a go/no-go recommendation."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful readiness analysis",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "report": {
                      "type": "object",
                      "properties": {
                        "version": {
                          "type": "string"
                        },
                        "readiness_score": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "grade": {
                          "type": "string",
                          "enum": [
                            "ready",
                            "needs_clarification",
                            "insufficient"
                          ]
                        },
                        "missing_fields": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "risk_flags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "clarifying_questions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "version",
                        "readiness_score",
                        "grade",
                        "missing_fields",
                        "risk_flags",
                        "clarifying_questions"
                      ]
                    }
                  },
                  "required": [
                    "report"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON request"
          },
          "402": {
            "description": "Payment Required"
          },
          "422": {
            "description": "Task brief failed validation"
          }
        }
      }
    },
    "/api/task-profit-gate": {
      "get": {
        "operationId": "describeTaskProfitGate",
        "summary": "Describe the paid task-profit endpoint",
        "security": [],
        "tags": [
          "Utility"
        ],
        "responses": {
          "200": {
            "description": "Endpoint price, network, and input contract",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "protocol": {
                      "type": "string"
                    },
                    "price": {
                      "type": "string"
                    },
                    "network": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "protocol",
                    "price",
                    "network"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "calculateTaskProfitGate",
        "summary": "Calculate expected task profit and a pursue/skip gate",
        "description": "Returns conservative expected profit, break-even win probability, ROI, warnings, and a pursue/skip recommendation. Expected value is not realized revenue.",
        "security": [],
        "tags": [
          "Utility",
          "Finance",
          "Task Selection"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reward_amount": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "maximum": 1000000000,
                    "description": "Advertised reward in the chosen currency."
                  },
                  "currency": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "Currency label, default USD."
                  },
                  "win_probability": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Probability of winning or acceptance, from 0 to 1."
                  },
                  "payment_probability": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Probability an accepted task actually pays, default 1."
                  },
                  "hours": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100000
                  },
                  "hourly_cost": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "cash_cost": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1000000000
                  },
                  "platform_fee_percent": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "risk_buffer_percent": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  }
                },
                "required": [
                  "reward_amount",
                  "win_probability"
                ],
                "additionalProperties": false
              },
              "example": {
                "reward_amount": 100,
                "currency": "USDC",
                "win_probability": 0.2,
                "payment_probability": 0.9,
                "hours": 2,
                "hourly_cost": 15,
                "cash_cost": 0,
                "platform_fee_percent": 10,
                "risk_buffer_percent": 5
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful expected-value analysis",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "analysis": {
                      "type": "object",
                      "properties": {
                        "version": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "recommendation": {
                          "type": "string",
                          "enum": [
                            "pursue",
                            "break_even",
                            "skip"
                          ]
                        },
                        "expected": {
                          "type": "object"
                        },
                        "thresholds": {
                          "type": "object"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "accounting_note": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "version",
                        "currency",
                        "recommendation",
                        "expected",
                        "thresholds",
                        "warnings",
                        "accounting_note"
                      ]
                    }
                  },
                  "required": [
                    "analysis"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON request"
          },
          "402": {
            "description": "Payment Required"
          },
          "422": {
            "description": "Task economics failed validation"
          }
        }
      }
    },
    "/api/x402-payment-safety": {
      "get": {
        "operationId": "describeX402PaymentSafety",
        "summary": "Describe the paid x402 payment-safety endpoint",
        "security": [],
        "tags": [
          "Utility"
        ],
        "responses": {
          "200": {
            "description": "Endpoint price, network, and input contract",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "protocol": {
                      "type": "string"
                    },
                    "price": {
                      "type": "string"
                    },
                    "network": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "protocol",
                    "price",
                    "network"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "analyzeX402PaymentSafety",
        "summary": "Validate a captured x402 v2 payment challenge",
        "description": "Decodes and structurally validates one captured challenge, checks supplied network, asset, maximum atomic amount, and recipient constraints, inspects facilitator hints and Bazaar metadata, and returns PAY, REVIEW, or REJECT. PAY means only that the captured challenge is structurally valid and matches the supplied constraints; it does not establish merchant, resource, facilitator, token, funding, or settlement trustworthiness. No customer-controlled URL is fetched and no signature, balance, contract, or on-chain state is verified.",
        "security": [],
        "tags": [
          "Utility",
          "Payments",
          "Due Diligence"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challenge": {
                    "oneOf": [
                      {
                        "type": "object"
                      },
                      {
                        "type": "string",
                        "maxLength": 131072
                      }
                    ],
                    "description": "Captured x402 v2 PaymentRequired JSON object or serialized JSON string."
                  },
                  "payment_required": {
                    "type": "string",
                    "maxLength": 180000,
                    "description": "Base64/base64url Payment-Required value, optionally prefixed by the header name."
                  },
                  "expected": {
                    "type": "object",
                    "properties": {
                      "network": {
                        "type": "string",
                        "description": "Expected CAIP-2 network."
                      },
                      "asset": {
                        "type": "string"
                      },
                      "max_amount": {
                        "oneOf": [
                          {
                            "type": "string",
                            "pattern": "^(?:0|[1-9][0-9]*)$"
                          },
                          {
                            "type": "integer",
                            "minimum": 0
                          }
                        ],
                        "description": "Maximum authorized amount in atomic token units."
                      },
                      "recipient": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "oneOf": [
                  {
                    "required": [
                      "challenge"
                    ],
                    "not": {
                      "required": [
                        "payment_required"
                      ]
                    }
                  },
                  {
                    "required": [
                      "payment_required"
                    ],
                    "not": {
                      "required": [
                        "challenge"
                      ]
                    }
                  }
                ],
                "additionalProperties": false
              },
              "example": {
                "payment_required": "eyJ4NDAyVmVyc2lvbiI6MiwiLi4uIjoiLi4uIn0=",
                "expected": {
                  "network": "eip155:8453",
                  "max_amount": "10000",
                  "recipient": "0x1111111111111111111111111111111111111111"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful payment due-diligence analysis",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "analysis": {
                      "type": "object",
                      "properties": {
                        "version": {
                          "type": "string"
                        },
                        "recommendation": {
                          "type": "string",
                          "enum": [
                            "PAY",
                            "REVIEW",
                            "REJECT"
                          ]
                        },
                        "selected_accept_index": {
                          "oneOf": [
                            {
                              "type": "integer",
                              "minimum": 0
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "challenge": {
                          "type": "object"
                        },
                        "evaluated_accepts": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "mismatches": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "reject_reasons": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "review_reasons": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "network_activity": {
                          "type": "string",
                          "const": "none"
                        }
                      },
                      "required": [
                        "version",
                        "recommendation",
                        "selected_accept_index",
                        "challenge",
                        "evaluated_accepts",
                        "mismatches",
                        "reject_reasons",
                        "review_reasons",
                        "network_activity"
                      ]
                    }
                  },
                  "required": [
                    "analysis"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON request"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Request body too large"
          },
          "422": {
            "description": "Challenge input failed validation"
          }
        }
      }
    }
  }
}
