{
  "openapi": "3.1.1",
  "info": {
    "title": "Subscription Stack API",
    "version": "1.0.0",
    "summary": "Add up every subscription, spot overlaps and see which ones to cancel and what you save.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://subscriptionstack.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Add up every subscription, spot overlaps and see which ones to cancel and what you save.",
        "description": "List your subscriptions with price, billing cycle, category, how often you use them and how many people share them. Subscription Stack converts everything to monthly and yearly totals, groups by category, flags overlapping services, computes cost per use and lists cancellation candidates with the savings.\n\nMethodology:\n- Monthly price = weekly × (365.25/12)/7 (≈ 4.348), monthly × 1, quarterly ÷ 3, yearly ÷ 12.\n- Your share = monthly price ÷ number of people sharing; annual = your monthly share × 12.\n- Cost per use = your monthly share ÷ uses per month (not computed when uses are unknown or zero).\n- Overlap = two or more subscriptions in the same category (excluding “other”).\n- Cancel candidate if uses per month < your threshold, or cost per use > your threshold, or it is the most expensive per use (or least used) service within an overlapping category.\n- Savings if cancelled = sum of your monthly shares of all candidates; annual = × 12.",
        "tags": [
          "money"
        ],
        "x-mcp-tool": "subscription_stack",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionStackInput"
              },
              "examples": {
                "example1": {
                  "summary": "Typical household stack",
                  "value": {
                    "currency": "EUR",
                    "minUsesPerMonth": 2,
                    "maxCostPerUse": 5,
                    "subscriptions": [
                      {
                        "name": "Netflix",
                        "price": 13.99,
                        "billing": "monthly",
                        "category": "video",
                        "usesPerMonth": 12,
                        "sharedBy": 2
                      },
                      {
                        "name": "Disney+",
                        "price": 89.9,
                        "billing": "yearly",
                        "category": "video",
                        "usesPerMonth": 2
                      },
                      {
                        "name": "Spotify",
                        "price": 10.99,
                        "billing": "monthly",
                        "category": "music",
                        "usesPerMonth": 40
                      },
                      {
                        "name": "Gym",
                        "price": 34.9,
                        "billing": "monthly",
                        "category": "fitness",
                        "usesPerMonth": 3
                      },
                      {
                        "name": "Cloud 2 TB",
                        "price": 9.99,
                        "billing": "monthly",
                        "category": "cloud-storage",
                        "usesPerMonth": 30
                      },
                      {
                        "name": "Newspaper",
                        "price": 29.97,
                        "billing": "quarterly",
                        "category": "news",
                        "usesPerMonth": 1
                      }
                    ]
                  }
                },
                "example2": {
                  "summary": "Freelancer software stack",
                  "value": {
                    "currency": "USD",
                    "minUsesPerMonth": 4,
                    "maxCostPerUse": 3,
                    "subscriptions": [
                      {
                        "name": "Design suite",
                        "price": 59.99,
                        "billing": "monthly",
                        "category": "software",
                        "usesPerMonth": 20
                      },
                      {
                        "name": "Second design app",
                        "price": 99,
                        "billing": "yearly",
                        "category": "software",
                        "usesPerMonth": 1
                      },
                      {
                        "name": "Cloud backup",
                        "price": 6,
                        "billing": "monthly",
                        "category": "cloud-storage",
                        "usesPerMonth": 30
                      },
                      {
                        "name": "Extra cloud drive",
                        "price": 2.99,
                        "billing": "monthly",
                        "category": "cloud-storage"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionStackResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "SubscriptionStackInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "currency": {
            "title": "Currency",
            "description": "Shown in results only; no conversion is performed.",
            "type": "string",
            "maxLength": 8,
            "default": "EUR"
          },
          "minUsesPerMonth": {
            "title": "Flag if used fewer than",
            "type": "number",
            "minimum": 0,
            "maximum": 1000,
            "default": 2,
            "x-unit": "times/month"
          },
          "maxCostPerUse": {
            "title": "Flag if cost per use is above",
            "description": "In your currency, for your share.",
            "type": "number",
            "minimum": 0,
            "default": 5
          },
          "subscriptions": {
            "title": "Subscriptions",
            "description": "Price is the full price per billing period; “Shared by” splits it (you pay price ÷ people). Leave uses empty if unknown.",
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "name": {
                  "title": "Service",
                  "type": "string"
                },
                "price": {
                  "title": "Price",
                  "type": "number",
                  "minimum": 0
                },
                "billing": {
                  "title": "Billed",
                  "type": "string",
                  "enum": [
                    "weekly",
                    "monthly",
                    "quarterly",
                    "yearly"
                  ],
                  "default": "monthly"
                },
                "category": {
                  "title": "Category",
                  "type": "string",
                  "enum": [
                    "video",
                    "music",
                    "news",
                    "software",
                    "cloud-storage",
                    "fitness",
                    "gaming",
                    "food",
                    "other"
                  ],
                  "default": "other"
                },
                "usesPerMonth": {
                  "title": "Uses / month",
                  "type": "number",
                  "minimum": 0
                },
                "sharedBy": {
                  "title": "Shared by",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 20,
                  "default": 1,
                  "x-unit": "people"
                }
              },
              "required": [
                "name",
                "price"
              ]
            }
          }
        },
        "required": [
          "subscriptions"
        ]
      },
      "SubscriptionStackResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "currency",
              "monthlyTotal",
              "annualTotal",
              "fullPriceMonthlyTotal",
              "subscriptions",
              "categories",
              "overlaps",
              "cancelCandidates",
              "savingsIfCancelled"
            ],
            "properties": {
              "currency": {
                "type": "string"
              },
              "monthlyTotal": {
                "type": "number",
                "description": "Your share, per month."
              },
              "annualTotal": {
                "type": "number"
              },
              "fullPriceMonthlyTotal": {
                "type": "number",
                "description": "Before splitting shared subscriptions."
              },
              "subscriptions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "category",
                    "billing",
                    "monthlyFullPrice",
                    "monthlyYourShare",
                    "annualYourShare",
                    "usesPerMonth",
                    "costPerUse",
                    "shareOfTotalPercent",
                    "cancelCandidate",
                    "reasons"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "category": {
                      "type": "string",
                      "enum": [
                        "video",
                        "music",
                        "news",
                        "software",
                        "cloud-storage",
                        "fitness",
                        "gaming",
                        "food",
                        "other"
                      ]
                    },
                    "billing": {
                      "type": "string",
                      "enum": [
                        "weekly",
                        "monthly",
                        "quarterly",
                        "yearly"
                      ]
                    },
                    "monthlyFullPrice": {
                      "type": "number"
                    },
                    "monthlyYourShare": {
                      "type": "number"
                    },
                    "annualYourShare": {
                      "type": "number"
                    },
                    "usesPerMonth": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "costPerUse": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Your monthly share ÷ uses per month; null if uses unknown or 0."
                    },
                    "shareOfTotalPercent": {
                      "type": "number"
                    },
                    "cancelCandidate": {
                      "type": "boolean"
                    },
                    "reasons": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "categories": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "category",
                    "label",
                    "count",
                    "monthly",
                    "annual"
                  ],
                  "properties": {
                    "category": {
                      "type": "string",
                      "enum": [
                        "video",
                        "music",
                        "news",
                        "software",
                        "cloud-storage",
                        "fitness",
                        "gaming",
                        "food",
                        "other"
                      ]
                    },
                    "label": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "monthly": {
                      "type": "number"
                    },
                    "annual": {
                      "type": "number"
                    }
                  }
                }
              },
              "overlaps": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "category",
                    "services",
                    "monthly"
                  ],
                  "properties": {
                    "category": {
                      "type": "string",
                      "enum": [
                        "video",
                        "music",
                        "news",
                        "software",
                        "cloud-storage",
                        "fitness",
                        "gaming",
                        "food",
                        "other"
                      ]
                    },
                    "services": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "monthly": {
                      "type": "number"
                    }
                  }
                }
              },
              "cancelCandidates": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "savingsIfCancelled": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "monthly",
                  "annual"
                ],
                "properties": {
                  "monthly": {
                    "type": "number"
                  },
                  "annual": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}