Skip to main content

n8n Email Validation with an API: Route Results Before CRM Updates

Choose between a format check and an API workflow, then build Soryxa validation in n8n. Preserve the source record ID and route allow, review, block and errors before CRM updates.

Sora

Sora

Digital Guide X LinkedIn Website

Sora guides Elvesora’s voice across data, clarity, and growth. She helps teams navigate company data with a focus on accuracy and transparency.

Dec 02, 2026 12 min read 12 views
An email-validation API workflow with separate allow, review, block and technical-error paths.

To validate an email address in n8n, first choose the check you need: a format test for malformed input, or a validation API when your next action needs an external result and a policy decision.

This guide builds the API path with Soryxa using HTTP Request, Code, and Switch nodes. It preserves the CRM record ID, routes allow, review, and block, and keeps request failures away from the automatic writer. It is a node-by-node build guide with example code; it does not include an importable workflow export.

An HTTP Request node can finish successfully while the checked email still requires review. The workflow below checks the returned decision before allowing a CRM update.

The examples are synthetic and the routing code is an implementation example, not evidence of a live check. You can exercise its branches with the fixture below before connecting a real token or writer.

Format check, validation API, or ownership confirmation?

What you need to know Appropriate step Limit to keep in mind
Does the input have an email-address format? A format condition, such as n8n's isEmail() string function A format match does not establish mailbox availability or who controls it.
How should the workflow treat the address using validation evidence and your policy? Call a validation API and inspect its decision and reasons An uncertain or unavailable result still needs a separate path; no result guarantees inbox delivery.
Can the applicant access the address? A confirmation link or code in your authentication flow This is separate from email-risk validation and does not establish company authority.

n8n documents isEmail() as a string function. Use a format-only condition when that is the full requirement. Continue with this recipe when you need Soryxa's decision before a CRM action; keep ownership confirmation in the application's separate verification step.

The workflow you will build

Source record
  → Check source input (IF)
      valid   → Validate email (HTTP Request)
                  → Prepare routing (Code)
                  → Route validation (Switch)
                      allow           → check current CRM record → update validation fields
                      review          → hold for an assigned reviewer
                      block           → correction or blocked-intake handling
                      technical_error → operational error handling
      invalid → operational error handling

The CRM update is your workflow's action; Soryxa does not perform it automatically. Here, technical_error is a local routing label, not a fourth Soryxa decision.

Keep this first version to one source record per execution. For a large list, use a deliberate job design rather than turning the tutorial into an unbounded loop. Soryxa's batch-validation guide covers that separate API.

You need an n8n workflow, a Soryxa token with validation access, and a source record whose identifier you can retain. A CRM-specific writer also needs that CRM's credentials and field mapping. Start with the writer disconnected.

1. Keep the source ID and original address

Create an Edit Fields node named Source record before the HTTP Request. Map three fields from your source:

Field Purpose
source_record_id The stable CRM or intake record ID, represented as a string
source_email The original email value, retained so you can detect a later edit
email The address to submit, with surrounding whitespace removed

For example, a synthetic source item could be:

{
  "source_record_id": "contact-example-42",
  "source_email": "support@cedar.example",
  "email": "support@cedar.example"
}

These values describe a fixture, not an address to use for a live validation. When you connect your real source, add an IF node named Check source input after Source record. Continue to Validate email only when source_record_id, source_email, and the trimmed email are nonempty strings. Send invalid records to an operational error path without calling Soryxa.

Keep the defensive checks in the Prepare routing Code node as a second safeguard.

Do not try to preserve the CRM ID by sending it in context. Soryxa's current validate-email contract prohibits context metadata. The ID stays in n8n.

The HTTP Request output is the response, so do not assume source_record_id will still exist on its output JSON. Step 3 explicitly retrieves the linked Source record item and copies the ID into the result.

2. Configure the Soryxa request

Add an HTTP Request node named Validate email.

Setting Value
Method POST
URL https://soryxa.elvesora.com/api/v1/validate
Authentication Generic Credential Type → Header Auth
Credential header name Authorization
Credential value Bearer YOUR_SORYXA_API_KEY
Send Body On
Body Content Type JSON
Body fields email and policy_key, as below
Response Format JSON
Include Response Headers and Status On
Never Error On
Retry On Fail Off for this initial workflow
On Error Stop Workflow

Create the header credential in n8n's credential store. The token belongs there, not in an Edit Fields value, shared workflow JSON, or a Code node. n8n's HTTP credentials documentation explains the Header Auth name/value configuration.

For the JSON body, use Using Fields Below:

Name Value
email Expression: {{ $json.email }}
policy_key Fixed text: crm_intake

The equivalent request body is:

{
  "email": "support@cedar.example",
  "policy_key": "crm_intake"
}

policy_key labels this flow in the response. It does not choose a different team ruleset.

The HTTP Request response options make the next node's paths important. With the full response enabled, read the HTTP status from $json.statusCode and the API body from $json.body. The decision is therefore at $json.body.data.decision.

Never Error lets HTTP error responses reach your routing logic. It does not turn an error body into a valid decision. Transport failures and JSON parsing failures can still stop the node; with On Error: Stop Workflow, they cannot reach the writer.

3. Prepare a small routing record

Add a Code node named Prepare routing. Select JavaScript and Run Once for Each Item. Copy this code:

const source = $('Source record').item.json;
const response = $json;

if (
  typeof source.source_record_id !== 'string' ||
  !source.source_record_id.trim() ||
  typeof source.source_email !== 'string' ||
  typeof source.email !== 'string'
) {
  throw new Error('Missing source record mapping');
}

const isObject = value =>
  value !== null && typeof value === 'object' && !Array.isArray(value);

const body = isObject(response.body) ? response.body : null;
const data = body && isObject(body.data) ? body.data : null;
const status = response.statusCode;
const isHttpSuccess =
  Number.isInteger(status) && status >= 200 && status < 300;

const reasonCode =
  typeof data?.reason_code === 'string' && data.reason_code.trim()
    ? data.reason_code
    : null;

const hasDecision =
  data !== null && ['allow', 'review', 'block'].includes(data.decision);

let route = 'technical_error';
let decision = null;

if (isHttpSuccess && body?.success === true && hasDecision && reasonCode) {
  decision = data.decision;
  route = decision;

  // This reason must never reach an automatic writer.
  if (reasonCode === 'SERVICE_UNAVAILABLE' && decision !== 'review') {
    route = 'technical_error';
  }
}

return {
  json: {
    source_record_id: source.source_record_id,
    source_email: source.source_email,
    email: source.email,
    route,
    decision,
    reason_code: reasonCode,
    score: typeof data?.score === 'number' ? data.score : null,
    http_status: Number.isInteger(status) ? status : null,
    error_code: typeof body?.error_code === 'string' ? body.error_code : null,
    availability_issue: reasonCode === 'SERVICE_UNAVAILABLE',
    received_at: new Date().toISOString()
  }
};

This adapter requires an actual success envelope, a recognized decision, and a reason code. A 200 response with missing data, success: false, or an unfamiliar decision does not reach allow. Neither does a contradictory response that combines SERVICE_UNAVAILABLE with allow.

The code retrieves the original record using n8n's linked-item reference, then returns only the fields needed for routing and write-back. See n8n's item-linking guidance and Code node modes when adapting it.

Keep the original straight path while using this example. If you later add aggregation or parallel streams, revisit correlation explicitly. For keyed joins, n8n's Merge node can combine matching fields; it should not be used to guess which response belongs to which contact.

4. Route the decision before connecting the writer

Add a Switch node named Route validation in Rules mode. Compare the string expression {{ $json.route }} against four exact values:

Rule Destination
Equals allow The CRM update path
Equals review A pending record or review task with an assigned owner
Equals block Correction or blocked-intake handling
Equals technical_error An operational error path

Set Fallback Output to Extra Output, and send that output to the operational error path too. Leave “send data to all matching outputs” off. These options are documented in the Switch node reference.

A review branch needs a real destination and an owner. Saving the reason without arranging a later decision leaves the workflow unfinished. This recipe does not automatically resume it after a Soryxa reviewer acts; that requires a separately designed continuation.

For SERVICE_UNAVAILABLE, hold the record because usable validation evidence was unavailable. Do not mark the mailbox invalid, and do not bypass the hold because the HTTP status was 200.

A block result also does not instruct you to delete an existing contact. It can stop a new intake action or request a corrected address while preserving the existing record.

5. Handle request failures by cause

All of the following must keep the automatic writer stopped. Use the Soryxa API error reference to inspect the response's error_code.

Result Next action
HTTP 401 Repair the missing, invalid, expired, or revoked token; repeating the same request does not repair credentials.
HTTP 403 Check scope and access restrictions before retrying.
HTTP 402 Resolve the subscription condition.
HTTP 422 / VALIDATION_ERROR Correct the input or request mapping. This is not the same as a completed block decision.
HTTP 429 / TOKEN_RATE_LIMIT_EXCEEDED Respect the returned retry timing, then use a bounded retry of this validation step if appropriate.
HTTP 429 / USAGE_LIMIT_EXCEEDED Pause until validation capacity is available; a short delay does not restore a billing-period allowance.
HTTP 5xx, timeout, or connection failure Keep the record pending and investigate; any retry should have a finite attempt limit.
HTTP 200 with an incomplete or unexpected body Inspect the contract or response before retrying; do not infer allow from the status.

A timed-out request may have reached the service even though your workflow did not receive the answer. Successful real-time calls consume validation credits. Do not assume that rerunning the entire workflow is a free, deduplicated retry, and do not add an invented idempotency header to this recipe.

Keep Retry On Fail off until you have chosen a bounded policy for the failures you actually encounter. Retry the validation step, not a previously successful CRM write.

If the technical-error branch should fail the execution, connect it to Stop and Error with a message containing the record ID and error code, without the token or raw provider payload. An n8n error workflow can then handle the failure. Configure transport-failure handling too, because those failures may stop at HTTP Request before the adapter runs.

6. Test routing without calling the validation API

Disconnect Validate email and the CRM writer. On the valid output of Check source input, temporarily replace Validate email with a Code node in Run Once for Each Item mode:

return {
  json: {
    statusCode: 200,
    headers: {},
    body: {
      success: true,
      data: {
        decision: 'review',
        reason_code: 'SERVICE_UNAVAILABLE',
        score: 0
      }
    }
  }
};

This is a minimal synthetic HTTP-result fixture containing only the fields the adapter reads. It is not a complete response captured from Soryxa. Use it with the fictional source item above; no request is sent to the service.

The output should retain contact-example-42, set route to review, and set availability_issue to true. Then change the fixture to exercise these cases:

Fixture change Expected route
200, success: true, allow, CLASSIFICATION_VALID allow
200, success: true, block, BLOCK_ROLE_ACCOUNT block
200, success: true, review, CLASSIFICATION_RISKY review
200, success: true, review, SERVICE_UNAVAILABLE review
200, allow paired with SERVICE_UNAVAILABLE technical_error
401 or 429 with an error envelope technical_error
200 with no decision, no reason code, or decision: "unknown" technical_error
200 with success: false technical_error

Also verify that a missing source ID fails the adapter rather than allowing an update without a target.

Restore the HTTP Request only after the fixture paths behave as intended. A real request then tests credentials and the service connection and may consume a credit; it is a separate check from this offline exercise.

Connect the CRM update deliberately

On the allow branch, use source_record_id to select the original record. Fetch the current record before updating and compare its current email with source_email. If a person or another process has changed it since validation began, hold the update and validate the replacement address through a new operation.

Map the decision, reason code, and timestamp to fields your CRM actually provides or that you have intentionally configured. For example, email_validation_decision and email_validation_reason are suggested destination field names, not built-in CRM fields. Do not overwrite the contact's email merely because the response is allowed.

Store the smallest result summary your workflow needs. The adapter does not forward Soryxa's raw provider payload; check n8n execution-data retention separately, since intermediate node data can still contain the address and full response.

Finally, prevent duplicate intake events from repeating the same accepted CRM mutation using the source system's event identifier or your existing operation tracking. Preserving an ID establishes correlation; it does not make the writer idempotent by itself.

The workflow now has a decision boundary before the CRM writer. Only a recognized allow result can proceed to a guarded update. review, block, and technical failures follow separate paths, while the original record identity remains available for reconciliation.

A successful HTTP request is not permission to update a CRM record. That permission comes from the validation decision and the workflow's own write policy.

Sora

Sora

Digital Guide

Sora guides Elvesora’s voice across data, clarity, and growth. She helps teams navigate company data with a focus on accuracy and transparency.

Related reading