Developer Guides
·IdenticAPI

Adding AI Security Checks to n8n Workflows

Add AI security checks to n8n workflows — HTTP Request nodes, authentication, verdict branching, and error handling without a native IdenticAPI node.

Add AI security checks to n8n workflows using the HTTP Request node to call IdenticAPI Unified Guard. There is no native IdenticAPI n8n node — configure authentication, JSON bodies, and IF branching on decision yourself.

This guide covers durable patterns for low-code automation: guard user text before LLM nodes, guard completions before Slack/email actions, and handle API errors explicitly.

For Make.com equivalents, see Make AI Security. For code-first integration, see Node.js Guardrails.

Workflow architecture

Typical n8n AI automation:

Webhook / Form Trigger
  → HTTP Request: Unified Guard INPUT
  → IF decision = allow
      → OpenAI / Anthropic / HTTP LLM node
      → HTTP Request: Unified Guard OUTPUT
      → IF decision = allow
          → Slack / Email / CRM node
  → ELSE: Stop or notify ops

Run guards server-side in n8n (cloud or self-hosted). Do not call IdenticAPI from browser-based test UIs with production keys.

Prerequisites

  • n8n instance (cloud or self-hosted)
  • IdenticAPI API key (idapi_test_ for staging)
  • Credentials stored in n8n Credentials — not hardcoded in node JSON

Store API key in n8n

  1. Open CredentialsHeader Auth (or Generic Credential Type)
  2. Name: IdenticAPI Bearer
  3. Header name: Authorization
  4. Value: Bearer idapi_test_your_synthetic_key_here

Reference this credential on every HTTP Request node.

Input guard HTTP Request node

Method: POST
URL: https://www.identicapi.com/api/v1/guard
Authentication: IdenticAPI Bearer credential
Body Content Type: JSON

JSON body (Expression mode):

{
  "text": "={{ $json.chatInput || $json.body.message || $json.text }}",
  "checks": ["prompt_injection", "pii_secrets"],
  "redact": true
}

Map text from your trigger — Webhook body.message, Chat Trigger chatInput, or a Set node that assembles context.

Expected response fields

FieldUse in n8n
decisionIF node: allow, review, block
request_idLog to error workflow / database
checksOptional per-check detail in notifications
processing_time_msMonitoring

Aggregation: block > review > allow.

IF node: branch on decision

Condition: {{ $json.decision }} equals allow

  • True branch → LLM node
  • False branch → Send safe fallback (Slack message, email template) or Stop and Error

For review, route to a human approval sub-workflow instead of auto-continuing.

LLM step (provider node)

Use n8n's OpenAI, Anthropic, or generic HTTP node. Guardrails run outside the provider node — n8n does not inject IdenticAPI automatically.

Pass only guarded input. If you use redact: true, substitute redacted text from the PII check result when your policy requires it (may need a Function node to extract redacted content from checks).

Output guard HTTP Request node

After the LLM node, add a second HTTP Request:

{
  "text": "={{ $json.message.content || $json.text || $json.choices[0].message.content }}",
  "checks": ["output_safety", "pii_secrets"]
}

Adjust the expression to match your LLM node's output shape.

IF node: output decision

Same pattern — continue to Slack/Email only when decision is allow. On block or review, send a static fallback message:

"The automated assistant could not deliver a response for this request. Reference: {{ $json.request_id }}"

Never forward blocked LLM text to customers.

Error handling (guard API down)

Enable Continue On Fail only if you documented fail-open policy. For security-sensitive workflows:

  1. Disable Continue On Fail on guard nodes
  2. Connect error output to a Notify Ops branch (Slack, PagerDuty)
  3. Do not call the LLM on guard HTTP 5xx

See Fail Open vs Fail Closed.

Example: Webhook → Guard → OpenAI → Guard → Slack

StepNode typeNotes
1WebhookReceives { "message": "..." }
2HTTP RequestInput guard
3IFdecision === "allow"
4OpenAIChat message with webhook text
5HTTP RequestOutput guard on completion
6IFdecision === "allow"
7SlackPost approved text

Agent / tool workflows

Before an HTTP Request that deletes records or sends email, call Unified Guard with agent_action:

{
  "checks": ["agent_action"],
  "agent_action": {
    "tool_name": "={{ $json.tool }}",
    "action": "={{ $json.action }}",
    "arguments": "={{ $json.arguments }}"
  }
}

Note: arguments must be a JSON object, not a string — use a Function node to parse if needed.

Rate limits and timeouts

Set HTTP Request timeout (e.g., 10s). n8n retries can amplify load — configure workflow settings appropriately. Log usage_units from responses for billing visibility.

Security hygiene

  • Use separate n8n credentials for test (idapi_test_) and production (idapi_live_)
  • Restrict webhook URLs with authentication
  • Do not log full text payloads in n8n execution data if executions are broadly visible
  • Rotate keys if a workflow exported credentials

curl equivalent (for debugging)

curl -X POST https://www.identicapi.com/api/v1/guard \
  -H "Authorization: Bearer idapi_test_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "User question from n8n webhook",
    "checks": ["prompt_injection", "pii_secrets", "output_safety"]
  }'

Unified Guard schema reference

Required checks array (1–4 values). Optional text, redact, agent_action. Max text length: 32,000 characters. Full docs: Unified Guard.

Testing workflows

  1. Benign message → both guards allow → Slack delivers
  2. Injection phrase → input block → LLM branch skipped
  3. Disable guard credential → verify fail-closed behavior
  4. Synthetic API key in message → pii_secrets blocks

Summary

n8n AI security uses HTTP Request nodes against POST /api/v1/guard — no native IdenticAPI node. Branch on decision, guard input before LLM nodes and output before customer-facing actions, and fail closed when the guard API errors. Call Unified Guard from n8n · Documentation

Frequently asked questions

Is there a native IdenticAPI node in n8n?

No. Use the HTTP Request node to POST https://www.identicapi.com/api/v1/guard with Bearer authentication and a JSON body matching the Unified Guard schema.

How do I branch on guard results in n8n?

Add an IF node after each HTTP Request node filtering on decision equal to allow. Route block and review to fallback notifications or stop paths — do not call LLM nodes on blocked input.

What JSON body should the input guard node send?

Include text from your trigger, checks set to prompt_injection and pii_secrets, and redact true when policy allows redaction before the LLM step.

How do I handle guard API failures in n8n?

For security-sensitive workflows, disable Continue On Fail on guard nodes and route HTTP errors to ops notifications without calling the LLM. Document fail-open only if explicitly chosen.

Where should the output guard sit in an n8n AI workflow?

After the OpenAI, Anthropic, or HTTP LLM node and before Slack, email, or CRM modules — map the completion text into the guard text field with checks output_safety and pii_secrets.

Related reading