Integrations
Validate phone numbers and emails in HubSpot
Verify contact emails and phone numbers in a HubSpot workflow with a custom code action, write the result to a property and branch on it.
Updated 2026-11-23
This recipe checks the email of each new HubSpot contact with a custom code action in a workflow, stores the result in contact properties, and branches on it so you can tag, route or clean bad addresses.
What you need
- A HubSpot account with workflows and custom code actions. These belong to Operations Hub Professional or Enterprise as far as we know: check your plan.
- A Qelka API key. A
sk_test_key returns simulated results and never spends credits: see Test mode. - Two custom contact properties:
email_status(single-line text) andemail_suggestion(single-line text). Create them in Settings, Properties.
There is no native Qelka integration for HubSpot. If your plan has no custom code, a webhook action that sends the email to a small service of yours is the alternative: that service can use the Node.js integration.
Steps
1. Create the workflow
Create a contact-based workflow. Set the enrollment trigger to Contact created, with a filter that Email is known. Add the action Custom code.
2. Add the secret and the input
In the action, add a secret named API_KEY and paste your key as its value. Then add an input field: name email, and map it to the contact property Email. Choose a Node.js runtime of 18 or later, which has fetch built in.
3. The code
exports.main = async (event, callback) => {
const email = event.inputFields.email
const empty = { email_status: 'unchecked', email_suggestion: '', email_reason: '' }
if (!email) return callback({ outputFields: empty })
for (let attempt = 1; attempt <= 3; attempt += 1) {
let response
try {
response = await fetch('https://api.qelka.com/v1/email', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, mode: 'fast' }),
signal: AbortSignal.timeout(8000),
})
} catch (error) {
console.log('validation skipped: unreachable')
return callback({ outputFields: empty })
}
if (response.ok) {
const result = await response.json()
return callback({
outputFields: {
email_status: result.status,
email_suggestion: result.did_you_mean || '',
email_reason: result.reason,
},
})
}
const retryable = [429, 500, 502, 503].includes(response.status)
if (retryable && attempt < 3) {
const retryAfter = Number(response.headers.get('Retry-After'))
await new Promise((resolve) => setTimeout(resolve, (retryAfter > 0 ? Math.min(retryAfter, 5) : attempt) * 1000))
continue
}
const failure = (await response.json()).error
console.log(`validation skipped: ${failure.type} request ${response.headers.get('X-Request-Id')}`)
return callback({ outputFields: empty })
}
}
In the action's output section, declare three outputs as strings: email_status, email_suggestion and email_reason. mode: 'fast' runs the syntax, DNS and list checks and skips the mailbox check, which keeps the action short; HubSpot limits how long a custom code action may run, so check its current limit before using full. See the email reference.
The action never fails the workflow: on any API problem it returns unchecked, so contacts keep flowing and you can re-check them later. The log line carries the documented error type and the request id, visible in the workflow history.
4. Write the result to the contact
Add two Set property value actions after the code. Set email_status to the output email_status, and email_suggestion to the output email_suggestion.
5. Branch on the status
Add an If/then branch on the email_status property:
| Value | Meaning | Suggested action |
|---|---|---|
undeliverable |
Bad syntax, no domain or no mailbox | Mark the contact as bad email, remove from marketing sends, notify the owner with email_suggestion when it is not empty |
risky |
Disposable inbox, catch-all domain or full mailbox | Add to a review list |
deliverable |
The mail server accepted the mailbox | Continue the normal flow |
unknown or unchecked |
Not conclusive, or the API was unreachable | Continue, and re-check later |
An unknown email is not a bad email, so do not delete it. See the email reference for each reason, and Block disposable email signups for the disposable case.
Phone numbers
Duplicate the custom code action for the phone property. Change the URL to https://api.qelka.com/v1/phone, the body to { phone, country: 'US' } with the country from a property if you have one, and read result.status and result.e164 instead. Store e164 in a property and use it for calling and messaging. A number without a + and without a country returns unknown. See the phone reference.
Handle errors and rate limits
Nothing is billed on errors. 401 and 403 mean a wrong or restricted key, 402 an empty balance: all three end as unchecked here, so filter contacts with that value regularly and alert yourself. A 429 is retried after Retry-After, up to five seconds. A key allows 200 requests per 10 seconds, so enroll existing contacts in waves. Each email check costs 1 credit. See Errors and Rate limits. For a full export, a bulk file check is simpler.
Related
Frequently asked questions
Do I need a paid HubSpot plan?
Where do I store the API key in HubSpot?
Can I check contacts that already exist?
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