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 <noreply@anthropic.com>
This commit is contained in:
@@ -115,15 +115,16 @@ Output: Verified API access with documented curl commands for workflow CRUD and
|
|||||||
-H "accept: application/json" \
|
-H "accept: application/json" \
|
||||||
-H "X-N8N-API-KEY: ${N8N_API_KEY}")
|
-H "X-N8N-API-KEY: ${N8N_API_KEY}")
|
||||||
|
|
||||||
# PATCH with same nodes/connections (no-op update to verify write access)
|
# PUT with same nodes/connections (no-op update to verify write access)
|
||||||
echo "$WORKFLOW" | jq '{nodes: .nodes, connections: .connections}' | \
|
# Note: n8n public API uses PUT (full update), not PATCH
|
||||||
curl -s -X PATCH "${N8N_HOST}/api/v1/workflows/{WORKFLOW_ID}" \
|
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 "accept: application/json" \
|
||||||
-H "X-N8N-API-KEY: ${N8N_API_KEY}" \
|
-H "X-N8N-API-KEY: ${N8N_API_KEY}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @- | jq '.updatedAt'
|
-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
|
4. **API-04: Execution History** - View recent workflow runs
|
||||||
```bash
|
```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:
|
All 4 curl commands return successful JSON responses:
|
||||||
- GET /api/v1/workflows returns 200 with workflow list
|
- GET /api/v1/workflows returns 200 with workflow list
|
||||||
- GET /api/v1/workflows/{id} returns 200 with full workflow JSON
|
- 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
|
- GET /api/v1/executions returns 200 with execution records
|
||||||
</verify>
|
</verify>
|
||||||
<done>
|
<done>
|
||||||
- API-01: API key authenticates successfully (no 401/403)
|
- API-01: API key authenticates successfully (no 401/403)
|
||||||
- API-02: Can read full workflow JSON including nodes and connections
|
- 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
|
- API-04: Can view execution history with status for each run
|
||||||
- .env.n8n-api created with credentials (gitignored)
|
- .env.n8n-api created with credentials (gitignored)
|
||||||
</done>
|
</done>
|
||||||
@@ -171,7 +172,7 @@ Run the 4 verification curl commands and confirm:
|
|||||||
All 4 requirements verified with working curl commands:
|
All 4 requirements verified with working curl commands:
|
||||||
- API-01: n8n API key created and accessible (curl returns 200)
|
- API-01: n8n API key created and accessible (curl returns 200)
|
||||||
- API-02: Claude Code can read workflow via API (full JSON retrieved)
|
- 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)
|
- API-04: Claude Code can view execution history and logs (executions listed)
|
||||||
</success_criteria>
|
</success_criteria>
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ const updated = await n8nClient.patch(`/api/v1/workflows/${workflowId}`, {
|
|||||||
**When to use:** Making incremental changes to existing workflows
|
**When to use:** Making incremental changes to existing workflows
|
||||||
**Example:**
|
**Example:**
|
||||||
```javascript
|
```javascript
|
||||||
// Source: Community workflow manager patterns
|
// Source: n8n official docs - public API uses PUT (full replace)
|
||||||
async function updateWorkflowNode(workflowId, nodeName, newParams) {
|
async function updateWorkflowNode(workflowId, nodeName, newParams) {
|
||||||
// 1. Fetch current workflow
|
// 1. Fetch current workflow
|
||||||
const { data: workflow } = await n8nClient.get(`/api/v1/workflows/${workflowId}`);
|
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 };
|
node.parameters = { ...node.parameters, ...newParams };
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Push updated workflow
|
// 3. Push updated workflow (PUT requires full workflow body)
|
||||||
const { data: updated } = await n8nClient.patch(`/api/v1/workflows/${workflowId}`, {
|
const { data: updated } = await n8nClient.put(`/api/v1/workflows/${workflowId}`, {
|
||||||
|
name: workflow.name,
|
||||||
nodes: workflow.nodes,
|
nodes: workflow.nodes,
|
||||||
connections: workflow.connections,
|
connections: workflow.connections,
|
||||||
settings: workflow.settings
|
settings: workflow.settings
|
||||||
@@ -275,16 +276,19 @@ curl -X GET 'http://localhost:5678/api/v1/workflows/1' \
|
|||||||
-H 'X-N8N-API-KEY: n8n_api_...'
|
-H 'X-N8N-API-KEY: n8n_api_...'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Update Workflow (Partial)
|
### Update Workflow (Full Replace)
|
||||||
```bash
|
```bash
|
||||||
# Source: Community workflow manager patterns
|
# Source: n8n official docs - public API uses PUT for workflow updates
|
||||||
curl -X PATCH 'http://localhost:5678/api/v1/workflows/1' \
|
# 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 'accept: application/json' \
|
||||||
-H 'X-N8N-API-KEY: n8n_api_...' \
|
-H 'X-N8N-API-KEY: n8n_api_...' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{
|
-d '{
|
||||||
|
"name": "Workflow Name",
|
||||||
"nodes": [...updated nodes array...],
|
"nodes": [...updated nodes array...],
|
||||||
"connections": {...updated connections...}
|
"connections": {...updated connections...},
|
||||||
|
"settings": {}
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user