{
  "id": "TnW5x7kBDf9kzFGI",
  "name": "Gemini File Search - List Stores (Webhook)",
  "description": "Lists all Gemini File Search Stores (corpora) for the provided API key. Webhook endpoint: POST /kb-list-stores with apiKey in body.",
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "kb-list-stores",
        "responseMode": "lastNode",
        "options": {
          "responseData": "firstEntryJson"
        }
      },
      "id": "Webhook",
      "name": "Webhook /kb-list-stores",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        280,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const { apiKey } = $json;\nif (!apiKey || apiKey.length < 20) {\n  return [{ json: { status: 'ERROR', error: 'API key is required' } }];\n}\nreturn [{ json: { apiKey } }];"
      },
      "id": "Validate",
      "name": "Validate Input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://generativelanguage.googleapis.com/v1beta/corpora?key={{$json.apiKey}}",
        "responseFormat": "json",
        "options": {}
      },
      "id": "Http Request",
      "name": "Fetch Stores",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        760,
        300
      ],
      "notes": "Lists File Search corpora for the provided API key."
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const res = $json;\nif (res.statusCode && res.statusCode !== 200) {\n  return [{ json: { status: 'ERROR', error: `Gemini returned ${res.statusCode}`, body: res.body || res } }];\n}\nreturn [{ json: { status: 'SUCCESS', corpora: res.body?.corpora || res.corpora || [] } }];"
      },
      "id": "Return",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1000,
        300
      ]
    }
  ],
  "connections": {
    "Webhook /kb-list-stores": {
      "main": [
        [
          {
            "node": "Validate Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Input": {
      "main": [
        [
          {
            "node": "Fetch Stores",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Stores": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "meta": null
}