CRM
Validate phone numbers and emails in Attio
Verify the email and phone of each new Attio person with a signed record.created webhook and a small handler that writes the result to person attributes.
Updated 2026-11-26
This recipe checks the email and phone number of every person created in Attio and writes the answer to two person attributes, so you can filter bad addresses out of sequences and see which numbers can receive SMS. There is no native Qelka app for Attio: an Attio webhook calls a small handler of yours, which reads the person, calls the API and writes the result through Attio's REST API.
What you need
- An Attio workspace where you can create attributes and an access token. Create the token in Attio's developer settings with the scopes
record_permission:read-write,object_configuration:readandwebhook:read-write; it is sent asAuthorization: Bearer. - A Qelka API key. A
sk_test_key returns simulated results and never spends credits: see Test mode. A restricted key limited toemailandphoneis enough. - A place to run the handler that receives a web
Request: Cloudflare Workers or Vercel below, or any server through a framework such as Hono.
Steps
1. Create two person attributes
On the People object, add two text attributes, Email status and Phone line type, with the slugs email_status and phone_line_type. Then read the id of the People object, which the webhook filter needs:
curl https://api.attio.com/v2/objects/people \
-H "Authorization: Bearer $ATTIO_TOKEN"
The id is data.id.object_id.
2. The handler
Save as attio-webhook.js:
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
const encoder = new TextEncoder()
function safeEqual(a, b) {
if (a.length !== b.length) return false
let difference = 0
for (let index = 0; index < a.length; index += 1) difference |= a.charCodeAt(index) ^ b.charCodeAt(index)
return difference === 0
}
async function signatureIsValid(env, rawBody, signature) {
const key = await crypto.subtle.importKey('raw', encoder.encode(env.ATTIO_WEBHOOK_SECRET), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'])
const digest = new Uint8Array(await crypto.subtle.sign('HMAC', key, encoder.encode(rawBody)))
return safeEqual([...digest].map((byte) => byte.toString(16).padStart(2, '0')).join(''), signature)
}
async function check(env, path, body, timeoutMs) {
for (let attempt = 1; attempt <= 2; attempt += 1) {
let response
try {
response = await fetch(`https://api.qelka.com/v1${path}`, {
method: 'POST',
headers: { Authorization: `Bearer ${env.QELKA_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
signal: AbortSignal.timeout(timeoutMs),
})
} catch (error) {
console.warn(`check skipped: ${path} unreachable (${error.name})`)
return null
}
if (response.ok) return response.json()
if (attempt === 1 && [429, 500, 502, 503].includes(response.status)) {
const retryAfter = Number(response.headers.get('Retry-After'))
await sleep((retryAfter > 0 ? Math.min(retryAfter, 5) : 1) * 1000)
continue
}
const failure = await response.json().catch(() => ({}))
console.warn(`check skipped: ${failure.error?.type ?? response.status} request ${response.headers.get('X-Request-Id')}`)
return null
}
return null
}
const attio = (env, path, init = {}) =>
fetch(`https://api.attio.com/v2${path}`, {
...init,
headers: { Authorization: `Bearer ${env.ATTIO_TOKEN}`, 'Content-Type': 'application/json' },
signal: AbortSignal.timeout(8000),
})
const current = (values) => (values ?? []).find((value) => value.active_until === null)
async function checkPerson(env, recordId) {
const found = await attio(env, `/objects/people/records/${recordId}`)
if (!found.ok) return console.warn(`person ${recordId} not readable: ${found.status}`)
const { values } = (await found.json()).data
if (current(values.email_status)?.value || current(values.phone_line_type)?.value) return
const email = current(values.email_addresses)?.email_address
const phone = current(values.phone_numbers)?.phone_number
const [emailResult, phoneResult] = await Promise.all([
email ? check(env, '/email', { email, mode: 'full' }, 15000) : null,
phone ? check(env, '/phone', { phone }, 8000) : null,
])
const changes = {}
if (email) changes.email_status = emailResult ? emailResult.status : 'unchecked'
if (phone) changes.phone_line_type = !phoneResult ? 'unchecked' : phoneResult.status === 'valid' ? phoneResult.line_type : phoneResult.status
if (Object.keys(changes).length === 0) return
const saved = await attio(env, `/objects/people/records/${recordId}`, { method: 'PATCH', body: JSON.stringify({ data: { values: changes } }) })
if (!saved.ok) console.warn(`person ${recordId} not updated: ${saved.status}`)
}
export async function handle(request, env, waitUntil) {
if (request.method !== 'POST') return new Response(null, { status: 405 })
const rawBody = await request.text()
if (!(await signatureIsValid(env, rawBody, request.headers.get('Attio-Signature') ?? ''))) return new Response(null, { status: 401 })
const events = JSON.parse(rawBody).events ?? []
const created = events.filter((event) => event.event_type === 'record.created' && event.id?.object_id === env.ATTIO_PEOPLE_OBJECT_ID)
for (const event of created) {
waitUntil(checkPerson(env, event.id.record_id).catch((error) => console.error(`person check failed: ${error.name}`)))
}
return new Response(null, { status: 204 })
}
Attio signs each delivery with an HMAC-SHA256 of the raw body, keyed with the webhook secret, and sends the hex digest in the Attio-Signature header. The handler checks it before parsing anything, and checks the object id again even though the subscription filters on it.
The handler answers at once and works in the background, because Attio waits only 5 seconds for an answer, according to its current docs, and retries deliveries that time out. Attio delivers at least once, so the same event can arrive twice: the handler reads the person first and stops when a status is already stored, which makes a duplicate free. Attio also sends an Idempotency-Key header that stays the same across retries, if you prefer to record what you processed.
mode: 'full' runs the mailbox check, the only way to get deliverable. If your host stops background work early, use mode: 'fast', which answers unknown with smtp_not_checked when the other checks pass. See the email reference. Attio stores numbers in E.164, so the phone check needs no country.
3. Deploy it with its secrets
import { handle } from './attio-webhook.js'
export default {
fetch: (request, env, ctx) => handle(request, env, (task) => ctx.waitUntil(task)),
}
import { waitUntil } from '@vercel/functions'
import { handle } from '../attio-webhook.js'
export default {
fetch: (request) => handle(request, process.env, waitUntil),
}
On Vercel the entry file is api/attio.js, with "type": "module" in package.json. Store as secrets (wrangler secret put or vercel env add): QELKA_API_KEY, ATTIO_TOKEN, ATTIO_PEOPLE_OBJECT_ID and, after the next step, ATTIO_WEBHOOK_SECRET.
4. Create the webhook
curl https://api.attio.com/v2/webhooks \
-H "Authorization: Bearer $ATTIO_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"data": {
"target_url": "https://your-handler.example.com/",
"subscriptions": [
{
"event_type": "record.created",
"filter": { "$and": [{ "field": "id.object_id", "operator": "equals", "value": "PEOPLE_OBJECT_ID" }] }
}
]
}
}'
Replace PEOPLE_OBJECT_ID with the id from step 1. Filters compare payload fields in dot notation with equals or not_equals, so companies and other objects never reach the handler. The response contains a secret, shown only at creation: store it as ATTIO_WEBHOOK_SECRET and redeploy. The target URL must be HTTPS.
5. Test it
With a sk_test_ key, create a person with the email disposable@example.com. A few seconds later, Email status reads risky. undeliverable@example.com gives undeliverable, any other well-formed address deliverable. Attio's developer settings can also send a test event to your URL; test payloads use real records of your workspace and ignore filters, so expect the handler to skip non-person events. Then swap in a live key.
6. Use the result
Filter views and lists on the two attributes:
Email status |
Meaning | Suggested action |
|---|---|---|
undeliverable |
Bad syntax, no domain, or the mailbox was refused | Keep the person out of sequences |
risky |
Disposable inbox, catch-all domain or full mailbox | Review before reaching out |
deliverable |
The mail server accepted the mailbox | Nothing to do |
unknown or unchecked |
Not conclusive, or the API was unreachable | Keep the person, check again later |
Phone line type holds mobile, landline, fixed_line_or_mobile, voip and the other line types of the phone reference for a valid number, or invalid or unchecked. In the United States and Canada the numbering plan does not separate mobiles from landlines, so expect fixed_line_or_mobile there; a level: 'live' check, at 3 credits, asks the network instead.
Handle errors and rate limits
Every API problem ends as unchecked, logged with the error type and the X-Request-Id; the person is never blocked or changed otherwise. No error is billed. 401 and 403 mean a wrong or restricted key and 402 an empty balance: alert on those. A 429 is retried once after Retry-After. A key allows 200 requests per 10 seconds, which an import of thousands of people can exceed: check imported files with a bulk file check instead. Each email check costs 1 credit and each basic phone check 1. See Errors and Rate limits.
On Attio's side, a delivery that keeps failing is retried for several days and the webhook is then marked degraded, according to its docs. A run of 401 responses from the handler usually means the stored secret belongs to another webhook.
Related
Frequently asked questions
Why does the handler fetch the record instead of reading the webhook?
Will writing the attributes send another webhook?
Attio already formats phone numbers. Why check them?
More in CRM
All integrationsPut 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