Skip to content

In n8n, copy this file and paste it onto the canvas, or use Import from File.

{
  "name": "01 - Text Post API (starter)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "posts",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "text-post-playground"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "p1",
              "name": "id",
              "value": "={{ $execution.id }}",
              "type": "string"
            },
            {
              "id": "p2",
              "name": "author",
              "value": "={{ $json.body.author || 'anonymous' }}",
              "type": "string"
            },
            {
              "id": "p3",
              "name": "text",
              "value": "={{ $json.body.text }}",
              "type": "string"
            },
            {
              "id": "p4",
              "name": "length",
              "value": "={{ ($json.body.text || '').length }}",
              "type": "number"
            },
            {
              "id": "p5",
              "name": "createdAt",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0002-4000-8000-000000000002",
      "name": "Build Post",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      },
      "id": "a1b2c3d4-0003-4000-8000-000000000003",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        440,
        0
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Build Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Post": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}