{
  "openapi": "3.1.0",
  "info": {
    "title": "Agent Decision Gate API",
    "version": "0.1.0-preview",
    "summary": "Branch-aware compute governor with verifiable decision receipts.",
    "description": "Agent Decision Gate evaluates autonomous-agent execution branches and returns deterministic decisions with tamper-evident receipts. Use it for agent branch evaluation, runtime checkpoint decisions, compute guardrails, payment preflight, claim audit preflight, and execution receipt verification."
  },
  "servers": [
    {
      "url": "https://agentdecisiongate.com"
    }
  ],
  "paths": {
    "/.well-known/agent.json": {
      "get": {
        "operationId": "getAgentServiceIndex",
        "summary": "Discover the service, trust boundary, primary endpoint, and absolute integration links.",
        "responses": {
          "200": {
            "description": "Canonical agent-facing service index"
          }
        }
      }
    },
    "/v1/service-index.json": {
      "get": {
        "operationId": "getVersionedServiceIndex",
        "summary": "Return the versioned alias of the canonical agent-facing service index.",
        "responses": {
          "200": {
            "description": "Agent-facing service index"
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Service status"
          }
        }
      }
    },
    "/v1/pricing": {
      "get": {
        "operationId": "getPricing",
        "responses": {
          "200": {
            "description": "Preview pricing and planned paid endpoints"
          }
        }
      }
    },
    "/v1/capabilities": {
      "get": {
        "operationId": "getCapabilities",
        "summary": "Describe agent-facing capabilities and search phrases.",
        "responses": {
          "200": {
            "description": "Capabilities document"
          }
        }
      }
    },
    "/v1/trust.json": {
      "get": {
        "operationId": "getTrust",
        "summary": "Describe the preview trust model, verification rules, and limitations.",
        "responses": {
          "200": {
            "description": "Trust model document"
          }
        }
      }
    },
    "/v1/examples": {
      "get": {
        "operationId": "getExamples",
        "summary": "List scenario fixtures and expected decisions for quick agent integration.",
        "responses": {
          "200": {
            "description": "Integration examples"
          }
        }
      }
    },
    "/v1/branches/evaluate": {
      "post": {
        "operationId": "evaluateBranch",
        "summary": "Evaluate whether an agent branch should continue, stop, prune, or escalate.",
        "parameters": [
          {
            "name": "persist",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Persist the receipt to configured D1/R2 bindings."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "https://agentdecisiongate.com/contracts/branch-evaluation-request.schema.json"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "request": {
                        "$ref": "https://agentdecisiongate.com/contracts/branch-evaluation-request.schema.json"
                      },
                      "policy": {
                        "$ref": "https://agentdecisiongate.com/contracts/policy.schema.json"
                      }
                    },
                    "required": [
                      "request"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Branch decision and receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://agentdecisiongate.com/contracts/branch-evaluation-response.schema.json"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "402": {
            "description": "Payment required. In ADG_PAYMENT_MODE=mock this includes a PAYMENT-REQUIRED header with x402-style payment instructions."
          },
          "409": {
            "description": "Receipt id, object, or chain-head conflict"
          },
          "503": {
            "description": "D1/R2 storage bindings unavailable"
          }
        }
      }
    },
    "/v1/receipts/verify": {
      "post": {
        "operationId": "verifyReceipt",
        "summary": "Verify a tamper-evident Agent Decision Gate receipt.",
        "responses": {
          "200": {
            "description": "Verification result"
          },
          "400": {
            "description": "Invalid receipt payload"
          }
        }
      }
    },
    "/v1/receipts/{receipt_id}": {
      "get": {
        "operationId": "getReceipt",
        "summary": "Get public receipt metadata and storage verification by receipt id.",
        "parameters": [
          {
            "name": "receipt_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public receipt verification view"
          },
          "404": {
            "description": "Receipt not found or not public"
          },
          "503": {
            "description": "D1/R2 storage bindings unavailable"
          }
        }
      }
    },
    "/v1/receipts/by-hash/{integrity_hash}": {
      "get": {
        "operationId": "getReceiptByHash",
        "summary": "Get public receipt metadata by integrity hash.",
        "parameters": [
          {
            "name": "integrity_hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public receipt verification view"
          },
          "404": {
            "description": "Receipt not found or not public"
          },
          "503": {
            "description": "D1/R2 storage bindings unavailable"
          }
        }
      }
    }
  }
}