From c15c5e389224498e31864c5c88ca6682031d28dc Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Tue, 3 Feb 2026 08:10:13 -0500 Subject: [PATCH] docs(06): create phase plan for n8n API access Phase 6: n8n API Access - 1 plan in 1 wave - Covers API-01 through API-04 requirements - Human checkpoint for API key creation + automated verification - Fixed: Use PUT (not PATCH) per current n8n docs Co-Authored-By: Claude Opus 4.5 --- .../phases/06-n8n-api-access/06-01-PLAN.md | 15 ++++++++------- .../phases/06-n8n-api-access/06-RESEARCH.md | 18 +++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.planning/phases/06-n8n-api-access/06-01-PLAN.md b/.planning/phases/06-n8n-api-access/06-01-PLAN.md index 8b98e40..e0078c1 100644 --- a/.planning/phases/06-n8n-api-access/06-01-PLAN.md +++ b/.planning/phases/06-n8n-api-access/06-01-PLAN.md @@ -115,15 +115,16 @@ Output: Verified API access with documented curl commands for workflow CRUD and -H "accept: application/json" \ -H "X-N8N-API-KEY: ${N8N_API_KEY}") - # PATCH with same nodes/connections (no-op update to verify write access) - echo "$WORKFLOW" | jq '{nodes: .nodes, connections: .connections}' | \ - curl -s -X PATCH "${N8N_HOST}/api/v1/workflows/{WORKFLOW_ID}" \ + # PUT with same nodes/connections (no-op update to verify write access) + # Note: n8n public API uses PUT (full update), not PATCH + echo "$WORKFLOW" | jq '{name: .name, nodes: .nodes, connections: .connections, settings: .settings}' | \ + curl -s -X PUT "${N8N_HOST}/api/v1/workflows/{WORKFLOW_ID}" \ -H "accept: application/json" \ -H "X-N8N-API-KEY: ${N8N_API_KEY}" \ -H "Content-Type: application/json" \ -d @- | jq '.updatedAt' ``` - Expected: Updated timestamp returned (workflow accepted the PATCH) + Expected: Updated timestamp returned (workflow accepted the PUT) 4. **API-04: Execution History** - View recent workflow runs ```bash @@ -145,13 +146,13 @@ Output: Verified API access with documented curl commands for workflow CRUD and All 4 curl commands return successful JSON responses: - GET /api/v1/workflows returns 200 with workflow list - GET /api/v1/workflows/{id} returns 200 with full workflow JSON - - PATCH /api/v1/workflows/{id} returns 200 with updated timestamp + - PUT /api/v1/workflows/{id} returns 200 with updated timestamp - GET /api/v1/executions returns 200 with execution records - API-01: API key authenticates successfully (no 401/403) - API-02: Can read full workflow JSON including nodes and connections - - API-03: Can push workflow changes (PATCH accepted, updatedAt changed) + - API-03: Can push workflow changes (PUT accepted, updatedAt changed) - API-04: Can view execution history with status for each run - .env.n8n-api created with credentials (gitignored) @@ -171,7 +172,7 @@ Run the 4 verification curl commands and confirm: All 4 requirements verified with working curl commands: - API-01: n8n API key created and accessible (curl returns 200) - API-02: Claude Code can read workflow via API (full JSON retrieved) -- API-03: Claude Code can update workflow via API (PATCH succeeds) +- API-03: Claude Code can update workflow via API (PUT succeeds) - API-04: Claude Code can view execution history and logs (executions listed) diff --git a/.planning/phases/06-n8n-api-access/06-RESEARCH.md b/.planning/phases/06-n8n-api-access/06-RESEARCH.md index 2d9e931..cb70af4 100644 --- a/.planning/phases/06-n8n-api-access/06-RESEARCH.md +++ b/.planning/phases/06-n8n-api-access/06-RESEARCH.md @@ -103,7 +103,7 @@ const updated = await n8nClient.patch(`/api/v1/workflows/${workflowId}`, { **When to use:** Making incremental changes to existing workflows **Example:** ```javascript -// Source: Community workflow manager patterns +// Source: n8n official docs - public API uses PUT (full replace) async function updateWorkflowNode(workflowId, nodeName, newParams) { // 1. Fetch current workflow const { data: workflow } = await n8nClient.get(`/api/v1/workflows/${workflowId}`); @@ -114,8 +114,9 @@ async function updateWorkflowNode(workflowId, nodeName, newParams) { node.parameters = { ...node.parameters, ...newParams }; } - // 3. Push updated workflow - const { data: updated } = await n8nClient.patch(`/api/v1/workflows/${workflowId}`, { + // 3. Push updated workflow (PUT requires full workflow body) + const { data: updated } = await n8nClient.put(`/api/v1/workflows/${workflowId}`, { + name: workflow.name, nodes: workflow.nodes, connections: workflow.connections, settings: workflow.settings @@ -275,16 +276,19 @@ curl -X GET 'http://localhost:5678/api/v1/workflows/1' \ -H 'X-N8N-API-KEY: n8n_api_...' ``` -### Update Workflow (Partial) +### Update Workflow (Full Replace) ```bash -# Source: Community workflow manager patterns -curl -X PATCH 'http://localhost:5678/api/v1/workflows/1' \ +# Source: n8n official docs - public API uses PUT for workflow updates +# Note: Must include name, nodes, connections, settings (full workflow body) +curl -X PUT 'http://localhost:5678/api/v1/workflows/1' \ -H 'accept: application/json' \ -H 'X-N8N-API-KEY: n8n_api_...' \ -H 'Content-Type: application/json' \ -d '{ + "name": "Workflow Name", "nodes": [...updated nodes array...], - "connections": {...updated connections...} + "connections": {...updated connections...}, + "settings": {} }' ```