{
  "openapi": "3.0.3",
  "info": {
    "title": "Piggy Ledger Public Service & Discovery API",
    "version": "1.0.0",
    "description": "Public machine-readable API, agent commerce endpoints, and RFC 9727 service catalog for Piggy Ledger - Smart Personal Finance & Budget Ecosystem.",
    "termsOfService": "https://piggyapp.top/terms",
    "contact": {
      "name": "Piggy Ledger Developer Support",
      "url": "https://piggyapp.top/",
      "email": "contact@piggyapp.top"
    },
    "license": {
      "name": "Apache-2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "x-service-info": {
    "categories": [
      "finance",
      "commerce",
      "budgeting",
      "productivity"
    ],
    "protocols": [
      "acp",
      "ap2",
      "mpp",
      "ucp",
      "x402"
    ]
  },
  "servers": [
    {
      "url": "https://piggyapp.top",
      "description": "Production Server"
    }
  ],
  "paths": {
    "/.well-known/api-catalog": {
      "get": {
        "summary": "RFC 9727 API Catalog",
        "description": "Machine-readable catalog of Piggy Ledger APIs and documentation conforming to RFC 9727.",
        "operationId": "getApiCatalog",
        "responses": {
          "200": {
            "description": "Successful linkset catalog response",
            "content": {
              "application/linkset+json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "linkset": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "summary": "Service Health Check",
        "description": "Returns operational health status of Piggy Ledger web services.",
        "operationId": "getHealthStatus",
        "responses": {
          "200": {
            "description": "Service is healthy and operational",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "service": {
                      "type": "string",
                      "example": "Piggy Ledger"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pay": {
      "post": {
        "summary": "Machine Payment Protocol (MPP) & x402 Payment Gateway",
        "description": "Payable endpoint for AI agent micropayments and subscription access per MPP and x402 standards.",
        "operationId": "processAgentPayment",
        "x-payment-info": {
          "intent": "charge",
          "method": "stripe",
          "amount": "5.00",
          "currency": "USD",
          "description": "Piggy Ledger Pro Agent Access & Financial Intelligence License"
        },
        "responses": {
          "200": {
            "description": "Payment successfully authorized and settled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "paid" },
                    "receipt": { "type": "string", "example": "rec_agent_9918" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment Required (x402 / L402 protocol specification)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "integer", "example": 402 },
                    "error": { "type": "string", "example": "Payment Required" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "summary": "Agent Commerce Checkout",
        "description": "ACP and UCP checkout session creation for automated agent purchases.",
        "operationId": "createCheckoutSession",
        "x-payment-info": {
          "intent": "session",
          "method": "card",
          "amount": "9.99",
          "currency": "USD",
          "description": "Piggy Ledger Premium Plan Subscription Checkout"
        },
        "responses": {
          "200": {
            "description": "Checkout session initialized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checkout_url": { "type": "string" },
                    "session_id": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/premium/insights": {
      "get": {
        "summary": "Premium AI Financial Insights (Paid Resource)",
        "description": "Protected premium endpoint requiring micropayment via x402 or MPP token.",
        "operationId": "getPremiumInsights",
        "x-payment-info": {
          "intent": "charge",
          "method": "tempo",
          "amount": "1.00",
          "currency": "USD",
          "description": "Real-time AI Budget Optimization & Wealth Growth Analysis"
        },
        "responses": {
          "200": {
            "description": "Premium analytics payload returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        }
      }
    }
  }
}
