Blog

Fault Tolerance in n8n: How to Prevent a Failed API Call from Breaking Your Automation Workflow

By ·03 Dec 2026 ·6 min ·Theme: No-code
Contents
    Fault Tolerance in n8n: How to Prevent a Failed API Call from Breaking Your Automation Workflow

    A failed API call can halt a critical workflow. In n8n, enable Retry On Fail for 5 automatic retries (max 5-second delay), use Idempotency-Key to prevent duplicates during recovery, and set up an Error Workflow to alert your team. Here’s how to implement these mechanisms, including their exact limitations.

    1. Automatically Retry Failed API Calls with Retry On Fail

    The Retry On Fail setting in an n8n node (e.g., HTTP Request) allows automatic retries of failed requests, with a configurable delay between attempts. Here’s how to set it up:

    • Enable the Retry On Fail toggle in the node settings.
    • Set Wait Between Tries (configurable delay up to 5,000 ms (5 seconds), a technical limit of n8n) to respect the target API’s rate limits. For example, if the API allows one request per second, set this delay to 1,000 ms.
    • Limit the number of attempts to 5 (Max Tries).

    Limitations:

    • This mechanism does not handle the Retry-After header returned by some APIs (e.g., 429 Too Many Requests). For longer delays, use a Wait node or a Loop Over Items with a custom interval (F1).
    • Attempts stop after 5 failures, even if the API is temporarily unavailable.

    Use Case: Payment API

    A payment validation workflow can use Retry On Fail to reduce temporary failures (e.g., timeouts). For example, a 2-second delay between attempts can bypass short outages without manual intervention.

    2. Prevent Duplicates with Idempotency-Key on n8n’s API

    The Idempotency-Key header, as per n8n’s official documentation, ensures that a retry of a POST request to n8n’s public API (/api/v1) returns the first successful response instead of re-running the operation. Here are the rules to follow:

    • The key must be a string of 1 to 128 visible ASCII characters (no spaces), unique per distinct request. A UUID v4 is recommended (F3).
    • The request must be identical (same path, query string, and body, including the order of JSON fields) for the retry to work (F4).
    • The response is stored for 12 hours. After this period, a retry with the same key re-runs the request (F5).

    Implementation Example

    POST /api/v1/executions
    Headers:
      Idempotency-Key: 123e4567-e89b-12d3-a456-426614174000
    Body:
      {"workflowId": "123"}
    

    Note:

    • If the first request is still in progress, a retry with the same key returns a 409 Conflict status. This code is returned only if the first request is still in progress (F5).
    • This mechanism returns the first successful response (except for POST requests returning a file) (F3).
    • It only applies to n8n’s public API endpoints (/api/v1). For external calls (e.g., HTTP Request to Stripe), use the target API’s idempotency mechanisms.

    3. Remove Duplicates with the Remove Duplicates Node

    The Remove Duplicates node allows you to delete duplicate items, either in the current data or by comparing with previous executions. Two modes are available:

    • Remove Items Repeated Within Current Input: Removes duplicates in the data being processed, comparing all fields or a subset.
    • Remove Items Processed in Previous Executions: Compares current items with those from previous executions and removes duplicates based on a criterion (e.g., “Value Is New,” “Value Is Higher”).

    Advanced Configuration

    • Set the scope of deduplication: Node (default, history specific to the node) or Workflow (history shared across multiple Remove Duplicates nodes) (F8).
    • For the “Remove Items Processed in Previous Executions” mode, choose a retention criterion:
      • Value Is New: Removes items whose value already exists in the history.
      • Value Is Higher than Any Previous Value: Keeps only items with a higher value than those already processed.
      • Value Is a Date Later than Any Previous Date: Keeps items with a more recent date (F7).
    • The history size is limited to 10,000 items by default. Adjust it as needed (F7).

    Example: Lead Synchronization Workflow

    A workflow synchronizing leads between HubSpot and Salesforce can use the Remove Duplicates node in “Remove Items Processed in Previous Executions” mode with the “Value Is New” criterion on the email field. This prevents duplicates during retries after API failures, even if the HTTP Request node had partially processed items before failing.

    4. Centralize Error Handling with an Error Workflow

    An Error Workflow automatically triggers when a linked workflow fails. Here’s how to set it up:

    1. Create a new workflow with an Error Trigger node as the first node.
    2. In the main workflow, go to Options > Settings and select the Error Workflow you created.
    3. The Error Trigger node receives data about the failure, including:
      • The execution.id and execution.url (if the execution is saved in the database).
      • Error details (error.message, error.stack).
      • Data from the failed node (execution.data).

    Example Corrective Actions

    • Send a Slack alert with error details and a link to the failed execution.
    • Automatically retry the workflow with POST /api/v1/executions/{executionId}/retry (using Idempotency-Key to avoid duplicates).
    • Log the error in a monitoring tool (e.g., Datadog).

    Limitation: Errors in the Trigger node of the main workflow do not trigger the Error Workflow, as the workflow never started (F9).

    5. Retry a Failed Execution Without Creating Duplicates

    Retrying a failed execution (Retry execution), as per n8n’s documentation, restarts from the last saved state of the failed node, without repeating nodes that already succeeded. However, the failed node receives its input data again and processes all its items, including those already handled before the failure (F10).

    Best Practices to Avoid Duplicates

    • Use update operations instead of creation. For example, in Google Sheets, prefer Append or Update Row over Add Row (F11).
    • If the failed node is an Execute Sub-workflow, the retry reruns the entire sub-workflow. Ensure it is idempotent.
    • Manually check the data in the target application before retrying, especially if the node partially processed items.

    6. Limitations and Precautions

    • Retry On Fail: Limited to 5 attempts and a 5-second interval. For longer rate limits, use a Wait node or a Loop Over Items with a custom delay (F1).
    • Idempotency-Key: Only covers n8n’s public API endpoints (/api/v1). For external calls, use the target API’s idempotency mechanisms (e.g., Stripe-Idempotency-Key).
    • Remove Duplicates: Requires precise configuration of the fields to compare. Poor choices can lead to false positives or negatives.
    • Execution Retry: May repeat actions already performed if the node partially processed items. Always verify data in the target application before retrying.
    • Error Workflows: Do not trigger for errors in the main workflow’s Trigger node (F9).

    Example Configuration

    Here’s an example configuration to implement these mechanisms in an order processing workflow:

    1. An HTTP Request node to fetch orders from an external API, with Retry On Fail enabled (3 attempts, 2-second delay).
    2. A Remove Duplicates node in “Remove Items Processed in Previous Executions” mode (criterion “Value Is New,” field orderId).
    3. An Execute Workflow node to process the order, with an Error Workflow configured to send a Slack alert on failure.
    4. An HTTP Request node to send the order confirmation to the external API, with an Idempotency-Key header (UUID v4).

    An example configuration is available in the n8n documentation.

    Useful Resources

    Article prepared with AI assistance and checked against the sources consulted.

    n8n fault tolerance API automation workflow idempotency error handling
    Read next
    A similar project to scope? Let's talk. Get in touch with Keerok →
    © 2026 Keerok · All rights reserved Cran · Keerok's media