Tips > Data, APIs & Webhooks

Use Execution Status to Skip Downstream Calls After Upstream Failures

When a validation or preprocessing node fails or produces no results, downstream nodes should not execute (and waste API calls).

When a validation or preprocessing node fails or returns nothing, downstream nodes should not run and waste API calls. Use n8n expressions to check the previous node's execution status and short-circuit the branch. An IF node testing the upstream result, or a Code node returning empty, stops the flow before expensive enrichment and LLM calls.

Why check execution status before downstream calls?

When a validation or preprocessing node fails or produces no results, downstream nodes should not execute (and waste API calls). Use n8n expressions to check the previous node's execution status and short-circuit the workflow.

Real-world example: A workflow validates incoming data, enriches it via an API, then sends it to an LLM. If validation fails, the enrichment and LLM calls should not run.

How do you short-circuit after an upstream failure?

// Code node: "Check Upstream Status"
// Place this before any expensive API call

const prevStatus = $('Validate Data').isExecuted;
const validationResult = $('Validate Data').first().json;

if (!prevStatus || validationResult.valid === false) {
  // Return empty to stop this branch, or return an error object
  return [{
    json: {
      skipped: true,
      reason: 'Upstream validation failed',
      errors: validationResult.errors || ['Unknown validation error'],
      apiCallsSaved: 2  // enrichment + LLM
    }
  }];
}

// Validation passed -- continue with the data
return [{
  json: {
    skipped: false,
    data: validationResult.data
  }
}];

A simpler approach using the IF node with execution expressions:

IF node configuration:
  Condition: Expression
  Value 1: {{ $('Validate Data').first().json.valid }}
  Operation: equals
  Value 2: true

  True branch:  --> [Enrich via API] --> [Send to LLM]
  False branch: --> [Log Failure] --> [End]

You can also use $prevNode for simpler chains:

// Expression in an IF node
// Check if the previous node produced any output items
{{ $prevNode.first() !== undefined && $prevNode.first().json.error === undefined }}

How much does this save?

Cost impact example:
  Workflow: Validate --> Enrich ($0.01) --> LLM ($0.03)
  Invalid input rate: 30%
  Daily executions: 1000

  Without status check: 1000 x ($0.01 + $0.03) = $40/day
  With status check:    700 x ($0.01 + $0.03) + 300 x $0.00 = $28/day
  Savings: $12/day = $360/month

This pattern ensures you only spend money on API calls that will actually produce useful results.

Related: Use Structured Output (JSON Mode) for Parseable Responses · Configure Payload Size and Binary Data Mode for Large Files

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

190 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book an introductory call