claude-memory/graph/code-patterns/pattern-n8n-rest-api-workflow-activation-sequence-de4a3c.md
2026-03-01 09:59:09 -06:00

79 lines
2.2 KiB
Markdown

---
id: de4a3c65-6eb5-4f73-ad69-685dba0a7847
type: code_pattern
title: "Pattern: N8N REST API workflow activation sequence"
tags: [n8n, api, workflow-activation, rest-api, code_pattern]
importance: 0.65
confidence: 0.8
created: "2026-03-01T15:58:51.499347+00:00"
updated: "2026-03-01T15:59:09.577761+00:00"
relations:
- target: 22d124fd-34e9-4538-acef-9962642a0e54
type: RELATED_TO
direction: outgoing
strength: 0.83
edge_id: e3349a77-3b63-4acd-a4cd-ae3a61882888
- target: e085b8bf-6fbf-4fb7-aded-4d2d651fc2e6
type: RELATED_TO
direction: outgoing
strength: 0.75
edge_id: 38900429-ad4c-4096-a396-8d1e200a6b88
- target: 39379120-896b-46cd-befa-b83d09d7556b
type: RELATED_TO
direction: outgoing
strength: 0.82
edge_id: 24cf1f3d-585a-43b5-a723-0727c9252efe
- target: c3070599-c723-4993-bada-3103e6f03e53
type: CAUSES
direction: incoming
strength: 0.95
edge_id: 27f91cb1-068d-48ef-b8d9-7b101a5f3ebb
- target: 67898e52-470a-470e-b149-43fef0047ae9
type: RELATED_TO
direction: outgoing
strength: 0.8
edge_id: 79c28e76-ff78-4b5e-8e34-194d5536ced1
---
# N8N REST API Workflow Activation Pattern
## Use Case
When you need to update and activate an n8n workflow programmatically (e.g., after MCP corruption recovery, or scripted deployments).
## Steps
### 1. Fetch current workflow
```
GET /api/v1/workflows/{id}
```
### 2. PUT with clean body
```
PUT /api/v1/workflows/{id}
Body: { name, nodes, connections, settings }
```
**`settings` must only include standard fields:**
- `executionOrder`
- `timezone`
- `callerPolicy`
Custom/non-standard settings (e.g., `timeSavedMode`) cause "additional properties" validation errors.
**Omit all read-only fields from the PUT body:**
- `id`, `active`, `createdAt`, `updatedAt`, `shared`, `meta`
### 3. Activate separately
```
POST /api/v1/workflows/{id}/activate
```
The `active` field is read-only on PUT — activation must be done via the dedicated `/activate` endpoint.
## Notes
- This pattern is the recovery path when MCP partial updates corrupt a workflow
- Always GET first to ensure node definitions match what's installed
## Tags
n8n, api, workflow-activation, rest-api