{
  "openapi": "3.1.0",
  "info": {
    "title": "TensorPM API",
    "version": "1.0.0",
    "description": "TensorPM commerce + credit endpoints (proxy) and local A2A endpoint (desktop). The MCP server is described separately at /.well-known/mcp/server-card.json. For end-user pricing rules see /PRICING.md.",
    "contact": {
      "name": "TensorPM Support",
      "email": "support@tensorpm.com",
      "url": "https://tensorpm.com/contact"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://tensorpm.com/legal/terms"
    },
    "x-anthropic": {
      "agentReady": true,
      "skill": "https://tensorpm.com/SKILL.md"
    },
    "x-openai": {
      "isConsequential": false
    }
  },
  "servers": [
    {
      "url": "https://api.tensorpm.com",
      "description": "TensorPM Proxy (cloud) — auth, billing, credits, AI proxy"
    },
    {
      "url": "http://localhost:37850",
      "description": "TensorPM Desktop A2A endpoint (local-only, requires desktop app running)"
    }
  ],
  "tags": [
    { "name": "credits", "description": "Credit balance and plan allowances" },
    { "name": "subscriptions", "description": "Stripe-backed subscription lifecycle" },
    {
      "name": "acp",
      "description": "Agentic Commerce Protocol — programmatic catalog and checkout for agents"
    },
    { "name": "a2a", "description": "Agent-to-Agent JSON-RPC 2.0 (local desktop)" },
    { "name": "discovery", "description": "Well-known agent and MCP discovery resources" }
  ],
  "paths": {
    "/api/credits": {
      "get": {
        "tags": ["credits"],
        "summary": "Get current credit balance and monthly allowance",
        "description": "Returns the authenticated user's credit balance, Trial lifetime allowance or monthly Pro allowance (if any), and recent usage. Pro monthly credits reset on the 1st UTC.",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": {
            "description": "Credit summary",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CreditSummary" }
              }
            }
          }
        }
      }
    },
    "/acp/catalog": {
      "get": {
        "tags": ["acp"],
        "summary": "Agentic Commerce Protocol — product catalog",
        "description": "Returns current subscription offers in ACP-compatible format. Current public offers are Trial, Pro monthly, Pro yearly, and Business contact-sales guidance.",
        "responses": {
          "200": {
            "description": "ACP catalog",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AcpCatalog" }
              }
            }
          }
        }
      }
    },
    "/acp/checkouts": {
      "post": {
        "tags": ["acp"],
        "summary": "Create an ACP checkout for a Pro subscription",
        "description": "Initiates an Agentic Commerce Protocol checkout for Pro monthly or Pro yearly. Business is contact-sales; Trial has no checkout.",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["productId"],
                "properties": {
                  "productId": { "type": "string" },
                  "returnUrl": { "type": "string", "format": "uri" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ACP checkout response"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "CreditSummary": {
        "type": "object",
        "properties": {
          "balance": {
            "type": "integer",
            "description": "Current credit balance (Trial lifetime or monthly Pro/Business allowance)"
          },
          "monthlyAllowance": {
            "type": "integer",
            "description": "Pro monthly allowance (0 for non-Pro)"
          },
          "monthlyUsed": { "type": "integer" },
          "monthlyResetAt": { "type": "string", "format": "date-time" },
          "tier": { "type": "string", "enum": ["trial", "pro", "business"] }
        }
      },
      "AcpCatalog": {
        "type": "object",
        "properties": {
          "version": { "type": "string" },
          "products": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string" },
                "type": { "type": "string", "enum": ["digital_subscription", "contact_sales"] },
                "name": { "type": "string" },
                "price": { "type": "object" },
                "description": { "type": "string" }
              }
            }
          }
        }
      }
    }
  }
}
