Skip to content

About

Find and verify work emails with looot, then load only the deliverable leads into an Instantly campaign. TypeScript CLI, dry run by default, cost cap

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

looot for Instantly

looot for Instantly

License Docs

looot gives a workspace one key and one prepaid balance for 4,200+ data endpoints from 300+ providers. This repo is a small command line tool that uses two of its jobs, find a work email and verify an email, and loads only the valid results into an Instantly campaign.

Status: source only. Not published to npm. Instantly has no code marketplace for third parties, so this runs from your machine with your own keys and needs no approval from Instantly. It has never run against a real Instantly workspace or a paid looot run. See "Not tested on the live platform".

Why

A lead list usually has names and company domains but no emails, and the emails you do have are not all good. Sending to bad addresses hurts a sending domain. This tool finds the missing emails, verifies every email, and pushes a lead to Instantly only when the verify result says it is deliverable. It prints the price before it spends anything and stops at a cap you set.

Quick start

Needs Node 20 or newer.

npm ci --ignore-scripts
npm run build

# 1. Dry run (the default). Prints a quote and a plan. Spends nothing, writes nothing to Instantly.
node dist/cli.js examples/leads.csv

# 2. Real run. Both keys come from the environment, never from flags.
export LOOOT_TOKEN=...          # looot dashboard, Settings, Agent tokens
export INSTANTLY_API_KEY=...    # Instantly, Settings, Integrations, API keys
node dist/cli.js leads.csv --apply --campaign <instantly-campaign-id> --max-cost 2

.env.example lists the two variable names. The tool does not load .env files itself; export the values in your shell.

Create the looot token in the looot dashboard under Settings, Agent tokens, with catalog.read, runs.read, runs.execute and usage.read. Create the Instantly key with the leads:create scope (or leads:all, all:create, all:all).

Lead file

CSV (or a JSON array of objects with the same keys). Column names are not case sensitive.

Column Alternatives Notes
first_name first with last_name, or use name
last_name last
name full_name used when first and last name are missing
domain website, company_domain protocol, www. and path are stripped
company company_name used when there is no domain
linkedin_url linkedin counts as both a name and a domain for the find step
email work_email if present, the find step is skipped and the email is only verified

A row needs a name (or first name, or LinkedIn URL) and a domain (or company, or LinkedIn URL), unless it already has an email. Other rows are skipped and listed in the result file with the reason. See examples/leads.csv (fake data on example domains).

Flags

Flag Default What it does
--apply off Spend looot credit and push to Instantly. Without it the tool only prints a quote and a plan.
--campaign <id> Instantly campaign id. Required with --apply.
--max-cost <usd> Cap for the whole run. Required with --apply.
--max-cost-per-lead <usd> 0.05 fallback.maxCostUsd sent with each looot run. A lead takes up to two runs (find, verify), so the worst case for one lead is twice this.
--concurrency <n> 3 Leads processed at once.
--out <file> looot-instantly-results.csv Result CSV, one row per lead.
--allow-unknown off Also push leads whose verify result has no deliverable value.
--no-skip-existing off Send skip_if_in_workspace: false. By default leads already in your Instantly workspace are skipped.

Exit codes: 0 ok, 1 some leads failed, 2 bad usage, 3 looot refused the token or the balance.

What it costs

Prices are the cheapest provider per call in the public catalog (GET https://api.looot.ai/v1/catalog/overview?depth=jobs) on 2026-10-09. They change. The tool reads them live on every run and falls back to these dated constants if the read fails; the quote says which one it used.

Job Used for Cheapest per call, 2026-10-09
people.email.find leads without an email $0.003598
people.email.verify every lead that has or finds an email $0.00145

A quote is the cheapest price times the number of lookups, shown as "from". The real charge is the actualCost of each run, which the tool sums and reports. A failed run costs nothing.

Worked example, 100 leads with no email: 100 x $0.003598 for find ($0.3598) plus up to 100 x $0.00145 for verify ($0.145) is from $0.5048. If looot finds an email for only 60 of them, only 60 verify calls run.

How the cap works

--max-cost is enforced in the tool, not only by looot. Each lookup is sent with fallback: { enabled: true, maxCostUsd: <max-cost-per-lead> }, so one run can spend at most that much across the providers looot tries. Before every lookup the tool checks spent so far + money reserved by lookups in flight + max-cost-per-lead. If that would pass --max-cost, it stops starting lookups. Leads not reached are written to the result file as not_processed with the reason cost_cap_reached. Because the check uses the worst case per lookup, a run stops a little before the cap, not after it. Raise --max-cost-per-lead and the tool becomes more conservative; lower it and more leads fit.

The idempotency key of each run is instantly- plus the SHA-256 of the job, the sorted input and the UTC date. Running the same file twice on one day replays the first runs and does not pay twice. The next day it runs fresh.

If a run is still queued or running after the 25 second wait, the tool polls GET /v1/runs/{runId} every 2 seconds for up to 2 minutes.

A 401 from looot (bad token) or a 402 (balance too low, nothing charged) stops the whole run with a message, writes the result file and exits 3.

What gets pushed and what never does

A lead is pushed only when the verify run completed and normalized.fields.deliverable === true.

Verify result Pushed
deliverable is true yes
deliverable is false never
deliverable missing (no field map from the provider that answered) only with --allow-unknown
find returned no email no, reason email_not_found
run failed, blocked or stopped no, counted as failed
Instantly reports the lead as not created (duplicate, blocklist, invalid) no, reason not_added_by_instantly

normalized.fields is optional in looot responses. When the provider that answered has no field map, the tool treats the result as not found (find) or unknown (verify).

Instantly endpoint used

Add leads in bulk to a campaign: POST https://api.instantly.ai/api/v2/leads/add.

  • Auth: Authorization: Bearer <INSTANTLY_API_KEY>.
  • Scope: one of leads:create, leads:all, all:create, all:all.
  • Body: campaign_id, leads (1 to 1000 objects), skip_if_in_workspace (true by default here).
  • Lead fields sent: email, and when known first_name, last_name, company_name, website. Only email is required for a campaign.
  • The tool sends batches of at most 1000 leads. It reads created_leads from the response to mark each lead pushed or not.
  • Rate limit per the docs: 100 requests per second and 6,000 per minute for the whole workspace, answered with HTTP 429. The tool retries a 429 up to 4 times, waiting the Retry-After seconds if the header is there and 1, 2, 4, 8 seconds otherwise, then marks the batch failed.
  • A 402 from Instantly means the workspace has no active paid plan.

Docs read on 2026-10-09:

Result file

One row per lead: row, first_name, last_name, name, domain, company, linkedin_url, email_input, email, found_by_looot, verify_status, deliverable, provider, cost_usd, pushed, reason. The last console line is a summary, for example found 2, verified 3, pushed 2, skipped 1, failed 0, not processed 0, spent $0.020000. Cells that start with =, +, - or @ get a leading apostrophe so a spreadsheet does not run them.

Develop and test

npm ci --ignore-scripts
npm run typecheck
npm test
npm run build

Tests use Node's built-in test runner through tsx. Both APIs are replaced by an injected fetch, so no test touches the network or spends credit. They cover CSV parsing, quote math, the dry run, the apply path with the exact Instantly request, the cost cap, undeliverable leads, the 401 and 402 messages, the Instantly 429 retry, idempotency keys and run polling.

Output on 2026-10-09, Node 24.18.0:

ℹ tests 41
ℹ pass 41
ℹ fail 0

Dry run of the built CLI on examples/leads.csv (one free catalog read, nothing else):

Quote
  leads in file:        4 (4 usable, 0 skipped for missing fields)
  find lookups:         3 x $0.003598
  verify lookups:       up to 4 x $0.00145
  price source:         live catalog (https://api.looot.ai/v1/catalog/overview?depth=jobs)
  from total:           $0.016594 (cheapest provider per call; the real charge is actualCost on each run)
  max cost per lead:    $0.05 (fallback cap for one run)
  max cost, whole run:  not set (required with --apply)

Dry run. Plan:
  row 1  Ada Example: find, verify, push if deliverable
  row 2  Ben Test, Jr.: find, verify, push if deliverable
  row 3  Carla Sample: find, verify, push if deliverable
  row 4  [email protected]: verify, push if deliverable

No looot run was started and nothing was sent to Instantly. Add --apply to run it.

The project has no runtime dependencies. Dev dependencies are typescript, tsx and @types/node, pinned to exact versions.

Not tested on the live platform

Never run: a real Instantly workspace, a real campaign, a paid looot run (POST /v1/runs). The tests use stand-ins built from the docs. Check in this order before a big list:

  1. The Instantly API key has the leads:create scope and the workspace has an active paid plan.
  2. Run with a 3 row file, --max-cost 0.5 and a test campaign. Look at the result CSV and at the campaign in Instantly.
  3. The lead appears in the campaign with the first name, last name, company and website fields filled as expected, and skip_if_in_workspace behaves as you want.
  4. The normalized.fields names email, deliverable and status come back on both jobs. If deliverable is missing for most leads, --allow-unknown is the only way to push them, so decide that on purpose.
  5. The sum of cost_usd in the result file matches the usage you see in the looot dashboard.

Run it on a schedule

Run it from cron on a machine that already has the two variables set. The same-day idempotency key means a repeated run does not pay twice for the same lead.

0 7 * * 1-5  cd /path/to/looot-instantly && node dist/cli.js leads.csv --apply --campaign <id> --max-cost 2

On GitHub Actions, put LOOOT_TOKEN and INSTANTLY_API_KEY in repository secrets and pass them with env:. Keep real lead lists out of a public repo.

Related

MIT, copyright looot.

About

Find and verify work emails with looot, then load only the deliverable leads into an Instantly campaign. TypeScript CLI, dry run by default, cost cap

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages