{
  "name": "Post to social media with Ampost",
  "nodes": [
    {
      "parameters": {},
      "id": "4b0d5a52-7f43-4a8e-9a43-0f3a5d1f6b01",
      "name": "Run it",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1f0c3d2-1b44-4c55-8d66-7e7788990011",
              "name": "text",
              "value": "Hello from n8n and Ampost!",
              "type": "string"
            },
            {
              "id": "a1f0c3d2-1b44-4c55-8d66-7e7788990012",
              "name": "platforms",
              "value": "bluesky,threads",
              "type": "string"
            },
            {
              "id": "a1f0c3d2-1b44-4c55-8d66-7e7788990013",
              "name": "link",
              "value": "",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "4b0d5a52-7f43-4a8e-9a43-0f3a5d1f6b02",
      "name": "Post content",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [220, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.ampost.io/api/posts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "=n8n-{{ $execution.id }}-{{ $itemIndex }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify(Object.assign({ targets: [{ platforms: $json.platforms.split(',').map(p => p.trim()).filter(p => p) }], text: $json.text, publishNow: true }, $json.link ? { linkUrl: $json.link } : {})) }}",
        "options": {}
      },
      "id": "4b0d5a52-7f43-4a8e-9a43-0f3a5d1f6b03",
      "name": "Ampost: create post",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "credentials": {
        "httpHeaderAuth": {
          "id": "ampostApiKey",
          "name": "Ampost API key"
        }
      }
    }
  ],
  "connections": {
    "Run it": {
      "main": [[{ "node": "Post content", "type": "main", "index": 0 }]]
    },
    "Post content": {
      "main": [[{ "node": "Ampost: create post", "type": "main", "index": 0 }]]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
