Skip to main content

Protect public webhooks with Ainoflow Guard rate limiting

Workflow preview

Workflow preview
100%
Protect public webhooks with Ainoflow Guard rate limiting preview
Open on n8n.io

1. Workflow Overview

Webhook Rate Limiter (Ainoflow Guard) Stop webhook flooding before it starts. Add production grade rate limiting to any n8n webhook in minutes reject abusive traffic before expensive workflow logic...

Best for

  • SecOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.webhook, n8n-nodes-base.set, n8n-nodes-base.code, n8n-nodes-base.httprequest, n8n-nodes-base.if, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Dmitrij Zykovic.

Original n8n.io source

1.1 Workflow description

Title
Protect public webhooks with Ainoflow Guard rate limiting
Workflow name
Protect public webhooks with Ainoflow Guard rate limiting

Webhook Rate Limiter (Ainoflow Guard)

Stop webhook flooding before it starts. Add production-grade rate limiting to any n8n webhook in minutes - reject abusive traffic before expensive workflow logic executes.

✨ Key Features

  • ⚑ Edge-style decisions - Allow/deny checked before any business logic runs
  • πŸ›‘οΈ Burst protection - Configurable limits (requests per time window)
  • πŸ”„ Stateless - No queues, databases, or counters needed in n8n
  • πŸ“‘ Proxy-aware - Correct IP extraction behind Cloudflare, nginx, load balancers
  • πŸ”‘ Dual identity modes - Rate limit by IP address or API key
  • ⏱️ Retry-After headers - Proper 429 responses with retry guidance
  • πŸ’₯ Fail-open - Guard outage doesn't block your production traffic
  • πŸ”§ Auto-setup - Guard policy auto-creates on first request

🎯 How It Works

  1. Webhook receives POST request

  2. Identity extracted from headers:

  • API key (x-api-key) β†’ per-client limiting
  • Client IP (X-Forwarded-For / x-real-ip) β†’ per-IP limiting
  1. Guard decides allow or deny:
  • POST /api/v1/guard/{route:identity}/counter
  • Checks against configured rate limit policy
  1. Allowed β†’ your business logic executes β†’ 200 OK

  2. Denied β†’ immediate 429 Too Many Requests + Retry-After header

Client β†’ Webhook β†’ Identity β†’ Guard β†’ Allowed? β†’ Business Logic β†’ 200 OK
 ↓ NO
 429 + Retry-After

πŸ”§ Setup Requirements

  • Ainoflow - Sign up free for Guard API access. Free plan available.

That's it. One credential, one API.

⚑ Quick Start

1. Import workflow and set Ainoflow Bearer credential on GuardCheck node

2. Edit Config node with your limits:

Variable Default Description
rate_limit 30 Max requests per window
window_sec 60 Window in seconds
identity_mode ip ip or apiKey
route_name webhook Endpoint name

3. Replace BusinessLogic node with your workflow

Access original request:

const body = $('Webhook').first().json.body;
const headers = $('Webhook').first().json.headers;

4. Activate and test

πŸ§ͺ Testing

Burst Test

Bash (Linux/macOS):

for i in {1..50}; do
 curl -s -o /dev/null -w "%{http_code}\n" \
 -X POST https://your-n8n.com/webhook/rate-limited-endpoint \
 -H "Content-Type: application/json" \
 -d '{"test": true}'
done

PowerShell (Windows):

1..50 | ForEach-Object {
 (Invoke-WebRequest -Uri "https://your-n8n.com/webhook/rate-limited-endpoint" -Method POST -Body '{"test":true}' -ContentType "application/json" -UseBasicParsing).StatusCode
}

Expected: First 30 β†’ 200, remaining β†’ 429

Proxy Test

curl -H "X-Forwarded-For: 1.2.3.4, 5.6.7.8" \
 -X POST https://your-n8n.com/webhook/rate-limited-endpoint

Identity key should use 1.2.3.4 (first IP from chain).

πŸ’¬ Response Examples

Allowed (200 OK)

{
 "ok": true,
 "data": { "message": "Request processed successfully" }
}

Denied (429 Too Many Requests)

Headers: Retry-After: 17

{
 "ok": false,
 "error": "rate_limited",
 "retryAfter": 17
}

πŸ—οΈ Workflow Architecture

Section Nodes Description
Rate Limit Check Webhook β†’ Config β†’ BuildIdentity β†’ GuardCheck β†’ IfAllowed Extract identity, check Guard
Allowed Path BusinessLogic β†’ RespondOk Your logic + 200 response
Denied Path BuildDeniedResponse β†’ RespondRateLimited 429 + Retry-After

Total: 9 nodes. Minimal by design.

πŸ”’ What This Protects Against

  • βœ… Webhook flooding - bot traffic, retry storms hitting your endpoint
  • βœ… Credit burn - one runaway loop = €500+ OpenAI/Twilio bill overnight
  • βœ… Automation overload - uncontrolled DB writes, external API hammering
  • βœ… Accidental loops - webhook chains triggering each other endlessly

❌ What This Does NOT Replace

  • Cloudflare / WAF (network-level protection)
  • Bot detection (behavioral analysis)
  • Layer 3/4 DDoS mitigation
  • Authentication (who is the user?)

Guard handles application-level rate decisions, not network security.

πŸ”‘ Identity Modes

IP Mode (default)

Best for public webhooks where clients don't have API keys.

X-Forwarded-For: 1.2.3.4, 5.6.7.8 β†’ identity = "1.2.3.4"
x-real-ip: 10.0.0.1 β†’ identity = "10.0.0.1"

⚠️ IP addresses can be shared (NAT, mobile carriers, offices).

API Key Mode

Best for authenticated endpoints with per-client keys.

x-api-key: client_abc123 β†’ identity = "client_abc123"

Falls back to IP if header is missing.

πŸ› οΈ Customization

Rate Limit Presets

Use Case rate_limit window_sec Result
Burst protection 30 60 30/min
API rate limiting 100 3600 100/hour
LLM cost protection 10 60 10/min
Daily limit 1000 86400 1000/day

Multiple Endpoints

Use different route_name values to create separate rate limits:

Config A: route_name = "orders" β†’ key = "orders:1.2.3.4"
Config B: route_name = "payments" β†’ key = "payments:1.2.3.4"

Each route has independent counters.

Fail-Open vs Fail-Closed

Default: Fail-open - Guard API uses failOpen=true, so Guard outage doesn't block traffic.

To switch to fail-closed: change failOpen query parameter to false in GuardCheck node.

Combine with Shield (Dedup Protection)

Getting duplicate webhook deliveries? Add Ainoflow Shield before your business logic - one trigger, one execution, guaranteed. Guard + Shield = rate limiting + deduplication on the same endpoint.

⚠️ Important Notes

  • Guard policy auto-creates on first request with rateMax/rateWindow parameters
  • allowPolicyOverwrite=true is set for easy demo/testing - Config node values always apply. Production: set to false in GuardCheck query params to lock policy and prevent hidden config drift
  • Denied requests not counted - only successful requests increment the counter
  • Window resets atomically - no gradual decay, clean reset every N seconds
  • No state in n8n - all rate limiting state lives in Guard API
  • 5-second timeout - GuardCheck has 5s timeout to prevent blocking

πŸ’Ό Need Customization?

Want to add temporary bans, cost protection mode, multi-tier rate limiting, or per-client usage dashboards?

Ainova Systems - We build custom AI automation infrastructure and safety layers for production workflows.


Tags: webhook, rate-limiting, security, guard, burst-protection, api-protection, ainoflow, production, webhook-security, cost-control

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - README

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - SectionRateLimitCheck

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - SectionAllowed

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - SectionDenied

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - StickyWebhook

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - StickyConfig

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - StickyIdentity

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - StickyGuard

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 10 - Config

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 11 - BuildIdentity

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - GuardCheck

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 13 - IfAllowed

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 14 - BusinessLogic

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - RespondOk

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 16 - BuildDeniedResponse

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 17 - RespondRateLimited

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

3. Summary Table

Workflow Protect public webhooks with Ainoflow Guard rate limiting
Complexity advanced
Nodes 17
Categories SecOps
Author Dmitrij Zykovic
Published 18 Feb 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/13491/13491.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Protect public webhooks with Ainoflow Guard rate limiting do?

Webhook Rate Limiter (Ainoflow Guard) Stop webhook flooding before it starts. Add production grade rate limiting to any n8n webhook in minutes reject abusive traffic before expensive workflow logic...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps use case.