Skip to main content

Cleanlist AI Python SDK (cleanlist-ai)

Official Python client for the Cleanlist AI API (v2) — B2B lead discovery, waterfall enrichment, lead lists, smart agents, and export.

The package ships both a standard and an asynchronous client generated from the public v2 OpenAPI schema, plus a small Cleanlist convenience facade so you can get productive in a few lines.

from cleanlist_ai import Cleanlist

with Cleanlist(access_token="clapi_live_...") as cl:
    print(cl.workspace.whoami().organization_name)
    lst = cl.lead_lists.create_list({"name": "Q3 outbound"})
    print("created list:", lst.list_id)
  • ✅ Fully typed (Pydantic v2 models for every request & response)
  • ✅ Standard (cleanlist_ai) and async (cleanlist_ai.aio) — same method names
  • ✅ Bearer-token auth, sensible production defaults
  • ✅ Generated from the same schema the API serves, so it never drifts

Table of contents


Installation

pip install cleanlist-ai

Requires Python 3.8+. Installing pulls in both the standard (urllib3) and async (aiohttp) runtimes, so both clients work out of the box.

Authentication

Every request is authenticated with a Cleanlist API key, sent as an Authorization: Bearer <key> header. Create one in the portal under Settings → API Keys (keys look like clapi_live_...).

Pass it explicitly, or set the CLEANLIST_API_KEY environment variable and let the client pick it up:

from cleanlist_ai import Cleanlist

cl = Cleanlist(access_token="clapi_live_...")   # explicit
cl = Cleanlist()                                # reads CLEANLIST_API_KEY
export CLEANLIST_API_KEY="clapi_live_..."

Keep keys secret. Never commit them. Prefer environment variables or a secrets manager over hard-coding.

Quickstart (standard)

from cleanlist_ai import Cleanlist
from cleanlist_ai.models import CreateListRequest, EnrichPersonRequest

with Cleanlist() as cl:                                     # CLEANLIST_API_KEY
    # 1. Who am I? (identity, tier, credit-affecting scopes)
    me = cl.workspace.whoami()
    print(f"Org: {me.organization_name} | tier: {me.tier}")

    # 2. Check credit balance
    print("credits:", cl.workspace.credits_balance().credits)

    # 3. Create a lead list
    lst = cl.lead_lists.create_list(CreateListRequest(name="Demo — API"))
    print("list id:", lst.list_id)

    # 4. Enrich a single person into that list (async workflow — returns a handle)
    job = cl.enrichment.enrich_person(
        EnrichPersonRequest(
            lead_list_id=lst.list_id,
            first_name="Ada",
            last_name="Lovelace",
            company_name="Analytical Engines",
        )
    )
    print("enrichment workflow:", job.workflow_id, "| reserved:", job.credits_reserved)

    # 5. Poll until it settles
    status = cl.enrichment.enrichment_status(job.workflow_id)
    print("status:", status.status)

Quickstart (async)

Everything is identical, but under cleanlist_ai.aio, awaited, and driven from an async with block:

import asyncio
from cleanlist_ai.aio import Cleanlist
from cleanlist_ai.aio.models import CreateListRequest

async def main():
    async with Cleanlist() as cl:                          # CLEANLIST_API_KEY
        me = await cl.workspace.whoami()
        print("org:", me.organization_name)

        lst = await cl.lead_lists.create_list(CreateListRequest(name="Demo — async"))
        print("list id:", lst.list_id)

asyncio.run(main())

Import models from cleanlist_ai.aio.models when using the async client (they are the same shapes as cleanlist_ai.models; both are accepted, kept separate for typing).

Configuration

Cleanlist(...) accepts:

Argument Default Description
access_token $CLEANLIST_API_KEY Your API key. Sent as Authorization: Bearer ….
host https://api.cleanlist.ai API base URL. Use http://localhost:8000 for local dev.
configuration None A pre-built Configuration for advanced needs (proxy, retries, etc.).
max_attempts 3 Tries per request, the first included. 1 turns retries off.

For finer control, build a Configuration yourself:

from cleanlist_ai import Cleanlist, Configuration

config = Configuration(host="https://api.cleanlist.ai", access_token="clapi_live_...")
config.retries = 3            # urllib3 retry count (standard)
cl = Cleanlist(configuration=config)

Per-request timeouts are supported on every method via _request_timeout (seconds, or a (connect, read) tuple):

cl.workspace.whoami(_request_timeout=10)

Core concepts

Credits & the estimate → quote flow

Search and list management are free; enrichment and smart-agent runs cost credits. Bulk/paid operations (enrich_list, run_smart_agent, and CSV import with enrichment) require a signed quote obtained from credits_estimate first. The quote pins the price and is single-use:

from cleanlist_ai.models import EstimateCostRequest, EnrichListRequest

quote = cl.workspace.credits_estimate(
    EstimateCostRequest(tool="enrich_list", list_id=lst.list_id, scope="full")
)
print(f"cost={quote.estimated_cost} sufficient={quote.sufficient} quote={quote.quote_id}")

if quote.sufficient:
    run = cl.enrichment.enrich_list(
        EnrichListRequest(list_id=lst.list_id, scope="full", quote_id=quote.quote_id)
    )
    print("bulk workflow:", run.workflow_id)

Enrichment scopes (what you pay for per lead):

Scope Returns Cost
partial email + LinkedIn + title + company 1 credit
phone_only phone only 10 credits
full email and phone 11 credits

Pricing is pay-for-results — the reservation (credits_reserved) is a cap; the unused portion is refunded when the workflow settles.

Enrichment is asynchronous — poll for results

enrich_person, enrich_company, enrich_by_task, and enrich_list dispatch a workflow and return immediately with a workflow_id (and a poll_url). Poll enrichment_status(workflow_id) until status is completed (or failed):

import time

job = cl.enrichment.enrich_person(EnrichPersonRequest(lead_list_id=lst.list_id, email="ada@example.com"))
while True:
    s = cl.enrichment.enrichment_status(job.workflow_id)
    print(s.status, s.processed, "/", s.total)
    if s.status in ("completed", "failed", "cancelled"):
        break
    time.sleep(3)
print("charged:", s.credits_charged, "refunded:", s.credits_refunded)

See examples/ for a complete, runnable polling helper (standard & async).


Endpoint reference

The v2 surface is 73 operations across 14 resource groups, exposed on the Cleanlist facade as cl.workspace, cl.lead_lists, cl.people_finder, cl.enrichment, cl.smart_agents, cl.export, cl.actions, cl.gtm_agents, cl.plays, cl.gtm_tasks, cl.inbox, cl.signals, cl.accounts_data and cl.webhooks. All examples below use the standard client; prepend await (and import from cleanlist_ai.aio…) for async.

Auto-generated, field-by-field docs for every model live in docs/reference/.

Workspace (cl.workspace)

Identity, credits, API keys, and usage.

Method HTTP Description
whoami() GET /api/v2/whoami Current identity, org, tier, scopes & feature grants.
credits_balance() GET /api/v2/credits/balance Spendable credit balance for the org.
credits_estimate(EstimateCostRequest) POST /api/v2/credits/estimate Price an operation and get a signed, single-use quote.
list_api_keys() GET /api/v2/api-keys List the org's API keys (metadata only).
usage_report(days=…, group_by=…) GET /api/v2/usage Credit-usage report over a window.
me      = cl.workspace.whoami()
balance = cl.workspace.credits_balance()
keys    = cl.workspace.list_api_keys()
usage   = cl.workspace.usage_report(days=30, group_by="tool")

quote = cl.workspace.credits_estimate(
    EstimateCostRequest(tool="enrich_person", scope="full", row_count=1)
)

Lead Lists (cl.lead_lists)

Create and manage lists and the leads inside them.

Method HTTP Description
create_list(CreateListRequest) POST /api/v2/lead-lists Create a list (idempotent on name).
list_lists(folder_id=…, limit=…, cursor=…) GET /api/v2/lead-lists List your lead lists (paginated).
get_list(list_id) GET /api/v2/lead-lists/{list_id} Fetch one list.
update_list(list_id, PublicLeadListUpdate) PATCH /api/v2/lead-lists/{list_id} Rename / move / edit description.
delete_list(list_id) DELETE /api/v2/lead-lists/{list_id} Delete a list.
list_leads_in_list(list_id, limit=…, cursor=…) GET /api/v2/lead-lists/{list_id}/leads Page through leads.
add_leads_to_list(list_id, Body) POST /api/v2/lead-lists/{list_id}/leads Add leads by id or from a search cohort.
remove_leads_from_list(list_id, RemoveLeadsRequest) DELETE /api/v2/lead-lists/{list_id}/leads Remove up to 100 leads.
csv_import(list_id, CsvImportRequest) POST /api/v2/lead-lists/{list_id}/csv-import Import leads from a base64 CSV.
find_people(list_id, FindPeopleRequest) POST /api/v2/lead-lists/{list_id}/find-people Find + import people at the list's companies (async).
find_people_status(list_id, workflow_id) GET …/{list_id}/find-people/status/{workflow_id} Poll a find-people job.
from cleanlist_ai.models import (
    CreateListRequest, PublicLeadListUpdate, Body, AddByLeadIds, RemoveLeadsRequest,
)

lst = cl.lead_lists.create_list(CreateListRequest(name="Prospects — West"))

cl.lead_lists.update_list(lst.list_id, PublicLeadListUpdate(description="US west region"))

page = cl.lead_lists.list_leads_in_list(lst.list_id, limit=100)
print(page.total, "leads")

# Add leads you already have ids for (Body is a one-of: ids OR a search cohort)
cl.lead_lists.add_leads_to_list(
    lst.list_id, Body(AddByLeadIds(lead_ids=["lead_abc", "lead_def"]))
)

cl.lead_lists.remove_leads_from_list(lst.list_id, RemoveLeadsRequest(lead_ids=["lead_abc"]))

People Finder (cl.people_finder)

Search people by filters. Searching is free; credits are spent only when you enrich or save.

Method HTTP Description
search_people(PeopleSearchRequest) POST /api/v2/people/find Search people by structured criteria (paginated).
search_filters_people(field, query=…) GET /api/v2/people/find/filters Valid values / autocomplete for a filter field.
compile_search(CompileRequest) POST /api/v2/people/find/compile Dry run: show the compiled filter without searching.
companies_find_start(PeopleByCompaniesRequest) POST /api/v2/people/find-at-companies Start an async "find people at these companies" search.
companies_find_status(task_id) GET /api/v2/people/find-at-companies/status/{task_id} Poll that search.
from cleanlist_ai.models import CompileRequest, PeopleSearchCriteria, PeopleSearchRequest

# `field` is positional (the generator names the parameter `var_field`).
seniority = cl.people_finder.search_filters_people("seniority")
titles    = cl.people_finder.search_filters_people("titles", query="vp sales")

criteria = PeopleSearchCriteria(
    jobTitlesInclude=["VP of Sales"],
    seniority=["Vice President"],
    contactCountries=["USA"],
)
preview = cl.people_finder.compile_search(CompileRequest(criteria=criteria))
page    = cl.people_finder.search_people(PeopleSearchRequest(criteria=criteria, limit=25))
for row in page.results:
    print(row.full_name, row.title, row.company)

Enrichment (cl.enrichment)

Run the provider waterfall to find emails/phones. All dispatch an async workflow (poll enrichment_status).

Method HTTP Description
enrich_person(EnrichPersonRequest) POST /api/v2/enrichment/person Enrich one contact into a list.
enrich_company(EnrichCompanyRequest) POST /api/v2/enrichment/company Enrich a company by domain/name/ticker.
enrich_by_task(EnrichByTaskRequest) POST /api/v2/enrichment/by-task Enrich entities from a prior search/list task.
enrich_list(EnrichListRequest) POST /api/v2/enrichment/bulk Bulk-enrich a whole list (needs a quote_id).
enrichment_status(workflow_id) GET /api/v2/enrichment/status/{workflow_id} Poll a workflow's progress & results.
from cleanlist_ai.models import (
    EnrichPersonRequest, EnrichCompanyRequest, EnrichByTaskRequest, EnrichListRequest,
)

person = cl.enrichment.enrich_person(
    EnrichPersonRequest(lead_list_id=lst.list_id, linkedin_url="https://linkedin.com/in/ada")
)

company = cl.enrichment.enrich_company(EnrichCompanyRequest(domain="stripe.com"))

status = cl.enrichment.enrichment_status(person.workflow_id)

Smart Agents (cl.smart_agents)

Run AI columns over a list (custom prompts, cold intros, preset research agents).

Method HTTP Description
run_smart_agent(RunSmartAgentRequest) POST /api/v2/smart-agents/run Run an agent as a new AI column (needs a quote_id).
list_smart_agents(list_id=…, limit=…) GET /api/v2/smart-agents Recent agent runs (optionally per-list).
get_smart_agent_results(smart_agent_task_id) GET /api/v2/smart-agents/{smart_agent_task_id} Fetch a run's per-lead output.
from cleanlist_ai.models import EstimateCostRequest, RunSmartAgentRequest

quote = cl.workspace.credits_estimate(
    EstimateCostRequest(tool="run_smart_agent", list_id=lst.list_id, agent_type="custom_ai", row_count=50)
)
run = cl.smart_agents.run_smart_agent(
    RunSmartAgentRequest(
        list_id=lst.list_id,
        agent_type="custom_ai",
        column_name="Personalized angle",
        prompt="In one sentence, suggest a cold-outreach angle for this lead.",
        max_rows=50,
        quote_id=quote.quote_id,
    )
)
results = cl.smart_agents.get_smart_agent_results(run.smart_agent_task_id)

Export (cl.export)

Method HTTP Description
export_csv(ExportCsvRequest) POST /api/v2/export/csv/signed-url Export a list to CSV; returns a signed download URL.
export_json(list_id, limit=…, cursor=…, columns=[…]) GET /api/v2/export/json Export list rows inline as JSON (paginated).
from cleanlist_ai.models import ExportCsvRequest

signed = cl.export.export_csv(ExportCsvRequest(list_id=lst.list_id))
print("download:", signed.download_url)   # signed URL, valid until signed.expires_at

data = cl.export.export_json(lst.list_id, limit=500)
for row in data.leads:
    print(row)

Agents, plays, tasks, inbox, signals and webhooks

Group Methods
cl.actions list_actions(), call_action(name, ActionCall), confirm_card(ConfirmCall)
cl.gtm_agents list_gtm_agents(), create_gtm_agent(), get_gtm_agent(), patch_gtm_agent(), set_gtm_agent_status(), run_gtm_agent(), list_gtm_agent_runs(), get_gtm_run(), list_gtm_run_records()
cl.plays list_plays(), run_play(), get_play_event()
cl.gtm_tasks list_gtm_tasks(), create_gtm_task(), get_gtm_task(), update_gtm_task(), list_updates()
cl.inbox list_inbox_threads(), read_inbox_thread(), update_inbox_thread(), reply_in_inbox_thread()
cl.signals search_job_postings(), list_job_changes(), check_job_changes(), company_signals(), search_linkedin_posts(), linkedin_post_engagers(), companies_by_technology()
cl.accounts_data buying_committee(), org_structure(), list_meetings(), read_meeting()
cl.webhooks list_webhooks(), create_webhook(), delete_webhook(), list_webhook_deliveries()
cl.workspace list_request_logs() (GET /api/v2/logs)
cl.enrichment batch_people_lookup(), batch_companies_lookup()

Turning an agent on, running an agent and running a play spend credits and can email people or write to a CRM. Each call takes a quote_id from cl.workspace.credits_estimate (the quote lists the run's effects and required_scopes), and only starts with commit=True; without it you get a preview.

from cleanlist_ai.models import EstimateCostRequest, RunGtmAgentBody

quote = cl.workspace.credits_estimate(EstimateCostRequest(tool="run_gtm_agent", agent_id="ag_123"))
run = cl.gtm_agents.run_gtm_agent("ag_123", RunGtmAgentBody(quote_id=quote.quote_id, commit=True))

Examples

Runnable scripts live in examples/ (setup notes in examples/README.md). Each reads CLEANLIST_API_KEY and an optional CLEANLIST_HOST.

Example What it shows Credits
01_quickstart.py whoami, credit balance, create and list lead lists. Free
02_enrich_person.py Enrich one contact and poll the workflow to completion. Spends
03_bulk_enrich_with_quote.py The estimate → quote → bulk-enrich credit flow. Spends
04_lead_lists_crud.py Lead-list lifecycle: create, read, update, paginate, delete. Free
05_smart_agent.py Run a custom AI smart-agent column and read the results. Spends
06_export.py Export a list to CSV (signed URL) and page through JSON. Free
07_async_quickstart.py The async client (cleanlist_ai.aio) end to end. Free
08_error_handling.py Catching typed API exceptions. Free
09_find_people.py People Finder: filter values, compile preview, search + next page. Free

Retries, idempotency and rate limits

GET, HEAD and OPTIONS are retried on network errors, 429 and 5xx, with backoff that honors Retry-After (a wait over a minute is returned to you instead). POST, PUT, PATCH and DELETE are retried only on a 429, a 503 idempotency_unavailable, or a network error with no response when the request carries an Idempotency-Key, because any other 5xx may mean the write already ran. POST /api/v2/actions/confirm and inbox replies are never retried.

The client adds an Idempotency-Key to every write and keeps it the same across its retries. A replay of a stored response comes back with Idempotent-Replayed: true. To set your own:

cl.lead_lists.create_list(CreateListRequest(name="Q3"), _headers={"Idempotency-Key": "order-1234"})

After any call, cl.last_response has the rate-limit headers and the mode:

cl.last_response.rate_limit           # RateLimit(limit, remaining, reset); reset is unix seconds
cl.last_response.idempotent_replayed  # True when the server replayed a stored response
cl.mode                               # "test" for a clapi_test_ key's sandbox workspace, else "live"

read_response_meta(err.status, err.headers) reads the same values off an ApiException.

Verifying webhooks

from cleanlist_ai import verify_webhook_signature

# raw_body: the request body bytes exactly as received, not re-serialized JSON.
if not verify_webhook_signature(raw_body, request.headers.get("Cleanlist-Signature"), secret):
    return Response(status=400)

Signatures older than 5 minutes are refused (tolerance_seconds= changes that).

Error handling

Non-2xx responses raise ApiException (subclasses expose status, reason, body, and parsed data where available):

from cleanlist_ai import ApiException
from cleanlist_ai.exceptions import NotFoundException, UnauthorizedException

try:
    cl.lead_lists.get_list("does-not-exist")
except NotFoundException:
    print("no such list")
except UnauthorizedException:
    print("bad or missing API key")
except ApiException as e:
    print(f"API error {e.status}: {e.body}")

Validation errors (HTTP 422) come back as a PublicApiError envelope in e.data, like every other error status.

Pagination

List endpoints return a page plus an opaque cursor. Pass it back to fetch the next page; a falsy cursor means you've reached the end:

cursor = None
while True:
    page = cl.lead_lists.list_leads_in_list(lst.list_id, limit=500, cursor=cursor)
    for lead in page.leads:
        ...
    cursor = page.cursor
    if not cursor:
        break

Using the generated API classes directly

The Cleanlist facade is optional sugar. You can wire the generated pieces yourself:

from cleanlist_ai import ApiClient, Configuration
from cleanlist_ai.api import PublicWorkspaceApi

config = Configuration(host="https://api.cleanlist.ai", access_token="clapi_live_...")
with ApiClient(config) as api_client:
    workspace = PublicWorkspaceApi(api_client)
    print(workspace.whoami())

The async equivalents live under cleanlist_ai.aio (ApiClient, Configuration, cleanlist_ai.aio.api.*).

Regenerating from the schema

This SDK is generated from the backend's public v2 OpenAPI schema with openapi-generator-cli (pinned in openapitools.json). To refresh after an API change:

# 1. Re-export openapi/cleanse-api-v2.oas.json from the backend, then:
PYTHON=python3 bash scripts/generate.sh

scripts/generate.sh cleans the operation ids into readable method names (scripts/prepare_spec.py), generates the standard + async clients, and re-applies the Cleanlist facade overlay.

Support

Licensed under the MIT License.

Metadata

Release files for cleanlist-ai 5.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cleanlist-ai 5.0.0
File Size Uploaded Provenance Actions
cleanlist_ai-5.0.0.tar.gz 386.7 kB With provenance Details for cleanlist_ai-5.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cleanlist-ai 5.0.0
File Interpreter ABI Platform Actions
cleanlist_ai-5.0.0-py3-none-any.whl Python 3 none any Details for cleanlist_ai-5.0.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / cleanlist_ai-5.0.0.tar.gz

Download URL cleanlist_ai-5.0.0.tar.gz
Size 386.7 kB
Tags Source
SHA-256 checksum
How to use checksums
adfb6a23c6afd13b3c245f09d0e2224e133f868c72a5be8b1795d4df3ec9d599
BLAKE2b-256 checksum
How to use checksums
1ea5f47380ace9b3b2f1217c02c0e76e3f3d6981ab43cc44a82f3aed5c194a93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / cleanlist_ai-5.0.0-py3-none-any.whl

Download URL cleanlist_ai-5.0.0-py3-none-any.whl
Size 774.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a19905171d1512d356e0457265776b4bdbf75b791f542602dc22a07fd29a156
BLAKE2b-256 checksum
How to use checksums
0c2300135d7dfe5acc4548235ac4b99300c873cac8d1b9d01db8c411a6f76ede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for cleanlist-ai 5.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cleanlist_ai-5.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page