# Corelia form-to-API repair lab

A runnable n8n example using synthetic enquiries and a local sample CRM endpoint. This is an engineering exercise, not a client case study.

## Run the recorded checks

Requires Node.js 24+, Python 3.10+, and n8n 2.38.7. No n8n account or paid subscription is needed for this local example. Installation downloads npm dependencies; the sample API listens only on 127.0.0.1:18947.

```
npm install --prefix runtime n8n@2.38.7 --no-audit --no-fund
python run_checks.py --n8n runtime/node_modules/n8n/bin/n8n
```

The runner imports both workflows into an isolated temporary n8n user folder, executes the broken workflow once, executes the repair twice, verifies the stored records and writes verification.json. The temporary database is removed afterward. Port 18947 must be available. Do not run the runner against your production n8n instance.

## What changes

The broken workflow sends `companyName: $json.company`; the incoming form actually stores the value at `$json.customer.company`. The API rejects the missing field. The repaired workflow uses the nested field and sends two valid orders. The IF node rejects an invalid email. The same event appears twice in the fixtures; a unique SQLite event key in the sample API prevents duplicate orders, including when the workflow runs again. A reused key with different content returns 409.

This deliberately demonstrates where idempotency is enforced: at the destination API. n8n alone does not make any arbitrary CRM operation idempotent.

## Inspect in the n8n editor

Run `python sample_api.py` and import broken.json or repaired.json into a local n8n editor running on the same host. The Manual Trigger reads /fixtures. These exports use HTTP Request, IF and No Operation nodes, with no credentials or community nodes. A Docker installation needs an explicit route to the host; the recorded verification uses the host CLI.

## Limits

Synthetic data only; no customer service is connected. The example is not a production API: deployment needs authentication, authorization, backups, payload limits, observability and integration tests against the real destination. No payment or throughput claims are made. n8n is a third-party tool; Corelia Bots has no official affiliation with n8n.

Corelia Bots: https://coreliabots.com/n8n-workflow-rescue/
