KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Building Workflows
When your workflow calls external APIs that charge money or trigger irreversible actions (sending emails, creating payments, posting to social media)
When a workflow calls external APIs that charge money or trigger irreversible actions, use $execution.id combined with an item index to build idempotency keys. Passing this key on requests -- for example as Stripe's Idempotency-Key header -- prevents duplicate charges or actions when n8n retries a node. For bulletproof safety across manual re-runs, derive the key from business data instead.
When your workflow calls external APIs that charge money or trigger irreversible actions (sending emails, creating payments, posting to social media), use $execution.id combined with an item index to generate idempotency keys. This prevents duplicate actions if n8n retries the workflow or the node executes twice.
Real-world example: Creating Stripe payment intents where a duplicate call would charge the customer twice.
// Mode: Run Once for Each Item
const item = $input.item.json;
const itemIndex = $input.all().indexOf($input.item);
// Deterministic idempotency key: same execution + same item = same key
const idempotencyKey = `${$execution.id}_${itemIndex}_${item.orderId}`;
const response = await this.helpers.httpRequest({
method: 'POST',
url: 'https://api.stripe.com/v1/payment_intents',
headers: {
'Authorization': `Bearer ${item.stripeSecretKey}`,
'Idempotency-Key': idempotencyKey,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `amount=${item.amount}¤cy=${item.currency}&customer=${item.customerId}`,
});
return [{
json: {
...item,
paymentIntentId: response.id,
idempotencyKey,
status: response.status,
}
}];
Warning: Idempotency Key Scope
The key is unique per execution. If you manually re-execute the workflow, $execution.id changes and a new payment intent will be created. For truly bulletproof idempotency, derive the key from business data only (e.g., orderId + invoiceDate).
Related: Use Edit Fields in "Map Each" Mode for Simple Renames · Configure Payload Size and Binary Data Mode for Large Files
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.