{
  "openapi": "3.1.0",
  "info": {
    "title": "Donorbox Agent API",
    "version": "1.0.0",
    "description": "Machine Payments Protocol (MPP) donation endpoints for AI agents."
  },
  "x-service-info": {
    "categories": ["donations", "nonprofit"]
  },
  "paths": {
    "/api/agent/donate": {
      "post": {
        "summary": "Donate to an agentic campaign via MPP",
        "description": "First request without an Authorization credential returns 402 with a Payment challenge. Retry with Authorization: Payment <credential> containing a Stripe Shared Payment Token (SPT). Query amount is in major currency units (e.g. 10.0 for $10); the challenge request.amount is the minor-unit integer string.",
        "operationId": "agentDonate",
        "parameters": [
          {
            "name": "campaignId",
            "in": "query",
            "required": true,
            "schema": { "type": "integer" },
            "description": "Agentic-eligible campaign (form) id"
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "schema": { "type": "string" },
            "description": "Donation amount in major currency units (e.g. \"10.0\")"
          },
          {
            "name": "donorFirstName",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          },
          {
            "name": "donorLastName",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          },
          {
            "name": "donorEmail",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "format": "email" }
          },
          {
            "name": "notes",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          }
        ],
        "x-payment-info": {
          "offers": [
            {
              "amount": null,
              "currency": "usd",
              "description": "One-time donation charged via Stripe Shared Payment Token. Amount and networkId come from the 402 challenge.",
              "intent": "charge",
              "method": "stripe"
            }
          ]
        },
        "responses": {
          "200": {
            "description": "Donation succeeded"
          },
          "402": {
            "description": "Payment Required — WWW-Authenticate Payment challenge"
          },
          "400": {
            "description": "Invalid campaign or amount"
          }
        }
      },
      "get": {
        "summary": "Donate to an agentic campaign via MPP (GET)",
        "description": "Same MPP handshake as POST. Browsers with Accept: text/html are redirected to the hosted donation form.",
        "operationId": "agentDonateGet",
        "parameters": [
          {
            "name": "campaignId",
            "in": "query",
            "required": true,
            "schema": { "type": "integer" }
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "x-payment-info": {
          "offers": [
            {
              "amount": null,
              "currency": "usd",
              "description": "One-time donation charged via Stripe Shared Payment Token. Amount and networkId come from the 402 challenge.",
              "intent": "charge",
              "method": "stripe"
            }
          ]
        },
        "responses": {
          "200": {
            "description": "Donation succeeded"
          },
          "302": {
            "description": "Browser redirect to hosted donation form"
          },
          "402": {
            "description": "Payment Required — WWW-Authenticate Payment challenge"
          },
          "400": {
            "description": "Invalid campaign or amount"
          }
        }
      }
    },
    "/api/agent/campaigns": {
      "get": {
        "summary": "List or search agentic-eligible campaigns",
        "operationId": "agentCampaignsIndex",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Optional free-text search"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 1 }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated campaign list"
          }
        }
      }
    },
    "/api/agent/campaigns/{id}": {
      "get": {
        "summary": "Show a single agentic-eligible campaign",
        "operationId": "agentCampaignsShow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "integer" }
          }
        ],
        "responses": {
          "200": {
            "description": "Campaign details"
          },
          "404": {
            "description": "Campaign not found or not agent-eligible"
          }
        }
      }
    }
  }
}
