create_category
Add a new budget category with name, group, goal targets, and notes to organize your finances in YNAB.
Instructions
[1 API call] Create a new category in a budget
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| budget_id | No | Budget ID or 'last-used' | last-used |
| name | Yes | Category name | |
| category_group_id | Yes | ID of the category group to add this category to | |
| note | No | Category note | |
| goal_target | No | Goal target amount in dollars | |
| goal_target_date | No | Goal target date (YYYY-MM-DD) |
Implementation Reference
- src/tools/categories.ts:69-97 (handler)The "create_category" tool definition and handler implementation.
server.registerTool("create_category", { title: "Create Category", description: "[1 API call] Create a new category in a budget", inputSchema: { budget_id: z.string().default("last-used").describe("Budget ID or 'last-used'"), name: z.string().describe("Category name"), category_group_id: z.string().describe("ID of the category group to add this category to"), note: z.string().optional().describe("Category note"), goal_target: z.number().optional().describe("Goal target amount in dollars"), goal_target_date: z.string().optional().describe("Goal target date (YYYY-MM-DD)"), }, annotations: { readOnlyHint: false }, }, async ({ budget_id, name, category_group_id, note, goal_target, goal_target_date }) => { try { const response = await getClient().categories.createCategory(budget_id, { category: { name, category_group_id, note, goal_target: goal_target != null ? dollarsToMilliunits(goal_target) : undefined, goal_target_date, }, }); const c = response.data.category; return textResult(`Created category "${c.name}"\nID: ${c.id}`); } catch (e: any) { return errorResult(e.message); } });