{ "nodes": [ { "name": "On clicking 'execute'", "type": "n8n-nodes-base.manualTrigger", "position": [ 250, 200 ], "parameters": {}, "typeVersion": 1, "id": "create-update-and-read-webflow-item-0" }, { "id": "create-update-and-read-webflow-item-1", "name": "Prepare item details", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const collectionId='YOUR_COLLECTION_ID',name='YOUR_ITEM_NAME',slug='YOUR_ITEM_SLUG',imageUrl='YOUR_PUBLIC_IMAGE_URL';for(const [k,v] of Object.entries({collectionId,name,slug,imageUrl}))if(!v||v.startsWith('YOUR_'))throw Error('Set '+k);return [{json:{collectionId,name,slug,imageUrl}}];" } }, { "name": "Create CMS item", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "parameters": { "method": "POST", "url": "={{ 'https://api.webflow.com/v2/collections/'+$json.collectionId+'/items' }}", "authentication": "predefinedCredentialType", "nodeCredentialType": "webflowOAuth2Api", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({isDraft:false,isArchived:false,fieldData:{name:$json.name,slug:$json.slug}}) }}", "options": {} }, "id": "create-update-and-read-webflow-item-2" }, { "id": "create-update-and-read-webflow-item-3", "name": "Prepare avatar update", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const item=$input.first().json,c=$('Prepare item details').first().json;if(!item.id||!item.fieldData?.name||!item.fieldData?.slug)throw Error('Missing created item details');return [{json:{collectionId:c.collectionId,itemId:item.id,fieldData:{name:item.fieldData.name,slug:item.fieldData.slug,avatar:{url:c.imageUrl}}}}];" } }, { "name": "Update item avatar", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "parameters": { "method": "PATCH", "url": "={{ 'https://api.webflow.com/v2/collections/'+$json.collectionId+'/items/'+$json.itemId }}", "authentication": "predefinedCredentialType", "nodeCredentialType": "webflowOAuth2Api", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({isDraft:false,isArchived:false,fieldData:$json.fieldData}) }}", "options": {} }, "id": "create-update-and-read-webflow-item-4" }, { "id": "create-update-and-read-webflow-item-5", "name": "Confirm avatar update", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const x=$input.first().json,c=$('Prepare avatar update').first().json;if(x.id!==c.itemId||x.isDraft!==false||x.isArchived!==false||typeof x.fieldData?.avatar?.url!=='string'||!x.fieldData.avatar.url)throw Error('Webflow did not confirm the avatar on the created item');return [{json:{collectionId:c.collectionId,itemId:c.itemId}}];" } }, { "name": "Read updated item", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "parameters": { "method": "GET", "url": "={{ 'https://api.webflow.com/v2/collections/'+$json.collectionId+'/items/'+$json.itemId }}", "authentication": "predefinedCredentialType", "nodeCredentialType": "webflowOAuth2Api", "options": {} }, "id": "create-update-and-read-webflow-item-6" } ], "connections": { "On clicking 'execute'": { "main": [ [ { "node": "Prepare item details", "type": "main", "index": 0 } ] ] }, "Prepare item details": { "main": [ [ { "node": "Create CMS item", "type": "main", "index": 0 } ] ] }, "Create CMS item": { "main": [ [ { "node": "Prepare avatar update", "type": "main", "index": 0 } ] ] }, "Prepare avatar update": { "main": [ [ { "node": "Update item avatar", "type": "main", "index": 0 } ] ] }, "Update item avatar": { "main": [ [ { "node": "Confirm avatar update", "type": "main", "index": 0 } ] ] }, "Confirm avatar update": { "main": [ [ { "node": "Read updated item", "type": "main", "index": 0 } ] ] } }, "name": "Create, Update and Read a Webflow CMS Item", "active": false, "pinData": {} }