{
  "name": "Monocrawl — inspect and retrieve one profile",
  "active": false,
  "nodes": [
    {
      "id": "manual",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "inspect",
      "name": "Inspect endpoint",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://www.monocrawl.com/mcp",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"get_endpoint\",\"arguments\":{\"id\":\"tiktok/profile\"}}}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true,
              "responseFormat": "json"
            }
          },
          "timeout": 75000
        }
      },
      "retryOnFail": false
    },
    {
      "id": "prepare",
      "name": "Prepare retrieval",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        0
      ],
      "parameters": {
        "jsCode": "const http = $input.first().json;\nconst message = http.body;\nconst row = message?.result?.structuredContent?.data;\nif (http.statusCode !== 200 || message?.error || message?.result?.isError || message?.result?.structuredContent?.success !== true || row?.id !== 'tiktok/profile' || row.mcp_read_available !== true || row.production_available !== true || !Number.isSafeInteger(row.credit_cost) || row.credit_cost < 0 || row.credit_cost > 1) throw new Error('Endpoint unavailable or outside the one-credit budget; no retrieval sent.');\nreturn [{ json: { jsonrpc: '2.0', id: 2, method: 'tools/call', params: { name: 'call_endpoint', arguments: { platform: 'tiktok', endpoint: 'profile', params: { handle: 'nasa' }, max_credits: 1, idempotency_key: 'n8n-profile-' + $execution.id } } } }];"
      }
    },
    {
      "id": "retrieve",
      "name": "Retrieve profile",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://www.monocrawl.com/mcp",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true,
              "responseFormat": "json"
            }
          },
          "timeout": 75000
        }
      },
      "retryOnFail": false
    },
    {
      "id": "result",
      "name": "Check receipt",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        0
      ],
      "parameters": {
        "jsCode": "const http = $input.first().json;\nconst message = http.body;\nconst body = message?.result?.structuredContent;\nif (http.statusCode !== 200 || message?.error || !body) throw new Error('No confirmed outcome. Recover the original key from Prepare retrieval; do not start a replacement execution.');\nif (message.result.isError || body.success !== true || !Number.isSafeInteger(body.credits_used) || body.credits_used < 0 || body.error?.details?.billing_status === 'pending_reconciliation') throw new Error('Request needs review. Keep request_id: ' + (body.request_id || 'unavailable') + ' and the original execution key.');\nreturn [{ json: body }];"
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Inspect endpoint",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inspect endpoint": {
      "main": [
        [
          {
            "node": "Prepare retrieval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare retrieval": {
      "main": [
        [
          {
            "node": "Retrieve profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve profile": {
      "main": [
        [
          {
            "node": "Check receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}
