This workflow corresponds to n8n.io template #13134 — we link there as the canonical source.
This workflow follows the Facebookgraphapi → Google Sheets recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "8D5WBdOceM9wP1jh",
"name": "Meta Ads Detailed Targeting (Universal, Switch by Endpoint)",
"tags": [
{
"id": "tITAFvUSOpVVIBvI",
"name": "MetaAds",
"createdAt": "2025-07-05T02:24:26.705Z",
"updatedAt": "2025-07-05T02:24:26.705Z"
},
{
"id": "8ZOxg8cY0fPL8g0s",
"name": "ReadyToUse",
"createdAt": "2025-07-10T04:08:19.089Z",
"updatedAt": "2025-07-10T04:08:19.089Z"
},
{
"id": "3Kr9akgvGQXhCtQJ",
"name": "ForPublishing",
"createdAt": "2025-08-13T13:36:55.022Z",
"updatedAt": "2025-08-13T13:36:55.022Z"
}
],
"nodes": [
{
"id": "e05b0000-6b5c-494f-90cd-f189781746a5",
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-816,
416
],
"parameters": {},
"typeVersion": 1
},
{
"id": "27b94aee-e8e6-4714-8f24-d4db290c9768",
"name": "Read Input (Google Sheets)",
"type": "n8n-nodes-base.googleSheets",
"position": [
-592,
416
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit#gid=0",
"cachedResultName": "targeting_requests"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit?usp=drivesdk",
"cachedResultName": "Meta Ads | Detailed targeting"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.6
},
{
"id": "a78b61c5-1e48-4621-9d60-3e811577183b",
"name": "Valid rows (ad_account_id + endpoint)",
"type": "n8n-nodes-base.filter",
"position": [
-384,
416
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c1",
"operator": {
"type": "string",
"operation": "notEmpty"
},
"leftValue": "={{ $json.ad_account_id }}",
"rightValue": ""
},
{
"id": "c2",
"operator": {
"type": "string",
"operation": "notEmpty"
},
"leftValue": "={{ $json.endpoint }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "5a8d62df-ef70-44df-9080-e6af2e836eba",
"name": "Switch by endpoint",
"type": "n8n-nodes-base.switch",
"position": [
-160,
400
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Search",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "s1",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.endpoint }}",
"rightValue": "search"
}
]
},
"renameOutput": true
},
{
"outputKey": "Suggestions",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "s2",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.endpoint }}",
"rightValue": "suggestions"
}
]
},
"renameOutput": true
},
{
"outputKey": "Browse",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "s3",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.endpoint }}",
"rightValue": "browse"
}
]
},
"renameOutput": true
},
{
"outputKey": "Validation",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "s4",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.endpoint }}",
"rightValue": "validation"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.3
},
{
"id": "25093240-0bd9-466d-986a-b9694b533d74",
"name": "API Search",
"type": "n8n-nodes-base.facebookGraphApi",
"position": [
80,
96
],
"parameters": {
"edge": "targetingsearch",
"node": "=act_{{ $json.ad_account_id }}",
"options": {
"queryParameters": {
"parameter": [
{
"name": "q",
"value": "={{ $json[\"q (keyword)\"] }}"
},
{
"name": "limit",
"value": "={{ $json.limit || 1000 }}"
},
{
"name": "limit_type",
"value": "={{ $json.limit_type || '' }}"
},
{
"name": "locale",
"value": "={{ $json.locale || '' }}"
}
]
}
},
"graphApiVersion": "v23.0"
},
"credentials": {
"facebookGraphApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "53e5b635-9906-4cfe-8cba-51343fb8b57e",
"name": "API Suggestions",
"type": "n8n-nodes-base.facebookGraphApi",
"position": [
80,
336
],
"parameters": {
"edge": "targetingsuggestions",
"node": "=act_{{ $json.ad_account_id }}",
"options": {
"queryParameters": {
"parameter": [
{
"name": "targeting_list",
"value": "={{ $json.targeting_list }}"
},
{
"name": "limit",
"value": "={{ $json.limit || 1000 }}"
},
{
"name": "limit_type",
"value": "={{ $json.limit_type}}"
},
{
"name": "locale",
"value": "={{ $json.locale || '' }}"
}
]
}
},
"graphApiVersion": "v23.0"
},
"credentials": {
"facebookGraphApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "2aa0e47c-819b-480a-ae72-e7cef5ce6a7e",
"name": "API Browse",
"type": "n8n-nodes-base.facebookGraphApi",
"position": [
80,
576
],
"parameters": {
"edge": "targetingbrowse",
"node": "=act_{{ $json.ad_account_id }}",
"options": {
"queryParameters": {
"parameter": [
{
"name": "limit_type",
"value": "={{ $json.limit_type || '' }}"
},
{
"name": "locale",
"value": "={{ $json.locale || '' }}"
}
]
}
},
"graphApiVersion": "v23.0"
},
"credentials": {
"facebookGraphApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "28f0f7b3-1098-4986-b7db-a8c600a2178e",
"name": "API Validation",
"type": "n8n-nodes-base.facebookGraphApi",
"position": [
80,
816
],
"parameters": {
"edge": "targetingvalidation",
"node": "=act_{{ $json.ad_account_id }}",
"options": {
"queryParameters": {
"parameter": [
{
"name": "targeting_list",
"value": "={{ $json.targeting_list }}"
},
{
"name": "locale",
"value": "={{ $json.locale || '' }}"
}
]
}
},
"graphApiVersion": "v23.0"
},
"credentials": {
"facebookGraphApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "3ceb2479-d1ab-404e-b49e-ad5028e87766",
"name": "Merge Search",
"type": "n8n-nodes-base.merge",
"position": [
320,
96
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.2
},
{
"id": "fa27ee58-7cc9-4be2-8ca9-e26588252e1d",
"name": "Merge Suggestions",
"type": "n8n-nodes-base.merge",
"position": [
320,
336
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.2
},
{
"id": "177fa3e5-7acc-45ab-af2e-afd8a31378b1",
"name": "Merge Browse",
"type": "n8n-nodes-base.merge",
"position": [
320,
576
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.2
},
{
"id": "c438e33c-3542-4001-aa5f-abb5696ab86c",
"name": "Merge Validation",
"type": "n8n-nodes-base.merge",
"position": [
320,
816
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.2
},
{
"id": "c689afc0-3551-48ec-871d-240fd89baa10",
"name": "Split Search",
"type": "n8n-nodes-base.splitOut",
"position": [
560,
96
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "data"
},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "4c2df6b3-4eae-4d26-9a3e-46830e8fcd90",
"name": "Split Suggestions",
"type": "n8n-nodes-base.splitOut",
"position": [
560,
336
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "data"
},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "3f18ac94-689f-4799-ab20-5f8569030ea5",
"name": "Split Browse",
"type": "n8n-nodes-base.splitOut",
"position": [
560,
576
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "data"
},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "1749dc20-580e-4a15-bbc1-af58f819505c",
"name": "Split Validation",
"type": "n8n-nodes-base.splitOut",
"position": [
560,
816
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "data"
},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "58529400-1fb0-4b7f-b70e-91f047657c67",
"name": "Format Search",
"type": "n8n-nodes-base.set",
"position": [
800,
96
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "e1",
"name": "endpoint",
"type": "string",
"value": "search"
},
{
"id": "a1",
"name": "ad_account_id",
"type": "string",
"value": "={{ $json.ad_account_id }}"
},
{
"id": "q1",
"name": "query",
"type": "string",
"value": "={{ $json[\"q (keyword)\"] }}"
},
{
"id": "lt1",
"name": "limit_type",
"type": "string",
"value": "={{ $json.data.type }}"
},
{
"id": "t1",
"name": "targeting_id",
"type": "string",
"value": "={{ $json.data.id }}"
},
{
"id": "t2",
"name": "targeting_name",
"type": "string",
"value": "={{ $json.data.name || '' }}"
},
{
"id": "lb",
"name": "audience_size_lower_bound",
"type": "number",
"value": "={{ $json.data.audience_size_lower_bound }}"
},
{
"id": "ub",
"name": "audience_size_upper_bound",
"type": "number",
"value": "={{ $json.data.audience_size_upper_bound }}"
},
{
"id": "p1",
"name": "path",
"type": "string",
"value": "={{ Array.isArray($json.data.path) ? $json.data.path.join(' > ') : ($json.data.path || '') }}"
},
{
"id": "d1",
"name": "description",
"type": "string",
"value": "={{ $json.data.description || ''}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "832eaf83-14f8-44f3-8ef2-8e9e958e070f",
"name": "Format Suggestions",
"type": "n8n-nodes-base.set",
"position": [
800,
336
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "e2",
"name": "endpoint",
"type": "string",
"value": "suggestions"
},
{
"id": "a2",
"name": "ad_account_id",
"type": "string",
"value": "={{ $json.ad_account_id }}"
},
{
"id": "q2",
"name": "query",
"type": "string",
"value": "={{ $json.targeting_list || '' }}"
},
{
"id": "lt2",
"name": "limit_type",
"type": "string",
"value": "={{ $json.data.type }}"
},
{
"id": "t3",
"name": "targeting_id",
"type": "string",
"value": "={{ $json.data.id }}"
},
{
"id": "t4",
"name": "targeting_name",
"type": "string",
"value": "={{ $json.data.name }}"
},
{
"id": "lb2",
"name": "audience_size_lower_bound",
"type": "number",
"value": "={{ $json.data.audience_size_lower_bound }}"
},
{
"id": "ub2",
"name": "audience_size_upper_bound",
"type": "number",
"value": "={{ $json.data.audience_size_upper_bound }}"
},
{
"id": "p2",
"name": "path",
"type": "string",
"value": "={{ Array.isArray($json.data.path ) ? $json.data.path .join(' > ') : ($json.data.path) }}"
},
{
"id": "d2",
"name": "description",
"type": "string",
"value": "={{ $json.data.description || '' }}"
},
{
"id": "ty2",
"name": "type",
"type": "string",
"value": "={{ $json.data.type }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "e1cd0e1f-aa68-44d5-a6d1-5232c86570b7",
"name": "Format Browse",
"type": "n8n-nodes-base.set",
"position": [
800,
576
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "e3",
"name": "endpoint",
"type": "string",
"value": "browse"
},
{
"id": "a3",
"name": "ad_account_id",
"type": "string",
"value": "={{ $json.ad_account_id }}"
},
{
"id": "lt3",
"name": "limit_type",
"type": "string",
"value": "={{ $json.limit_type || '' }}"
},
{
"id": "t5",
"name": "targeting_id",
"type": "string",
"value": "={{ $json.data.id }}"
},
{
"id": "t6",
"name": "targeting_name",
"type": "string",
"value": "={{ $json.data.raw_name }}"
},
{
"id": "lb3",
"name": "audience_size_lower_bound",
"type": "number",
"value": "={{ $json.data.audience_size_lower_bound }}"
},
{
"id": "ub3",
"name": "audience_size_upper_bound",
"type": "number",
"value": "={{ $json.data.audience_size_upper_bound }}"
},
{
"id": "p3",
"name": "path",
"type": "string",
"value": "={{ Array.isArray($json.data.path) ? $json.data.path.join(' > ') : ($json.data.path || '') }}"
},
{
"id": "d3",
"name": "description",
"type": "string",
"value": "={{ $json.data.description || '' }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "8c476157-11c1-46be-95b7-ab3483ee9164",
"name": "Format Validation",
"type": "n8n-nodes-base.set",
"position": [
800,
816
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "e4",
"name": "endpoint",
"type": "string",
"value": "validation"
},
{
"id": "a4",
"name": "ad_account_id",
"type": "string",
"value": "={{ $json.ad_account_id }}"
},
{
"id": "lt4",
"name": "limit_type",
"type": "string",
"value": "={{ $json.limit_type }}"
},
{
"id": "t7",
"name": "targeting_id",
"type": "string",
"value": "={{ $json.data.id }}"
},
{
"id": "t8",
"name": "targeting_name",
"type": "string",
"value": "={{ $json.data.name }}"
},
{
"id": "lb4",
"name": "audience_size_lower_bound",
"type": "number",
"value": "={{ $json.data.audience_size_lower_bound }}"
},
{
"id": "ub4",
"name": "audience_size_upper_bound",
"type": "number",
"value": "={{ $json.data.audience_size_upper_bound }}"
},
{
"id": "p4",
"name": "path",
"type": "string",
"value": "={{ Array.isArray($json.data.path) ? $json.data.path.join(' > ') : ($json.data.path) }}"
},
{
"id": "d4",
"name": "description",
"type": "string",
"value": "={{ $json.description || '' }}"
},
{
"id": "v4",
"name": "valid",
"type": "string",
"value": "={{ $json.data.valid }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "e13f208b-df3a-4720-9904-5546da62b4bb",
"name": "Save search_results",
"type": "n8n-nodes-base.googleSheets",
"position": [
1040,
96
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "targeting_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "targeting_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "query",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "limit_type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "limit_type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "targeting_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "targeting_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "audience_size_lower_bound",
"type": "string",
"display": true,
"required": false,
"displayName": "audience_size_lower_bound",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "audience_size_upper_bound",
"type": "string",
"display": true,
"required": false,
"displayName": "audience_size_upper_bound",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "path",
"type": "string",
"display": true,
"required": false,
"displayName": "path",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "description",
"type": "string",
"display": true,
"required": false,
"displayName": "description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "endpoint",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "endpoint",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ad_account_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ad_account_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "type",
"type": "string",
"display": true,
"required": false,
"displayName": "type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "valid",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "valid",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [
"id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1522930504,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit#gid=1522930504",
"cachedResultName": "search_results"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit?usp=drivesdk",
"cachedResultName": "Meta Ads | Detailed targeting"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.6
},
{
"id": "ad7d72a3-5bf3-4dff-9dfd-3158bbb84af5",
"name": "Save suggestions_results",
"type": "n8n-nodes-base.googleSheets",
"position": [
1040,
336
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "targeting_id",
"type": "string",
"display": true,
"required": false,
"displayName": "targeting_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "targeting_name",
"type": "string",
"display": true,
"required": false,
"displayName": "targeting_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "audience_size_lower_bound",
"type": "string",
"display": true,
"required": false,
"displayName": "audience_size_lower_bound",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "audience_size_upper_bound",
"type": "string",
"display": true,
"required": false,
"displayName": "audience_size_upper_bound",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "path",
"type": "string",
"display": true,
"required": false,
"displayName": "path",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "description",
"type": "string",
"display": true,
"required": false,
"displayName": "description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "type",
"type": "string",
"display": true,
"required": false,
"displayName": "type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "endpoint",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "endpoint",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ad_account_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ad_account_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "query",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "limit_type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "limit_type",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1986966398,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit#gid=1986966398",
"cachedResultName": "suggestions_results"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit?usp=drivesdk",
"cachedResultName": "Meta Ads | Detailed targeting"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.6
},
{
"id": "89aa9063-dc58-4454-87ce-11815a996d70",
"name": "Save browse_results",
"type": "n8n-nodes-base.googleSheets",
"position": [
1040,
576
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "targeting_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "targeting_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "targeting_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "targeting_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "audience_size_lower_bound",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "audience_size_lower_bound",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "audience_size_upper_bound",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "audience_size_upper_bound",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "path",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "path",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "description",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "limit_type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "limit_type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "endpoint",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "endpoint",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ad_account_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ad_account_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "query",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "type",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1871274505,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit#gid=1871274505",
"cachedResultName": "browse_results"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit?usp=drivesdk",
"cachedResultName": "Meta Ads | Detailed targeting"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.6
},
{
"id": "ab2406dc-f805-4bcd-a040-0896b27aa792",
"name": "Save validation_results",
"type": "n8n-nodes-base.googleSheets",
"position": [
1040,
816
],
"parameters": {
"columns": {
"value": {},
"schema": [],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 2094580083,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit#gid=2094580083",
"cachedResultName": "validation_results"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit?usp=drivesdk",
"cachedResultName": "Meta Ads | Detailed targeting"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.6
},
{
"id": "0e53ebdd-6ac3-43f6-9a66-0236a7e995ca",
"name": "Google Sheets Trigger",
"type": "n8n-nodes-base.googleSheetsTrigger",
"position": [
-816,
576
],
"parameters": {
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyHour"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit#gid=0",
"cachedResultName": "targeting_requests"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1n7rMaG_P5cXtsVo8qT6vA5ZfLk_Wpuw4b_iwbrBg2Bs/edit?usp=drivesdk",
"cachedResultName": "Meta Ads | Detailed targeting"
}
},
"credentials": {
"googleSheetsTriggerOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "cddf5a47-3cde-41a8-906b-1314fbd17891",
"name": "Sticky Note - Overview",
"type": "n8n-nodes-base.stickyNote",
"position": [
-864,
-720
],
"parameters": {
"width": 668,
"height": 816,
"content": "# Meta Ads Detailed Targeting (Universal)\n\n## How it works\n\n- Reads requests from **Google Sheets** (sheet `targeting_requests`) or runs when a **new row is added** (Google Sheets Trigger)\n- **Valid rows** keeps only rows with `ad_account_id` and `endpoint` set\n- **Switch by endpoint** routes to one of four API branches: Search, Suggestions, Browse, Validation\n- Each branch: calls **Meta Graph API** (targetingsearch / targetingsuggestions / targetingbrowse / targetingvalidation), **Merge** (response + request row), **Split** (data array), **Format**, then **Save** to a dedicated sheet\n- Results are written to **four sheets** in the same document: `search_results`, `suggestions_results`, `browse_results`, `validation_results`\n\n## Setup steps\n\n1. Set **Document ID** in Read Input, Google Sheets Trigger, and all four Save nodes (same spreadsheet)\n2. Create sheet `targeting_requests` with columns: `endpoint` (search | suggestions | browse | validation), `ad_account_id`, and endpoint-specific: `q`, `targeting_list`, `limit_type`, `limit`, `locale`\n3. Create four result sheets: `search_results`, `suggestions_results`, `browse_results`, `validation_results`\n4. Connect **Google Sheets** and **Facebook Graph API** credentials\n5. For **Suggestions** and **Validation**: `targeting_list` must be a JSON array, e.g. `[{\"type\":\"interests\",\"id\":\"6003263791114\"}]`\n\nBuilt by Kirill Khatkevich \n[Connect on LinkedIn](https://www.linkedin.com/in/kirill-khatkevich/)"
},
"typeVersion": 1
},
{
"id": "e2c5a832-1f27-4841-956a-a69040608e18",
"name": "Sticky Note - Get input & route",
"type": "n8n-nodes-base.stickyNote",
"position": [
-880,
112
],
"parameters": {
"color": 5,
"width": 856,
"height": 624,
"content": "## Get input & route by endpoint\n\n**Manual Trigger** / **Google Sheets Trigger**\nManual runs **Read Input** (whole sheet). Trigger runs when a new row is added to `targeting_requests`.\n\n**Read Input (Google Sheets)**\nReads sheet `targeting_requests`. Each row = one API request.\n\n**Valid rows (ad_account_id + endpoint)**\nKeeps only rows where `ad_account_id` and `endpoint` are not empty.\n\n**Switch by endpoint**\nRoutes each row to the branch matching `endpoint`: search, suggestions, browse, or validation."
},
"typeVersion": 1
},
{
"id": "e8402916-626a-4bf9-a8a5-9da844b96234",
"name": "Sticky Note - API & save",
"type": "n8n-nodes-base.stickyNote",
"position": [
48,
-304
],
"parameters": {
"color": 5,
"width": 1104,
"height": 1280,
"content": "## Call API, merge, split, format & save\n\nEach branch (Search, Suggestions, Browse, Validation):\n\n**API** (Facebook Graph API)\nCalls `act_{ad_account_id}/targetingsearch` (or targetingsuggestions / targetingbrowse / targetingvalidation) with params from the row.\n\n**Merge** (combine by position)\nMerges API response with the request row so each result keeps context (ad_account_id, q, etc.).\n\n**Split** (field: data)\nExpands the `data` array into one item per targeting result.\n\n**Format**\nMaps fields to flat columns for the sheet (targeting_id, targeting_name, audience_size_*, path, description, type, valid for Validation).\n\n**Save to Google Sheets**\nAppends to the branch sheet: search_results, suggestions_results, browse_results, or validation_results."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "bc6a1815-2d49-4efd-a6b0-2dd7e1ddca68",
"connections": {
"API Browse": {
"main": [
[
{
"node": "Merge Browse",
"type": "main",
"index": 0
}
]
]
},
"API Search": {
"main": [
[
{
"node": "Merge Search",
"type": "main",
"index": 0
}
]
]
},
"Merge Browse": {
"main": [
[
{
"node": "Split Browse",
"type": "main",
"index": 0
}
]
]
},
"Merge Search": {
"main": [
[
{
"node": "Split Search",
"type": "main",
"index": 0
}
]
]
},
"Split Browse": {
"main": [
[
{
"node": "Format Browse",
"type": "main",
"index": 0
}
]
]
},
"Split Search": {
"main": [
[
{
"node": "Format Search",
"type": "main",
"index": 0
}
]
]
},
"Format Browse": {
"main": [
[
{
"node": "Save browse_results",
"type": "main",
"index": 0
}
]
]
},
"Format Search": {
"main": [
[
{
"node": "Save search_results",
"type": "main",
"index": 0
}
]
]
},
"API Validation": {
"main": [
[
{
"node": "Merge Validation",
"type": "main",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Read Input (Google Sheets)",
"type": "main",
"index": 0
}
]
]
},
"API Suggestions": {
"main": [
[
{
"node": "Merge Suggestions",
"type": "main",
"index": 0
}
]
]
},
"Merge Validation": {
"main": [
[
{
"node": "Split Validation",
"type": "main",
"index": 0
}
]
]
},
"Split Validation": {
"main": [
[
{
"node": "Format Validation",
"type": "main",
"index": 0
}
]
]
},
"Format Validation": {
"main": [
[
{
"node": "Save validation_results",
"type": "main",
"index": 0
}
]
]
},
"Merge Suggestions": {
"main": [
[
{
"node": "Split Suggestions",
"type": "main",
"index": 0
}
]
]
},
"Split Suggestions": {
"main": [
[
{
"node": "Format Suggestions",
"type": "main",
"index": 0
}
]
]
},
"Format Suggestions": {
"main": [
[
{
"node": "Save suggestions_results",
"type": "main",
"index": 0
}
]
]
},
"Switch by endpoint": {
"main": [
[
{
"node": "API Search",
"type": "main",
"index": 0
},
{
"node": "Merge Search",
"type": "main",
"index": 1
}
],
[
{
"node": "API Suggestions",
"type": "main",
"index": 0
},
{
"node": "Merge Suggestions",
"type": "main",
"index": 1
}
],
[
{
"node": "API Browse",
"type": "main",
"index": 0
},
{
"node": "Merge Browse",
"type": "main",
"index": 1
}
],
[
{
"node": "API Validation",
"type": "main",
"index": 0
},
{
"node": "Merge Validation",
"type": "main",
"index": 1
}
]
]
},
"Google Sheets Trigger": {
"main": [
[
{
"node": "Read Input (Google Sheets)",
"type": "main",
"index": 0
}
]
]
},
"Read Input (Google Sheets)": {
"main": [
[
{
"node": "Valid rows (ad_account_id + endpoint)",
"type": "main",
"index": 0
}
]
]
},
"Valid rows (ad_account_id + endpoint)": {
"main": [
[
{
"node": "Switch by endpoint",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
facebookGraphApigoogleSheetsOAuth2ApigoogleSheetsTriggerOAuth2Api
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow is a universal automation for all four Meta Detailed Targeting API endpoints: Search, Suggestions, Browse, and Validation. You use a single Google Sheets tab with an column; a Switch node routes each row to the correct branch; results are written to four separate…
Source: https://n8n.io/workflows/13134/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
d27-FB-post. Uses googleSheets, googleDrive, googleSheetsTrigger, facebookGraphApi. Event-driven trigger; 8 nodes.
This template is designed for Marketing Managers, Performance Marketers, and Ad Ops professionals who want to automate Facebook ad creation using structured data in Google Sheets. It’s ideal for teams
This n8n workflow template automates the entire process of publishing Instagram Reels from content stored in Google Sheets and Google Drive. It's designed for content creators, social media managers,
This n8n workflow automates the process of uploading video and image advertisements to Meta Ads Manager via the Meta Graph API (Facebook Ads) directly from Google Sheets and Google Drive. The workflow
Marketing teams, agencies, and businesses who regularly create tens or hundreds of Facebook ads and store their creative assets in Google Drive.