{
  "openapi": "3.1.0",
  "info": {
    "title": "Proof21 API \u2014 design draft",
    "version": "0.1.0-draft",
    "description": "Not deployed. Structural design only; signing profiles and production authentication/payment policy are not finalized. No funds may depend on this draft."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:8787",
      "description": "Reserved for future local development; no server included."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Operational health only; not verification correctness."
          }
        }
      }
    },
    "/v0/evaluations": {
      "post": {
        "operationId": "createEvaluation",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EvaluationRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Evaluation accepted as a job; not a successful verdict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency key conflicts with request digest.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Input exceeds limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Processing or availability failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v0/verifications": {
      "post": {
        "operationId": "verifyReport",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerificationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification results; acceptance remains local.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Unable to process.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v0/jobs/{jobId}": {
      "get": {
        "operationId": "getJob",
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current job state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "Job unavailable to this caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Unable to process.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "maxLength": 80
          },
          "message": {
            "type": "string",
            "maxLength": 1024
          }
        }
      },
      "EvidenceReference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "kind": {
            "type": "string",
            "enum": [
              "issuer_assertion",
              "signed_observation",
              "rpc_observation",
              "inclusion_proof",
              "validated_state",
              "reproduced_calculation"
            ]
          },
          "digest": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "uri": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "Untrusted reference; fetching requires explicit server policy."
          },
          "network": {
            "type": "string",
            "maxLength": 128
          }
        }
      },
      "EvaluationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "profile",
          "operationId",
          "instructionDigest",
          "policyDigest",
          "evidence"
        ],
        "properties": {
          "profile": {
            "type": "string",
            "enum": [
              "p21.payment-conformance/0.1-draft",
              "p21.dmt-derivation/0.1-draft"
            ]
          },
          "operationId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "instructionDigest": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "policyDigest": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "evidence": {
            "type": "array",
            "minItems": 1,
            "maxItems": 64,
            "items": {
              "$ref": "#/components/schemas/EvidenceReference"
            }
          }
        }
      },
      "Job": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "jobId",
          "status"
        ],
        "properties": {
          "jobId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "status": {
            "type": "string",
            "enum": [
              "QUEUED",
              "RUNNING",
              "COMPLETE",
              "FAILED"
            ]
          },
          "evaluation": {
            "type": "string",
            "enum": [
              "PASS",
              "FAIL",
              "INDETERMINATE"
            ]
          },
          "limitations": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "type": "string",
              "maxLength": 2048
            }
          }
        }
      },
      "VerificationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact",
          "expectedOperationId",
          "expectedIssuer"
        ],
        "properties": {
          "artifact": {
            "type": "string",
            "maxLength": 1048576,
            "description": "Encoded original artifact; wire/signing profile not finalized."
          },
          "expectedOperationId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "expectedIssuer": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          }
        }
      },
      "VerificationResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "integrity",
          "evaluation",
          "reasons"
        ],
        "properties": {
          "integrity": {
            "type": "string",
            "enum": [
              "VALID",
              "INVALID",
              "UNRESOLVED"
            ]
          },
          "evaluation": {
            "type": "string",
            "enum": [
              "PASS",
              "FAIL",
              "INDETERMINATE"
            ]
          },
          "reasons": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "type": "string",
              "maxLength": 2048
            }
          }
        }
      }
    }
  },
  "x-proof21-status": "design-only-not-implemented"
}
