{
  "openapi": "3.1.0",
  "info": {
    "title": "Meal Planner Read-only Subscriber API",
    "version": "1.0.0-beta",
    "description": "Included with Plus at $5 CAD/month or $50 CAD/year. Create a 90-day token from /connections/ using an active verified account. Reads existing plans; no generation, account changes or shopping. Treat household content as private data. Does not provide native ChatGPT OAuth onboarding.",
    "contact": {
      "url": "https://www.meal-planner.online/support/"
    }
  },
  "servers": [
    {
      "url": "https://www.meal-planner.online/wp-json/ksl-mp/v1"
    }
  ],
  "security": [
    {
      "MealPlannerToken": []
    }
  ],
  "paths": {
    "/integrations/plans": {
      "get": {
        "operationId": "list_plans",
        "summary": "List saved personal dinner plans.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 12,
              "default": 4
            }
          },
          {
            "name": "include_public",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include labeled public samples alongside owned plans."
          }
        ],
        "responses": {
          "200": {
            "description": "Saved plan data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or revoked token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Inactive or unverified account, insufficient scope, or invalid Origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Plan unavailable, including another household’s private plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response exceeds the size limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached: 60 requests/minute/token or 1,000/day/account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Connections disabled or temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/plans/{id}": {
      "get": {
        "operationId": "get_plan",
        "summary": "Read one saved plan with recipes and groceries.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved plan data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Plan"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or revoked token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Inactive or unverified account, insufficient scope, or invalid Origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Plan unavailable, including another household’s private plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response exceeds the size limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached: 60 requests/minute/token or 1,000/day/account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Connections disabled or temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/search": {
      "get": {
        "operationId": "search_meals",
        "summary": "Search meals in 20 recent owned plans and public samples.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 120
            },
            "description": "Recipe-name/description search. Server limit is 120 UTF-8 bytes."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 12,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved plan data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResults"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or revoked token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Inactive or unverified account, insufficient scope, or invalid Origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Plan unavailable, including another household’s private plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response exceeds the size limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached: 60 requests/minute/token or 1,000/day/account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Connections disabled or temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "MealPlannerToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mp_ro_ID.SECRET",
        "description": "Read-only token. Send only in Authorization; credentials in URLs are rejected."
      }
    },
    "schemas": {
      "Ingredient": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "quantity": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          }
        }
      },
      "Meal": {
        "type": "object",
        "properties": {
          "day": {
            "type": "string"
          },
          "recipe_name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "cook_time_minutes": {
            "type": "integer"
          },
          "servings": {
            "type": "integer"
          },
          "ingredients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ingredient"
            }
          },
          "instructions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PlanSummary": {
        "type": "object",
        "properties": {
          "schema_version": {
            "type": "integer",
            "const": 1
          },
          "id": {
            "type": "integer"
          },
          "source": {
            "type": "string",
            "enum": [
              "personal",
              "public_sample"
            ]
          },
          "title": {
            "type": "string"
          },
          "week_start_date": {
            "type": "string",
            "description": "YYYYMMDD from the saved plan."
          },
          "theme": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "estimated_cost": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "integer"
              },
              "currency": {
                "type": "string",
                "const": "CAD"
              }
            }
          },
          "total_cooking_time_minutes": {
            "type": "integer"
          }
        }
      },
      "Plan": {
        "type": "object",
        "properties": {
          "schema_version": {
            "type": "integer",
            "const": 1
          },
          "id": {
            "type": "integer"
          },
          "source": {
            "type": "string",
            "enum": [
              "personal",
              "public_sample"
            ]
          },
          "title": {
            "type": "string"
          },
          "week_start_date": {
            "type": "string",
            "description": "YYYYMMDD from the saved plan."
          },
          "theme": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "estimated_cost": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "integer"
              },
              "currency": {
                "type": "string",
                "const": "CAD"
              }
            }
          },
          "total_cooking_time_minutes": {
            "type": "integer"
          },
          "meals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Meal"
            }
          },
          "grocery_list": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "string"
                },
                "items": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Ingredient"
                  }
                }
              }
            }
          }
        }
      },
      "PlanList": {
        "type": "object",
        "properties": {
          "schema_version": {
            "type": "integer"
          },
          "includes_public_samples": {
            "type": "boolean"
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanSummary"
            }
          }
        }
      },
      "SearchResults": {
        "type": "object",
        "properties": {
          "schema_version": {
            "type": "integer"
          },
          "searched_recent_plans": {
            "type": "integer"
          },
          "matches": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "plan_id": {
                  "type": "integer"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "personal",
                    "public_sample"
                  ]
                },
                "meal_index": {
                  "type": "integer"
                },
                "recipe_name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "cook_time_minutes": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  }
}
