{
  "name": "Google Sheet \u2192 TokPortal bundles (bulk account creation)",
  "nodes": [
    {
      "parameters": {
        "content": "## Google Sheet \u2192 TokPortal bundles\nEach row of the sheet becomes a **TokPortal bundle**: a real TikTok/Instagram account created and warmed by a human account manager.\n\n**Sheet columns:** `platform`, `country`, `username`, `visible_name`, `bio`, `profile_picture_url`, `videos_quantity`, `external_ref`\n\nCredits are debited on **Create**. The bundle ID and status are written back to the row.",
        "height": 260,
        "width": 620,
        "color": 4
      },
      "id": "tp-002",
      "name": "Sticky Notetp-001",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -260
      ]
    },
    {
      "parameters": {},
      "id": "tp-003",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        100
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/REPLACE_SHEET_ID/edit"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "accounts"
        },
        "options": {}
      },
      "id": "tp-004",
      "name": "Read Sheet Rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        220,
        100
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "f1",
              "leftValue": "={{ $json.bundle_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "tp-005",
      "name": "Only Rows Without Bundle",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        440,
        100
      ]
    },
    {
      "parameters": {
        "resource": "bundle",
        "operation": "create",
        "bundleType": "account_and_videos",
        "platform": "={{ $json.platform || \"tiktok\" }}",
        "country": "={{ $json.country }}",
        "videosQuantity": "={{ Number($json.videos_quantity || 0) }}",
        "additionalFields": {
          "title": "={{ \"Sheet: \" + $json.username }}",
          "external_ref": "={{ $json.external_ref || (\"sheet-row-\" + $json.row_number) }}",
          "wants_advanced_warming": true,
          "advanced_warming_terms_count": 6
        }
      },
      "id": "tp-006",
      "name": "Create Bundle",
      "type": "n8n-nodes-tokportal.tokPortal",
      "typeVersion": 1,
      "position": [
        660,
        100
      ],
      "credentials": {
        "tokPortalApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "bundle",
        "operation": "configureAccount",
        "bundleId": "={{ $json.id }}",
        "username": "={{ $(\"Only Rows Without Bundle\").item.json.username }}",
        "visibleName": "={{ $(\"Only Rows Without Bundle\").item.json.visible_name }}",
        "additionalFields": {
          "biography": "={{ $(\"Only Rows Without Bundle\").item.json.bio }}",
          "profile_picture_url": "={{ $(\"Only Rows Without Bundle\").item.json.profile_picture_url }}"
        }
      },
      "id": "tp-007",
      "name": "Configure Account Profile",
      "type": "n8n-nodes-tokportal.tokPortal",
      "typeVersion": 1,
      "position": [
        880,
        100
      ],
      "credentials": {
        "tokPortalApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "bundle",
        "operation": "publish",
        "bundleId": "={{ $(\"Create Bundle\").item.json.id }}"
      },
      "id": "tp-008",
      "name": "Publish Bundle",
      "type": "n8n-nodes-tokportal.tokPortal",
      "typeVersion": 1,
      "position": [
        1100,
        100
      ],
      "credentials": {
        "tokPortalApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/REPLACE_SHEET_ID/edit"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "accounts"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $(\"Only Rows Without Bundle\").item.json.row_number }}",
            "bundle_id": "={{ $(\"Create Bundle\").item.json.id }}",
            "status": "={{ $json.status }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "bundle_id",
              "displayName": "bundle_id",
              "type": "string"
            },
            {
              "id": "status",
              "displayName": "status",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "tp-009",
      "name": "Write Back Bundle ID",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1320,
        100
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Read Sheet Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Sheet Rows": {
      "main": [
        [
          {
            "node": "Only Rows Without Bundle",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only Rows Without Bundle": {
      "main": [
        [
          {
            "node": "Create Bundle",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Bundle": {
      "main": [
        [
          {
            "node": "Configure Account Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Account Profile": {
      "main": [
        [
          {
            "node": "Publish Bundle",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish Bundle": {
      "main": [
        [
          {
            "node": "Write Back Bundle ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    {
      "name": "TokPortal"
    }
  ]
}