Sheets & data
Validate emails and phone numbers in a Retool app
A Retool REST API resource holds the key as a secret, two queries check the selected row's email and phone, a table shows the results and a button re-checks.
Updated 2026-11-26
This recipe adds email and phone checks to a Retool app. Your team selects a customer in a table, and the app verifies the row's email address and phone number with the API, shows the results in a second table, and offers a button to check again from scratch. The API key stays in a Retool resource and never reaches the browser. There is no Qelka integration in Retool's resource list: you connect the API as a REST API resource, which takes a few minutes.
What you need
- A Retool organization where you can create resources and apps.
- An app with a table named
contactswhose rows haveemail,phoneandcountrycolumns, from any of your resources.countryis a two-letter code such asUS, used to read numbers written without+; it can be empty. - A Qelka API key. A
sk_test_key returns simulated results and never spends credits: see Test mode. Use a key restricted toemailandphonein the dashboard: see Restricted keys.
Steps
1. Store the key as a secret
Go to Settings, then Configuration variables, and create a variable named VALIDATION_API_KEY. Select Mark variable as secret, and give it a value for each environment you use: a sk_test_ key in staging, a live key in production. Retool hides the value of a secret variable and only lets resources read it, not apps.
Configuration variables are a Business and Enterprise feature as far as we know, so check your plan. Without them, paste the key directly into the resource's Bearer token field in the next step: it is stored with the resource, on Retool's side, and is not sent to the browser either.
2. Create the REST API resource
Go to Resources, select Create new, then Resource, and choose REST API. Fill in:
- Name:
Validation API. - Base URL:
https://api.qelka.com/v1. - Authentication: Bearer token, with the token
{{ environment.variables.VALIDATION_API_KEY }}.
Create the resource. Retool proxies every request through its backend and adds the Authorization: Bearer header there, so builders and users of the app see neither the header nor the key.
3. Query the email
In the app, add a query named checkEmail on the Validation API resource:
- Action type:
POST. In the URL field, after the base URL, type/email. - Headers:
Content-Typeset toapplication/json. - Body: Raw, with:
{{ JSON.stringify({ email: contacts.selectedRow.email, mode: 'full', fresh: typeof fresh === 'boolean' && fresh }) }}
- Advanced: set Timeout after to
20000milliseconds. Retool's default is ten seconds, and a full check can wait on a slow mail server. Retool caps every query at 120 seconds on its cloud, by its own documentation. - Let the query run only when triggered, not automatically or on page load. Turn on caching in its advanced settings, for an hour for example: if someone selects the same row again, Retool reuses the answer instead of spending a credit.
mode: 'full' includes the mailbox check: a person is looking at the screen, and the most precise answer is worth a second or two. fresh is only set by the re-check button below; typeof keeps the expression valid when the query runs without it. See the email reference.
4. Query the phone number
Add a second query, checkPhone, on the same resource, with action type POST, the path /phone, the same header, timeout and caching, and this raw body:
{{ JSON.stringify({ phone: contacts.selectedRow.phone, country: contacts.selectedRow.country || undefined, fresh: typeof fresh === 'boolean' && fresh }) }}
JSON.stringify drops a field whose value is undefined, so an empty country is simply not sent. The answer includes e164, the number in international format, and line_type, such as mobile or landline. See the phone reference.
5. Run both on row selection
Select the contacts table and add two event handlers on the Select row event:
- Action Control query, query
checkEmail, method Trigger. In the handler's advanced settings, set Only run when to{{ !!contacts.selectedRow.email }}. - The same for
checkPhone, with{{ !!contacts.selectedRow.phone }}.
A row without an email or a phone number then sends no request for it.
6. Show the results in a table
Add a transformer named checkResults:
const row = {{ contacts.selectedRow }}
function describe(label, input, query, read) {
if (!input) return { check: label, input: '', status: '', detail: 'Nothing to check' }
if (query.isFetching) return { check: label, input, status: 'checking', detail: '' }
if (query.error) return { check: label, input, status: 'unchecked', detail: query.error }
if (!query.data) return { check: label, input, status: '', detail: 'Not checked yet' }
return { check: label, input, ...read(query.data) }
}
return [
describe('Email', row?.email, {
isFetching: {{ checkEmail.isFetching }},
error: {{ checkEmail.error }},
data: {{ checkEmail.data }},
}, (data) => ({
status: data.status,
detail: data.did_you_mean ? `Did you mean ${data.did_you_mean}?` : data.reason,
})),
describe('Phone', row?.phone, {
isFetching: {{ checkPhone.isFetching }},
error: {{ checkPhone.error }},
data: {{ checkPhone.data }},
}, (data) => ({
status: data.status,
detail: data.e164 ? `${data.e164}, ${data.line_type}` : data.line_type,
})),
]
Then add a table named results with its data set to {{ checkResults.value }}. It shows one line per check, with the status and the useful detail: the suggested correction or the reason for an email, the E.164 format and line type for a phone number. A failed query shows unchecked and Retool's error message, which carries our error type, instead of a stale answer.
7. Add the re-check button
Add a JavaScript query named recheck:
const row = contacts.selectedRow
checkEmail.invalidateCache()
checkPhone.invalidateCache()
const runs = []
if (row?.email) runs.push(checkEmail.trigger({ additionalScope: { fresh: true } }))
if (row?.phone) runs.push(checkPhone.trigger({ additionalScope: { fresh: true } }))
await Promise.all(runs)
Add a button labeled Re-check, with a Click event handler that triggers recheck, and set the button's Disabled property to {{ !contacts.selectedRow }}. additionalScope passes fresh: true to both queries for this run only, so the API skips its 7-day result cache and checks again. Retool documents that trigger can only be called from JavaScript queries, not from transformers or expressions, which is why the button runs one.
Use the button when a customer says an address works or a number was ported: it costs the same as a normal check. See Caching.
Read the results
| Check | Status | What to do |
|---|---|---|
deliverable |
Use it | |
undeliverable |
Fix it with the suggestion, or ask the customer for another address | |
risky |
Read the reason: disposable inbox, catch-all domain or full mailbox | |
unknown |
Not conclusive: not a bad address | |
| Phone | valid |
Use the E.164 format to store or dial it |
| Phone | invalid |
Not a number in its country's numbering plan |
| Phone | unknown |
No + and no country: fill the country column and re-check |
| Either | unchecked |
The query failed: see the detail, then re-check |
Handle errors and rate limits
Nothing is billed on errors. A wrong or restricted key (401 invalid_api_key, 403 forbidden) or an empty balance (402 insufficient_credits) makes the query fail, and the results table shows unchecked with the message. To report a failure to us, open Retool's debug tools: the query's metadata.headers holds the response headers, X-Request-Id among them, when Retool keeps them for the failed run. A key allows 200 requests per 10 seconds, far more than people selecting rows will send; if a script loops over many rows, handle 429 rate_limited by waiting for Retry-After. See Errors and Rate limits.
The results live in the app's memory and disappear when the page is reloaded, apart from Retool's query cache. To keep them, add an update query on your own database that writes checkEmail.data.status and checkPhone.data.e164 back to the customer's row after a successful run.
Related
Frequently asked questions
Can people who use the app see the API key?
Does every row selection spend credits?
How do I check a whole table instead of one row?
More in Sheets & data
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