Skip to content

Marketing & email

Verify emails before creating Brevo contacts

Verify an address before your backend creates the contact through Brevo's API v3, store the result in a contact attribute and keep bad addresses off your lists.

Updated 2026-11-26

This recipe verifies an email address in your backend before it becomes a Brevo contact. Your code calls the email check, refuses addresses that cannot receive mail, and creates the contact through Brevo's API v3 with the result stored in an EMAIL_STATUS attribute, so you can build segments on it and keep risky addresses out of campaigns. There is no native Qelka app for Brevo: this is a few lines of Node.js, shown with Brevo's official SDK and with plain fetch.

Why do it at creation: every contact you add is a recipient of your next campaign. An address that does not exist bounces, and mailbox providers judge your domain by how much of your mail bounces. A few clean checks at the door cost less than repairing a sender reputation. See Email bounces explained.

What you need

  • A Brevo account and an API key created in your Brevo account's API keys settings.
  • A text contact attribute named EMAIL_STATUS, created once in Brevo's contact attribute settings. Brevo only sets attributes that already exist.
  • The ID of the list new contacts join.
  • Node.js 18 or later.
  • A Qelka API key. A sk_test_ key returns simulated results and never spends credits: see Test mode.
  • Environment variables BREVO_API_KEY, BREVO_LIST_ID and QELKA_API_KEY. Never call either API from browser code: both keys would be exposed.

Steps

1. Install the clients

bash
npm install @getbrevo/brevo @qelka/sdk

Skip @getbrevo/brevo if you use the fetch version in step 3.

2. Verify the address

javascript
import { ApiConnectionError, ApiError, Client } from '@qelka/sdk'

const verifier = new Client({ apiKey: process.env.QELKA_API_KEY, timeoutMs: 10000 })

export async function checkAddress(email) {
  try {
    return await verifier.email.verify({ email })
  } catch (error) {
    if (error instanceof ApiError) {
      console.warn(`email check skipped: ${error.type} request ${error.requestId}`)
    } else if (error instanceof ApiConnectionError) {
      console.warn(`email check skipped: ${error.message}`)
    } else {
      throw error
    }
    return { status: 'unchecked', reason: null, did_you_mean: null }
  }
}

The check runs in full mode, which asks the recipient's mail server about the mailbox, with a 10-second timeout so a slow server never holds your signup. A timeout, a network error or an API error returns unchecked, and the contact is still created: the check must never be the reason someone cannot sign up.

If your form needs an instant answer, pass { email, mode: 'fast' }. Fast mode runs the syntax, DNS and list checks and skips the mailbox check, so it still catches typos, domains that take no mail and disposable inboxes, and returns unknown with the reason smtp_not_checked for everything else.

3. Create the contact with the result

With the Brevo SDK:

javascript
import { BrevoClient, BrevoError } from '@getbrevo/brevo'
import { checkAddress } from './check-address.js'

const brevo = new BrevoClient({ apiKey: process.env.BREVO_API_KEY, timeoutInSeconds: 15 })
const listId = Number(process.env.BREVO_LIST_ID)

export async function addContact(rawEmail) {
  const email = rawEmail.trim()
  const check = await checkAddress(email)

  if (check.status === 'undeliverable') {
    return { ok: false, suggestion: check.did_you_mean }
  }

  const joinsList = check.reason !== 'disposable'
  try {
    await brevo.contacts.createContact({
      email,
      attributes: { EMAIL_STATUS: check.status },
      updateEnabled: true,
      ...(joinsList ? { listIds: [listId] } : {}),
    })
  } catch (error) {
    if (error instanceof BrevoError) console.error(`Brevo answered ${error.statusCode}`, error.body)
    throw error
  }
  return { ok: true, suggestion: null }
}

Without the SDK, the same call with fetch:

javascript
import { checkAddress } from './check-address.js'

const listId = Number(process.env.BREVO_LIST_ID)

export async function addContact(rawEmail) {
  const email = rawEmail.trim()
  const check = await checkAddress(email)

  if (check.status === 'undeliverable') {
    return { ok: false, suggestion: check.did_you_mean }
  }

  const contact = { email, attributes: { EMAIL_STATUS: check.status }, updateEnabled: true }
  if (check.reason !== 'disposable') contact.listIds = [listId]

  const response = await fetch('https://api.brevo.com/v3/contacts', {
    method: 'POST',
    headers: {
      'api-key': process.env.BREVO_API_KEY,
      'Content-Type': 'application/json',
      accept: 'application/json',
    },
    body: JSON.stringify(contact),
    signal: AbortSignal.timeout(15000),
  })
  if (!response.ok) throw new Error(`Brevo answered ${response.status}: ${await response.text()}`)
  return { ok: true, suggestion: null }
}

A few choices in this code:

  • updateEnabled: true updates the contact if the address already exists instead of failing, so a person who signs up twice does not get an error.
  • Undeliverable addresses never reach Brevo. Return the suggestion to your form and show "Did you mean" with it, since a typo such as gmial.com is the most common cause.
  • A disposable inbox becomes a contact, with its status stored, but does not join the list. Block it at signup instead if your product needs a lasting address: see Block disposable email signups.
  • Brevo errors are thrown, not swallowed: your signup handler decides whether to retry later or report it.

4. Use the attribute in Brevo

Create a segment for each value you act on, and exclude the bad ones from campaigns:

EMAIL_STATUS Meaning Suggested use in Brevo
deliverable The mail server accepted the mailbox Send normally
risky A disposable inbox, a catch-all domain or a full mailbox Exclude from cold or large campaigns; keep for mail the person asked for
unknown The checks could not conclude, for example greylisting or a provider that does not answer mailbox checks Send normally. Never delete these: re-check later
unchecked The API was not reached Send normally, and re-check
undeliverable Only appears if you store it, for example after a re-check Remove from lists

If you need the reason in Brevo too, create a second text attribute such as EMAIL_REASON and send check.reason in it. The email reference lists every reason.

Handle errors and rate limits

Nothing is billed on errors. 401 and 403 mean a wrong or restricted key, 402 an empty balance: each ends as unchecked, so watch for a growing EMAIL_STATUS = unchecked segment and alert yourself. The Qelka SDK retries 429 after Retry-After. A key allows 200 requests per 10 seconds, and each check costs 1 credit. See Errors and Rate limits. For an existing contact base, a bulk file check is simpler than calling the API per contact.

Frequently asked questions

Why is the attribute called EMAIL_STATUS in capitals?
Brevo's API reference says attribute names are capitalized and must already exist in your account. Create EMAIL_STATUS once as a text attribute, then send it in the attributes object of each call. Do it before you deploy, and test with one contact to confirm the value shows up.
Should I use the Brevo SDK or plain fetch?
Either. The official @getbrevo/brevo package, version 6 at the time of writing, gives you typed methods, retries and a timeout option; its older 3.x line only gets security fixes. Plain fetch to api.brevo.com/v3/contacts needs no dependency and sends the same request. Both are shown below.
Can I check the contacts already in Brevo?
Yes. Export the contacts, run a bulk file check, and import the results back into the EMAIL_STATUS attribute with Brevo's contact import. Each address costs 1 credit, so start with the lists you actually send to.

More in Marketing & email

All integrations

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.

  • 100 free credits a month
  • No card
  • Test keys spend nothing
  • Cancel any time