{
  "openapi": "3.1.0",
  "info": {
    "title": "DuitMyself Public API",
    "version": "1.0.0-alpha",
    "description": "REST API for DuitMyself Pro users. Personal API behavior is documented publicly; delegated access foundations are reserved for future lanes."
  },
  "servers": [
    {
      "url": "https://api.duitmyself.app",
      "description": "Production API"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key"
      }
    },
    "schemas": {
      "Error": {
        "$ref": "#/definitions/Error",
        "definitions": {
          "Error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "format": "uri"
              },
              "title": {
                "type": "string"
              },
              "detail": {
                "type": "string"
              },
              "status": {
                "type": "integer"
              },
              "code": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "title",
              "detail",
              "status",
              "code",
              "request_id"
            ],
            "additionalProperties": false
          }
        }
      },
      "Me": {
        "$ref": "#/definitions/Me",
        "definitions": {
          "Me": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "country": {
                "type": "string",
                "nullable": true
              },
              "defaultCurrency": {
                "type": "string",
                "nullable": true
              },
              "preferredLanguage": {
                "type": "string",
                "nullable": true
              },
              "tier": {
                "type": "string"
              },
              "accessMode": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "id",
              "name",
              "email",
              "country",
              "defaultCurrency",
              "preferredLanguage",
              "tier",
              "accessMode",
              "scopes"
            ],
            "additionalProperties": false
          }
        }
      },
      "AgentContext": {
        "$ref": "#/definitions/AgentContext",
        "definitions": {
          "AgentContext": {
            "type": "object",
            "properties": {
              "me": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "nullable": true
                  },
                  "email": {
                    "type": "string",
                    "nullable": true
                  },
                  "country": {
                    "type": "string",
                    "nullable": true
                  },
                  "defaultCurrency": {
                    "type": "string",
                    "nullable": true
                  },
                  "preferredLanguage": {
                    "type": "string",
                    "nullable": true
                  },
                  "tier": {
                    "type": "string"
                  },
                  "accessMode": {
                    "type": "string"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "id",
                  "name",
                  "email",
                  "country",
                  "defaultCurrency",
                  "preferredLanguage",
                  "tier",
                  "accessMode",
                  "scopes"
                ],
                "additionalProperties": false
              },
              "accounts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "externalId": {
                      "type": "string",
                      "nullable": true
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "physical",
                        "bank",
                        "ewallet",
                        "card",
                        "investment",
                        "crypto",
                        "loan",
                        "other"
                      ]
                    },
                    "subtype": {
                      "type": "string",
                      "nullable": true
                    },
                    "providerSlug": {
                      "type": "string",
                      "nullable": true
                    },
                    "secondaryProviderSlug": {
                      "type": "string",
                      "nullable": true
                    },
                    "balance": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string",
                      "nullable": true
                    },
                    "icon": {
                      "type": "string",
                      "nullable": true
                    },
                    "linkedAccountId": {
                      "type": "string",
                      "nullable": true
                    },
                    "isArchived": {
                      "type": "boolean"
                    },
                    "isLiability": {
                      "type": "boolean"
                    },
                    "isFavourite": {
                      "type": "boolean"
                    },
                    "showInDashboard": {
                      "type": "boolean"
                    },
                    "isHidden": {
                      "type": "boolean"
                    },
                    "notes": {
                      "type": "string",
                      "nullable": true
                    },
                    "sortOrder": {
                      "type": "number",
                      "nullable": true
                    },
                    "accountNumber": {
                      "type": "string",
                      "nullable": true
                    },
                    "customFields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "label",
                          "value"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "externalId",
                    "name",
                    "type",
                    "subtype",
                    "providerSlug",
                    "secondaryProviderSlug",
                    "balance",
                    "currency",
                    "color",
                    "icon",
                    "linkedAccountId",
                    "isArchived",
                    "isLiability",
                    "isFavourite",
                    "showInDashboard",
                    "isHidden",
                    "notes",
                    "sortOrder",
                    "accountNumber",
                    "customFields",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              },
              "categories": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "externalId": {
                      "type": "string",
                      "nullable": true
                    },
                    "name": {
                      "type": "string"
                    },
                    "icon": {
                      "type": "string",
                      "nullable": true
                    },
                    "color": {
                      "type": "string",
                      "nullable": true
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "expense",
                        "income"
                      ],
                      "nullable": true
                    },
                    "parentId": {
                      "type": "string",
                      "nullable": true
                    },
                    "depth": {
                      "type": "number"
                    },
                    "fullName": {
                      "type": "string"
                    },
                    "presetKey": {
                      "type": "string",
                      "nullable": true
                    },
                    "isArchived": {
                      "type": "boolean"
                    },
                    "isSystem": {
                      "type": "boolean"
                    },
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "nullable": true
                    }
                  },
                  "required": [
                    "id",
                    "externalId",
                    "name",
                    "icon",
                    "color",
                    "type",
                    "parentId",
                    "depth",
                    "fullName",
                    "presetKey",
                    "isArchived",
                    "isSystem",
                    "countries"
                  ],
                  "additionalProperties": false
                }
              },
              "payees": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "externalId": {
                      "type": "string",
                      "nullable": true
                    },
                    "name": {
                      "type": "string"
                    },
                    "normalizedName": {
                      "type": "string"
                    },
                    "aliases": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "categoryId": {
                      "type": "string",
                      "nullable": true
                    },
                    "isMerchant": {
                      "type": "boolean"
                    },
                    "transactionCount": {
                      "type": "number"
                    },
                    "totalSpent": {
                      "type": "number"
                    },
                    "createdAt": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "externalId",
                    "name",
                    "normalizedName",
                    "aliases",
                    "categoryId",
                    "isMerchant",
                    "transactionCount",
                    "totalSpent",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              },
              "recentTransactions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "externalId": {
                      "type": "string",
                      "nullable": true
                    },
                    "accountId": {
                      "type": "string",
                      "nullable": true
                    },
                    "categoryId": {
                      "type": "string",
                      "nullable": true
                    },
                    "payeeId": {
                      "type": "string",
                      "nullable": true
                    },
                    "amount": {
                      "type": "number"
                    },
                    "date": {
                      "type": "string"
                    },
                    "note": {
                      "type": "string",
                      "nullable": true
                    },
                    "time": {
                      "type": "string",
                      "nullable": true
                    },
                    "isTransfer": {
                      "type": "boolean"
                    },
                    "transferToAccountId": {
                      "type": "string",
                      "nullable": true
                    },
                    "destinationAmount": {
                      "type": "number",
                      "nullable": true
                    },
                    "exchangeRate": {
                      "type": "number",
                      "nullable": true
                    },
                    "hasSplits": {
                      "type": "boolean"
                    },
                    "splitMode": {
                      "type": "string",
                      "nullable": true
                    },
                    "categoryType": {
                      "type": "string",
                      "nullable": true
                    },
                    "createdAt": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "externalId",
                    "accountId",
                    "categoryId",
                    "payeeId",
                    "amount",
                    "date",
                    "note",
                    "time",
                    "isTransfer",
                    "transferToAccountId",
                    "destinationAmount",
                    "exchangeRate",
                    "hasSplits",
                    "splitMode",
                    "categoryType",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              },
              "serverTime": {
                "type": "number"
              }
            },
            "required": [
              "me",
              "accounts",
              "categories",
              "payees",
              "recentTransactions",
              "serverTime"
            ],
            "additionalProperties": false
          }
        }
      },
      "Account": {
        "$ref": "#/definitions/Account",
        "definitions": {
          "Account": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "physical",
                  "bank",
                  "ewallet",
                  "card",
                  "investment",
                  "crypto",
                  "loan",
                  "other"
                ]
              },
              "subtype": {
                "type": "string",
                "nullable": true
              },
              "providerSlug": {
                "type": "string",
                "nullable": true
              },
              "secondaryProviderSlug": {
                "type": "string",
                "nullable": true
              },
              "balance": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "color": {
                "type": "string",
                "nullable": true
              },
              "icon": {
                "type": "string",
                "nullable": true
              },
              "linkedAccountId": {
                "type": "string",
                "nullable": true
              },
              "isArchived": {
                "type": "boolean"
              },
              "isLiability": {
                "type": "boolean"
              },
              "isFavourite": {
                "type": "boolean"
              },
              "showInDashboard": {
                "type": "boolean"
              },
              "isHidden": {
                "type": "boolean"
              },
              "notes": {
                "type": "string",
                "nullable": true
              },
              "sortOrder": {
                "type": "number",
                "nullable": true
              },
              "accountNumber": {
                "type": "string",
                "nullable": true
              },
              "customFields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              "createdAt": {
                "type": "number"
              }
            },
            "required": [
              "id",
              "externalId",
              "name",
              "type",
              "subtype",
              "providerSlug",
              "secondaryProviderSlug",
              "balance",
              "currency",
              "color",
              "icon",
              "linkedAccountId",
              "isArchived",
              "isLiability",
              "isFavourite",
              "showInDashboard",
              "isHidden",
              "notes",
              "sortOrder",
              "accountNumber",
              "customFields",
              "createdAt"
            ],
            "additionalProperties": false
          }
        }
      },
      "AccountCreate": {
        "$ref": "#/definitions/AccountCreate",
        "definitions": {
          "AccountCreate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "physical",
                  "bank",
                  "ewallet",
                  "card",
                  "investment",
                  "crypto",
                  "loan",
                  "other"
                ]
              },
              "subtype": {
                "type": "string"
              },
              "providerSlug": {
                "type": "string"
              },
              "secondaryProviderSlug": {
                "type": "string"
              },
              "balance": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "linkedAccountId": {
                "type": "string"
              },
              "isLiability": {
                "type": "boolean"
              },
              "notes": {
                "type": "string"
              },
              "sortOrder": {
                "type": "number"
              },
              "accountNumber": {
                "type": "string"
              },
              "customFields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              "isFavourite": {
                "type": "boolean"
              },
              "showInDashboard": {
                "type": "boolean"
              },
              "isHidden": {
                "type": "boolean"
              }
            },
            "required": [
              "name",
              "type",
              "balance",
              "currency"
            ],
            "additionalProperties": false
          }
        }
      },
      "AccountUpsert": {
        "$ref": "#/definitions/AccountUpsert",
        "definitions": {
          "AccountUpsert": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "physical",
                  "bank",
                  "ewallet",
                  "card",
                  "investment",
                  "crypto",
                  "loan",
                  "other"
                ]
              },
              "subtype": {
                "type": "string"
              },
              "providerSlug": {
                "type": "string"
              },
              "secondaryProviderSlug": {
                "type": "string"
              },
              "balance": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "linkedAccountId": {
                "type": "string"
              },
              "isLiability": {
                "type": "boolean"
              },
              "notes": {
                "type": "string"
              },
              "sortOrder": {
                "type": "number"
              },
              "accountNumber": {
                "type": "string"
              },
              "customFields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              "isFavourite": {
                "type": "boolean"
              },
              "showInDashboard": {
                "type": "boolean"
              },
              "isHidden": {
                "type": "boolean"
              }
            },
            "required": [
              "externalId",
              "name",
              "type",
              "balance",
              "currency"
            ],
            "additionalProperties": false
          }
        }
      },
      "AccountUpdate": {
        "$ref": "#/definitions/AccountUpdate",
        "definitions": {
          "AccountUpdate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "physical",
                  "bank",
                  "ewallet",
                  "card",
                  "investment",
                  "crypto",
                  "loan",
                  "other"
                ]
              },
              "subtype": {
                "type": "string"
              },
              "providerSlug": {
                "type": "string"
              },
              "secondaryProviderSlug": {
                "type": "string"
              },
              "balance": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "linkedAccountId": {
                "type": "string"
              },
              "isLiability": {
                "type": "boolean"
              },
              "notes": {
                "type": "string"
              },
              "sortOrder": {
                "type": "number"
              },
              "accountNumber": {
                "type": "string"
              },
              "customFields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              "isFavourite": {
                "type": "boolean"
              },
              "showInDashboard": {
                "type": "boolean"
              },
              "isHidden": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "Category": {
        "$ref": "#/definitions/Category",
        "definitions": {
          "Category": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "icon": {
                "type": "string",
                "nullable": true
              },
              "color": {
                "type": "string",
                "nullable": true
              },
              "type": {
                "type": "string",
                "enum": [
                  "expense",
                  "income"
                ],
                "nullable": true
              },
              "parentId": {
                "type": "string",
                "nullable": true
              },
              "depth": {
                "type": "number"
              },
              "fullName": {
                "type": "string"
              },
              "presetKey": {
                "type": "string",
                "nullable": true
              },
              "isArchived": {
                "type": "boolean"
              },
              "isSystem": {
                "type": "boolean"
              },
              "countries": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "nullable": true
              }
            },
            "required": [
              "id",
              "externalId",
              "name",
              "icon",
              "color",
              "type",
              "parentId",
              "depth",
              "fullName",
              "presetKey",
              "isArchived",
              "isSystem",
              "countries"
            ],
            "additionalProperties": false
          }
        }
      },
      "CategoryCreate": {
        "$ref": "#/definitions/CategoryCreate",
        "definitions": {
          "CategoryCreate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "expense",
                  "income"
                ]
              },
              "parentId": {
                "type": "string"
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          }
        }
      },
      "CategoryUpsert": {
        "$ref": "#/definitions/CategoryUpsert",
        "definitions": {
          "CategoryUpsert": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "expense",
                  "income"
                ]
              },
              "parentId": {
                "type": "string"
              }
            },
            "required": [
              "externalId",
              "name"
            ],
            "additionalProperties": false
          }
        }
      },
      "CategoryUpdate": {
        "$ref": "#/definitions/CategoryUpdate",
        "definitions": {
          "CategoryUpdate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "expense",
                  "income"
                ]
              },
              "parentId": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "Payee": {
        "$ref": "#/definitions/Payee",
        "definitions": {
          "Payee": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "normalizedName": {
                "type": "string"
              },
              "aliases": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "categoryId": {
                "type": "string",
                "nullable": true
              },
              "isMerchant": {
                "type": "boolean"
              },
              "transactionCount": {
                "type": "number"
              },
              "totalSpent": {
                "type": "number"
              },
              "createdAt": {
                "type": "number"
              }
            },
            "required": [
              "id",
              "externalId",
              "name",
              "normalizedName",
              "aliases",
              "categoryId",
              "isMerchant",
              "transactionCount",
              "totalSpent",
              "createdAt"
            ],
            "additionalProperties": false
          }
        }
      },
      "PayeeCreate": {
        "$ref": "#/definitions/PayeeCreate",
        "definitions": {
          "PayeeCreate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "aliases": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "categoryId": {
                "type": "string",
                "nullable": true
              },
              "isMerchant": {
                "type": "boolean"
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          }
        }
      },
      "PayeeUpsert": {
        "$ref": "#/definitions/PayeeUpsert",
        "definitions": {
          "PayeeUpsert": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "aliases": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "categoryId": {
                "type": "string",
                "nullable": true
              },
              "isMerchant": {
                "type": "boolean"
              }
            },
            "required": [
              "externalId",
              "name"
            ],
            "additionalProperties": false
          }
        }
      },
      "PayeeUpdate": {
        "$ref": "#/definitions/PayeeUpdate",
        "definitions": {
          "PayeeUpdate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "aliases": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "categoryId": {
                "type": "string",
                "nullable": true
              },
              "isMerchant": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "Transaction": {
        "$ref": "#/definitions/Transaction",
        "definitions": {
          "Transaction": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "accountId": {
                "type": "string",
                "nullable": true
              },
              "categoryId": {
                "type": "string",
                "nullable": true
              },
              "payeeId": {
                "type": "string",
                "nullable": true
              },
              "amount": {
                "type": "number"
              },
              "date": {
                "type": "string"
              },
              "note": {
                "type": "string",
                "nullable": true
              },
              "time": {
                "type": "string",
                "nullable": true
              },
              "isTransfer": {
                "type": "boolean"
              },
              "transferToAccountId": {
                "type": "string",
                "nullable": true
              },
              "destinationAmount": {
                "type": "number",
                "nullable": true
              },
              "exchangeRate": {
                "type": "number",
                "nullable": true
              },
              "hasSplits": {
                "type": "boolean"
              },
              "splitMode": {
                "type": "string",
                "nullable": true
              },
              "categoryType": {
                "type": "string",
                "nullable": true
              },
              "createdAt": {
                "type": "number"
              }
            },
            "required": [
              "id",
              "externalId",
              "accountId",
              "categoryId",
              "payeeId",
              "amount",
              "date",
              "note",
              "time",
              "isTransfer",
              "transferToAccountId",
              "destinationAmount",
              "exchangeRate",
              "hasSplits",
              "splitMode",
              "categoryType",
              "createdAt"
            ],
            "additionalProperties": false
          }
        }
      },
      "TransactionCreate": {
        "$ref": "#/definitions/TransactionCreate",
        "definitions": {
          "TransactionCreate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "accountId": {
                "type": "string"
              },
              "categoryId": {
                "type": "string"
              },
              "payeeId": {
                "type": "string"
              },
              "payeeName": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "date": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "time": {
                "type": "string"
              },
              "isTransfer": {
                "type": "boolean"
              },
              "transferToAccountId": {
                "type": "string"
              },
              "destinationAmount": {
                "type": "number"
              },
              "exchangeRate": {
                "type": "number"
              }
            },
            "required": [
              "accountId",
              "amount",
              "date"
            ],
            "additionalProperties": false
          }
        }
      },
      "TransactionUpsert": {
        "$ref": "#/definitions/TransactionUpsert",
        "definitions": {
          "TransactionUpsert": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string"
              },
              "accountId": {
                "type": "string"
              },
              "categoryId": {
                "type": "string"
              },
              "payeeId": {
                "type": "string"
              },
              "payeeName": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "date": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "time": {
                "type": "string"
              },
              "isTransfer": {
                "type": "boolean"
              },
              "transferToAccountId": {
                "type": "string"
              },
              "destinationAmount": {
                "type": "number"
              },
              "exchangeRate": {
                "type": "number"
              }
            },
            "required": [
              "externalId",
              "accountId",
              "amount",
              "date"
            ],
            "additionalProperties": false
          }
        }
      },
      "TransactionUpdate": {
        "$ref": "#/definitions/TransactionUpdate",
        "definitions": {
          "TransactionUpdate": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": "string",
                "nullable": true
              },
              "accountId": {
                "type": "string"
              },
              "categoryId": {
                "type": "string",
                "nullable": true
              },
              "payeeId": {
                "type": "string",
                "nullable": true
              },
              "payeeName": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "date": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "time": {
                "type": "string",
                "nullable": true
              },
              "isTransfer": {
                "type": "boolean"
              },
              "transferToAccountId": {
                "type": "string",
                "nullable": true
              },
              "destinationAmount": {
                "type": "number"
              },
              "exchangeRate": {
                "type": "number"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "AccountListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Account"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "data",
          "nextCursor",
          "hasMore"
        ]
      },
      "CategoryListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "data",
          "nextCursor",
          "hasMore"
        ]
      },
      "PayeeListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payee"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "data",
          "nextCursor",
          "hasMore"
        ]
      },
      "TransactionListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Transaction"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "data",
          "nextCursor",
          "hasMore"
        ]
      },
      "MeResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Me"
          }
        },
        "required": [
          "data"
        ]
      },
      "AgentContextResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/AgentContext"
          }
        },
        "required": [
          "data"
        ]
      },
      "AccountResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Account"
          }
        },
        "required": [
          "data"
        ]
      },
      "CategoryResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Category"
          }
        },
        "required": [
          "data"
        ]
      },
      "PayeeResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Payee"
          }
        },
        "required": [
          "data"
        ]
      },
      "TransactionResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Transaction"
          }
        },
        "required": [
          "data"
        ]
      },
      "AccountUpsertResponse": {
        "type": "object",
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "created",
              "updated"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/Account"
          }
        },
        "required": [
          "operation",
          "data"
        ]
      },
      "CategoryUpsertResponse": {
        "type": "object",
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "created",
              "updated"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/Category"
          }
        },
        "required": [
          "operation",
          "data"
        ]
      },
      "PayeeUpsertResponse": {
        "type": "object",
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "created",
              "updated"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/Payee"
          }
        },
        "required": [
          "operation",
          "data"
        ]
      },
      "TransactionUpsertResponse": {
        "type": "object",
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "created",
              "updated"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/Transaction"
          }
        },
        "required": [
          "operation",
          "data"
        ]
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Get the authenticated API subject",
        "responses": {
          "200": {
            "description": "Authenticated subject",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent/context": {
      "get": {
        "operationId": "getAgentContext",
        "summary": "Bootstrap agent context",
        "parameters": [
          {
            "name": "includeArchived",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "payeeLimit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "recentTransactionLimit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Profile plus lookup tables and recent transactions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentContextResponse"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "operationId": "listAccounts",
        "summary": "List accounts",
        "responses": {
          "200": {
            "description": "Account list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createAccount",
        "summary": "Create an account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/upsert": {
      "post": {
        "operationId": "upsertAccount",
        "summary": "Create or update an account by external ID",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountUpsert"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created or updated account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountUpsertResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}": {
      "get": {
        "operationId": "getAccount",
        "summary": "Get an account",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateAccount",
        "summary": "Update an account",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteAccount",
        "summary": "Archive an account",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Archived"
          }
        }
      }
    },
    "/v1/categories": {
      "get": {
        "operationId": "listCategories",
        "summary": "List categories",
        "responses": {
          "200": {
            "description": "Category list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCategory",
        "summary": "Create a custom category",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CategoryCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created category",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/categories/upsert": {
      "post": {
        "operationId": "upsertCategory",
        "summary": "Create or update a custom category by external ID",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CategoryUpsert"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created or updated category",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryUpsertResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/categories/{categoryId}": {
      "get": {
        "operationId": "getCategory",
        "summary": "Get a category",
        "parameters": [
          {
            "name": "categoryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Category detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateCategory",
        "summary": "Update a custom category",
        "parameters": [
          {
            "name": "categoryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CategoryUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated category",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCategory",
        "summary": "Archive a custom category",
        "parameters": [
          {
            "name": "categoryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Archived"
          }
        }
      }
    },
    "/v1/payees": {
      "get": {
        "operationId": "listPayees",
        "summary": "List payees",
        "responses": {
          "200": {
            "description": "Payee list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayeeListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createPayee",
        "summary": "Create a payee",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayeeCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created payee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayeeResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payees/upsert": {
      "post": {
        "operationId": "upsertPayee",
        "summary": "Create or update a payee by external ID",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayeeUpsert"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created or updated payee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayeeUpsertResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payees/{payeeId}": {
      "get": {
        "operationId": "getPayee",
        "summary": "Get a payee",
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payee detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayeeResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updatePayee",
        "summary": "Update a payee",
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayeeUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated payee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayeeResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/transactions": {
      "get": {
        "operationId": "listTransactions",
        "summary": "List transactions",
        "responses": {
          "200": {
            "description": "Transaction list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTransaction",
        "summary": "Create a transaction",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/transactions/upsert": {
      "post": {
        "operationId": "upsertTransaction",
        "summary": "Create or update a transaction by external ID",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionUpsert"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created or updated transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionUpsertResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/transactions/{transactionId}": {
      "get": {
        "operationId": "getTransaction",
        "summary": "Get a transaction",
        "parameters": [
          {
            "name": "transactionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transaction detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTransaction",
        "summary": "Update a transaction",
        "parameters": [
          {
            "name": "transactionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTransaction",
        "summary": "Delete a transaction",
        "parameters": [
          {
            "name": "transactionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    }
  }
}