{
  "openapi": "3.1.0",
  "info": {
    "title": "LeafPay devnet API",
    "version": "1.0.0",
    "description": "Read the LeafPay v2 pool, broadcast signed transactions, and relay recipient-bound withdrawals. Private note data and proof generation remain client-side."
  },
  "servers": [{ "url": "https://leafpay.xyz" }],
  "paths": {
    "/api/v1/status": {
      "get": { "summary": "Service and devnet status", "responses": { "200": { "description": "Service status" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/v1/pool": {
      "get": { "summary": "Current v2 pool state", "responses": { "200": { "description": "Merkle roots, batch leaves, and indexer addresses" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/v1/circuits": {
      "get": { "summary": "Active proving artifacts", "responses": { "200": { "description": "WASM, proving key, and verification key URLs" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/v1/transactions": {
      "post": {
        "summary": "Broadcast a signed LeafPay v2 legacy transaction",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["signedTransaction"], "properties": { "signedTransaction": { "type": "string", "contentEncoding": "base64", "description": "Serialized, fully signed Solana legacy transaction" } } } } } },
        "responses": { "200": { "description": "Submitted transaction signature" }, "400": { "description": "Invalid transaction or simulation failure" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/v1/relay": {
      "get": { "summary": "Relayer availability and public key", "responses": { "200": { "description": "Relayer status" }, "429": { "$ref": "#/components/responses/RateLimited" } } },
      "post": {
        "summary": "Relay a recipient-bound withdrawal",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["identifier", "instructionData"], "properties": { "identifier": { "type": "string", "const": "leafpayv2" }, "instructionData": { "type": "string", "contentEncoding": "base64", "description": "Packed withdraw_on_behalf_shard instruction data, including a Groth16 proof" } } } } } },
        "responses": { "200": { "description": "Confirmed withdrawal signature" }, "400": { "description": "Invalid proof, pool, or instruction" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    }
  },
  "components": { "responses": { "RateLimited": { "description": "Per-IP limit exceeded; retry after the Retry-After header" } } }
}
