{
  "openapi": "3.1.0",
  "info": {
    "title": "Plondo Foundation API",
    "version": "1.0.0",
    "description": "Public REST API for Plondo Foundation (501(c)(3), EIN 81-3596129): donations, contact, and service status. All errors return structured JSON.",
    "contact": {
      "name": "Plondo Foundation",
      "email": "foundation@plondo.com",
      "url": "https://plondofoundation.org/developers"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://plondofoundation.org",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Service health",
        "description": "Returns overall service status and which integrations are configured. No authentication.",
        "responses": {
          "200": {
            "description": "Service status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    },
    "/api/public-config": {
      "get": {
        "operationId": "getPublicConfig",
        "summary": "Browser-safe configuration",
        "description": "Returns the HTTP-referrer-restricted Google Maps key used by client-side address autocomplete.",
        "responses": {
          "200": {
            "description": "Public config",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "googleMapsApiKey": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "googleMapsApiKey"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/create-payment-intent": {
      "post": {
        "operationId": "createPaymentIntent",
        "summary": "Create a donation",
        "description": "Creates a one-time PaymentIntent or a monthly subscription. Card data is tokenized client-side with Stripe.js; the server only receives a Stripe paymentMethodId. Confirm the returned clientSecret with stripe.confirmCardPayment(). Amounts are capped at 1,000,000 cents ($10,000).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DonationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Intent created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DonationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Payments not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/contact": {
      "post": {
        "operationId": "sendContactMessage",
        "summary": "Send a contact message",
        "description": "Sends a message to the Foundation. Protected by rate limiting and a honeypot field.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Health": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "stripe": {
            "type": "boolean"
          },
          "database": {
            "type": "boolean"
          },
          "twilio": {
            "type": "boolean"
          },
          "smtp": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ]
      },
      "DonationRequest": {
        "type": "object",
        "required": [
          "amount",
          "type",
          "paymentMethodId",
          "email",
          "firstName",
          "lastName"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "minimum": 50,
            "maximum": 1000000,
            "description": "Amount in US cents."
          },
          "type": {
            "type": "string",
            "enum": [
              "One-time",
              "Monthly"
            ]
          },
          "paymentMethodId": {
            "type": "string",
            "description": "Stripe PaymentMethod id from stripe.createPaymentMethod."
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "addressLine2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "postalCode": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code.",
            "default": "US"
          }
        }
      },
      "DonationResponse": {
        "type": "object",
        "properties": {
          "clientSecret": {
            "type": "string"
          },
          "paymentIntentId": {
            "type": "string"
          },
          "subscriptionId": {
            "type": "string"
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "clientSecret"
        ]
      },
      "ContactRequest": {
        "type": "object",
        "required": [
          "name",
          "email",
          "message"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "subject": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error."
          },
          "code": {
            "type": "string",
            "description": "Machine-readable error code."
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}