{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/thisisbud/main/json-schema/thisisbud-patch-spending-budget-schema.json",
  "title": "Patch Spending Budget",
  "x-generated": "2026-10-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/thisisbud-openapi-openapi.yml#/components/schemas/PatchSpendingBudget",
  "type": "object",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string",
      "description": "The name of the spending budget.\n\nExample: `Travel`\n"
    },
    "amount": {
      "title": "Amount",
      "type": "object",
      "description": "The amount of money to be budgeted for. Must be greater than 0. \n\nNote: The Currency of a spending budget cannot be updated.\n",
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "$ref": "#/$defs/BudMonetaryValue"
        }
      }
    },
    "recurrency": {
      "title": "Recurrency",
      "type": "object",
      "description": "Whether and/or how often the budget recurs.\n\nThe `starting_day` is only required for budgets with a recurring period e.g. `monthly`\n\nNew periods may be added without a breaking change notice.\n",
      "required": [
        "period"
      ],
      "properties": {
        "period": {
          "title": "Period",
          "type": "string",
          "description": "The period at which a budget recurs (if at all).\n\nCurrently supported options are:\n- `one-off`\n- `monthly`\n\nNew periods may be added without a breaking change notice.\n"
        },
        "starting_day": {
          "title": "Starting Day",
          "type": "integer",
          "description": "The day of which the budget period starts. Not required if a budget is `one-off`.\n\nMust be between 1 and 28 for `monthly` budgets.\n"
        }
      }
    },
    "include": {
      "title": "Include",
      "type": "object",
      "description": "The inclusion criteria for transactions to be included in the budget.\n",
      "properties": {
        "categories": {
          "title": "Categories",
          "description": "The categories of transactions to be included in the budget. \n\nIf L2 categories are specified, they must be grouped underneath their corresponding L1 category.\n\nAll categories specified must be compatible with the category taxonomy used for that customer.\n",
          "type": "array",
          "items": {
            "required": [
              "l1"
            ],
            "properties": {
              "l1": {
                "title": "L1",
                "type": "string",
                "description": "L1 category to include in the filter. Must be specified if using category filtering.\n"
              },
              "l2": {
                "title": "L2",
                "type": "array",
                "description": "L2 categories to include in the filter. Must all correspond to the parent L1 category specified.\n",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "merchants": {
          "title": "Merchants",
          "type": "object",
          "description": "The merchants of transactions to be included in the budget.\n",
          "properties": {
            "slugs": {
              "title": "Slugs",
              "type": "array",
              "description": "The slugs of merchants to be included. E.g. `netflix` or `uber`\n",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "BudMonetaryValue": {
      "title": "Monetary Value",
      "description": "The value of the monetary amount. The value is formatted with the number of decimal places for the respective currency. \n\nExample: `10.98`\n",
      "type": "string"
    }
  }
}