Architecture

xFlow Workflows

Interactive diagram showing the complete flow from request to result. Click nodes to explore details and see code examples.

xFlow Architecture

Click nodes to explore • Interactive flow diagram

Client
1
Request
Client sends POST request
xFlow Gateway
2
Payment
402 Payment Required
x402 Verifier
3
Verify
x402 verification
n8n Webhook
4
Execute
n8n workflow runs
Result (200 OK)
5
Result
JSON response
Step by Step

How it works

Detailed breakdown of each step in the xFlow workflow execution process

1
Client Request

Your application sends a POST request to any xFlow workflow endpoint

Key Features:

  • Standard HTTP POST request
  • JSON payload with input data
  • No authentication required initially

Code Example:

fetch('/api/run/summarize', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ url: 'https://example.com' })
})
2
Payment Check

xFlow Gateway checks if payment is required and verified

Key Features:

  • Validates payment token if provided
  • Checks workflow pricing configuration
  • Determines if execution can proceed

Code Example:

if (!paymentVerified) {
  return res.status(402).json({
    status: 402,
    code: 'PAYMENT_REQUIRED',
    price: '0.25',
    currency: 'USDC',
    payment_url: '/api/payment/webhook?token=...'
  })
}
3
Payment Verification

x402 Verifier validates the micropayment on-chain

Key Features:

  • On-chain transaction verification
  • Multi-chain support (Base, Ethereum, Polygon)
  • Instant settlement confirmation

Code Example:

const isValid = await verifyPayment({
  token: paymentToken,
  amount: '0.25',
  currency: 'USDC',
  chain: 'Base'
})
4
Workflow Execution

n8n webhook is triggered with the verified request

Key Features:

  • Secure webhook call to n8n
  • Input data processing
  • Workflow automation execution

Code Example:

await fetch(n8nWebhookUrl, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    workflowId: 'summarize',
    input: payload,
    paid: true,
    tx_ref: transactionId
  })
})
5
Result Return

Processed result is returned to the client

Key Features:

  • Structured JSON response
  • Error handling and logging
  • Performance metrics included

Code Example:

{
  "ok": true,
  "workflowId": "summarize",
  "output": {
    "summary": "Article summary...",
    "wordCount": 1500,
    "processingTime": "2.3s"
  },
  "timestamp": "2024-01-15T10:30:00Z"
}
Performance

Built for scale

Enterprise-grade performance and reliability for production workloads

99.9% Uptime

Enterprise-grade reliability with automatic failover and monitoring

< 5s Response

Average response time including payment processing and workflow execution

100% Secure

End-to-end encryption and on-chain payment verification