{
  "name": "Fronterio — Stripe charge guardrail",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "stripe-charge-failed",
        "options": {}
      },
      "id": "c1b3d51a-1111-4a00-aaaa-000000000001",
      "name": "Stripe webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "stripe-charge-failed"
    },
    {
      "parameters": {
        "url": "https://fronterio.com/api/mcp/sse",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{$credentials.fronterioApiKey}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "jsonBody": "={\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"validate_action\",\n    \"arguments\": {\n      \"agent_id\": \"{{$env.FRONTERIO_BILLING_AGENT_ID}}\",\n      \"action\": \"auto_retry_failed_charge\",\n      \"action_input\": {\n        \"customer_id\": \"{{$json.body.data.object.customer}}\",\n        \"amount\": {{$json.body.data.object.amount}},\n        \"failure_code\": \"{{$json.body.data.object.failure_code}}\"\n      },\n      \"autonomy_level\": \"automator\"\n    }\n  }\n}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "c1b3d51a-2222-4a00-aaaa-000000000002",
      "name": "Fronterio validate_action",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [520, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition-1",
              "leftValue": "={{$json.result.content[0].outcome}}",
              "rightValue": "allow",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c1b3d51a-3333-4a00-aaaa-000000000003",
      "name": "Allowed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [800, 300]
    },
    {
      "parameters": {
        "operation": "update",
        "resource": "charge",
        "chargeId": "={{$('Stripe webhook').item.json.body.data.object.id}}",
        "additionalFields": {}
      },
      "id": "c1b3d51a-4444-4a00-aaaa-000000000004",
      "name": "Retry charge",
      "type": "n8n-nodes-base.stripe",
      "typeVersion": 1,
      "position": [1080, 220]
    },
    {
      "parameters": {
        "channel": "={{$env.SLACK_FINANCE_APPROVAL_CHANNEL}}",
        "text": "=:warning: Fronterio blocked an automatic charge retry.\n\n• Customer: `{{$('Stripe webhook').item.json.body.data.object.customer}}`\n• Amount: `{{$('Stripe webhook').item.json.body.data.object.amount}}`\n• Rule: `{{$json.result.content[0].rule}}`\n• Reason: {{$json.result.content[0].reason}}\n\nClick below to approve or dismiss.",
        "otherOptions": {}
      },
      "id": "c1b3d51a-5555-4a00-aaaa-000000000005",
      "name": "Request human approval",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [1080, 400]
    }
  ],
  "connections": {
    "Stripe webhook": {
      "main": [[{ "node": "Fronterio validate_action", "type": "main", "index": 0 }]]
    },
    "Fronterio validate_action": {
      "main": [[{ "node": "Allowed?", "type": "main", "index": 0 }]]
    },
    "Allowed?": {
      "main": [
        [{ "node": "Retry charge", "type": "main", "index": 0 }],
        [{ "node": "Request human approval", "type": "main", "index": 0 }]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "source": "fronterio.com/integrations/n8n",
    "description": "When a Stripe charge fails, call Fronterio validate_action before an AI agent auto-retries. Routes to human approval if Fronterio's guardrails block. Set FRONTERIO_BILLING_AGENT_ID and SLACK_FINANCE_APPROVAL_CHANNEL in your n8n environment."
  }
}
