{
  "name": "Compliance — Full KYC onboarding (sanctions + ID verification + risk scoring)",
  "description": "Complete KYC pipeline for customer onboarding. Checks OFAC/EU/UN sanctions, validates tax ID, extracts data from ID document photo, and calculates a composite risk score. Returns approve/review/reject decision. For fintechs, insurers, and regulated entities in LATAM.",
  "tags": [
    "mediavox",
    "mediaapi",
    "kyc",
    "compliance",
    "sanctions",
    "ofac",
    "onboarding",
    "latam",
    "fintech"
  ],
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "kyc-check",
        "responseMode": "responseNode"
      },
      "name": "Webhook (KYC Request)",
      "type": "n8n-nodes-base.webhook",
      "position": [
        240,
        300
      ],
      "notes": "Receives: { name, document_id, country, document_photo_base64 }",
      "id": "22786b40-f86b-4ab5-944a-6d379c6b3852"
    },
    {
      "parameters": {
        "resource": "security",
        "method": "security.check_sanctions",
        "params": "={{ JSON.stringify({ name: $json.body.name, country: $json.body.country }) }}",
        "product": "mediaapi"
      },
      "name": "Sanctions Check",
      "type": "n8n-nodes-mediavox.mediavox",
      "position": [
        460,
        200
      ],
      "credentials": {
        "mediavoxApi": {
          "name": "Mediavox API"
        }
      },
      "notes": "Checks against OFAC SDN, EU consolidated, UN sanctions. Returns match score 0-100.",
      "typeVersion": 2,
      "id": "feb1d90d-b690-4014-ba35-e4d24419ca5f"
    },
    {
      "parameters": {
        "resource": "finance",
        "method": "datatools.finance.validate_tax_id",
        "params": "={{ JSON.stringify({ document_id: $('Webhook (KYC Request)').first().json.body.document_id, country: $('Webhook (KYC Request)').first().json.body.country }) }}",
        "product": "mediaapi"
      },
      "name": "Validate Tax ID",
      "type": "n8n-nodes-mediavox.mediavox",
      "position": [
        460,
        400
      ],
      "credentials": {
        "mediavoxApi": {
          "name": "Mediavox API"
        }
      },
      "notes": "Validates NIT (CO), RFC (MX), RUT (CL), RUC (PE/EC) format and check digit.",
      "typeVersion": 2,
      "id": "8feffeaf-89d2-46e1-bc59-c455c2ff3dcb"
    },
    {
      "parameters": {
        "functionCode": "const sanctions = $('Sanctions Check').first().json;\nconst taxId = $('Validate Tax ID').first().json;\nconst sanctionScore = sanctions.match_score || 0;\nconst taxValid = taxId.valid === true;\n\nlet decision = 'approve';\nlet riskScore = 0;\n\nif (sanctionScore >= 80) { decision = 'reject'; riskScore = 100; }\nelse if (sanctionScore >= 40) { decision = 'review'; riskScore = 70; }\nelse if (!taxValid) { decision = 'review'; riskScore = 50; }\nelse { riskScore = sanctionScore; }\n\nreturn [{ json: { decision, risk_score: riskScore, sanctions_match: sanctionScore, tax_id_valid: taxValid, name: $('Webhook (KYC Request)').first().json.body.name, document_id: $('Webhook (KYC Request)').first().json.body.document_id } }];"
      },
      "name": "Calculate Risk",
      "type": "n8n-nodes-base.code",
      "position": [
        700,
        300
      ],
      "notes": "Composite scoring: sanctions ≥80 = reject, ≥40 = review, invalid tax = review, else approve.",
      "id": "1c1e1a4a-aeda-4ed2-81ce-035434f73e96"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}"
      },
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        920,
        300
      ],
      "id": "9a5d8ec5-7cc6-4fee-8a50-1fec6ce4b835"
    }
  ],
  "connections": {
    "Webhook (KYC Request)": {
      "main": [
        [
          {
            "node": "Sanctions Check",
            "type": "main",
            "index": 0
          },
          {
            "node": "Validate Tax ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sanctions Check": {
      "main": [
        [
          {
            "node": "Calculate Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Tax ID": {
      "main": [
        [
          {
            "node": "Calculate Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Risk": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "active": false,
  "versionId": "b90bac9a-f724-4396-aaa8-ea5bfa16d93d",
  "meta": {
    "templateCredsSetupCompleted": true
  }
}