Skip to contentSkip to navigation

Python SDK

Official Python SDK for the FoxReach API. Sync and async support, typed models, auto-pagination.

Installation

pip
pip install foxreach

Requirements: Python 3.9+

Quick Start

Python
from foxreach import FoxReach, LeadCreate

client = FoxReach(api_key="otr_your_api_key")

# Create a lead
lead = client.leads.create(LeadCreate(
    email="jane@example.com",
    first_name="Jane",
    last_name="Smith",
    company="Acme Corp",
))
print(f"Created: {lead.id}")

# List leads
page = client.leads.list(search="jane", page_size=25)
for lead in page:
    print(f"{lead.email} | {lead.company}")

# Check pagination info
print(f"Page {page.meta.page}/{page.meta.total_pages}, {page.meta.total} total")

client.close()

Configuration

Python
client = FoxReach(
    api_key="otr_...",                                  # required
    base_url="https://api.foxreach.io/api/v1",          # default
    timeout=30.0,                                        # seconds, default
    max_retries=3,                                       # retries on 429, default
)

You can also use environment variables:

Terminal
export FOXREACH_API_KEY=otr_your_api_key
Python
import os
from foxreach import FoxReach

client = FoxReach(api_key=os.environ["FOXREACH_API_KEY"])

Resources

The SDK covers every operation of the public API (version 0.6.0 and later; upgrade with pip install -U foxreach). Every method has an async twin on AsyncFoxReach. Methods that return a dict give the API's data with keys in snake_case.

Leads

Python
from foxreach import LeadCreate, LeadUpdate

# List with filters
page = client.leads.list(page=1, page_size=50, search="acme", status="active")

# Get by ID
lead = client.leads.get("cld_abc123")

# Create
lead = client.leads.create(LeadCreate(
    email="jane@example.com",
    first_name="Jane",
    company="Acme Corp",
    tags=["enterprise"],
))

# Update
lead = client.leads.update("cld_abc123", LeadUpdate(company="New Corp"))

# Delete
client.leads.delete("cld_abc123")

# Get activity timeline and campaign memberships (returns a dict with snake_case keys)
activity = client.leads.activity("cld_abc123")
for item in activity["activities"]:
    print(f"{item['type']}: {item['subject']} at {item['timestamp']}")
for membership in activity["campaigns"]:
    print(f"Campaign: {membership['campaign_name']} ({membership['status']})")

Campaigns

Python
from foxreach import CampaignCreate, CampaignUpdate

# List
page = client.campaigns.list(status="active")

# Create (starts in draft)
campaign = client.campaigns.create(CampaignCreate(
    name="Q1 Outreach",
    timezone="America/New_York",
    daily_limit=50,
))

# Update
client.campaigns.update("cmp_xyz789", CampaignUpdate(daily_limit=100))

# Lifecycle
client.campaigns.start("cmp_xyz789")
client.campaigns.pause("cmp_xyz789")
client.campaigns.resume("cmp_xyz789")  # resume a paused campaign

# Add leads and accounts
client.campaigns.add_leads("cmp_xyz789", ["cld_1", "cld_2"])
client.campaigns.add_accounts("cmp_xyz789", ["acc_1"])

# Remove leads and accounts (campaign must not be active)
client.campaigns.remove_lead("cmp_xyz789", "cld_1")
client.campaigns.remove_account("cmp_xyz789", "acc_1")

# Delete (must be draft)
client.campaigns.delete("cmp_xyz789")
Python SDK (beta)
# Move leads into another campaign (campaign must not be active)
client.campaigns.move_leads("cmp_xyz789", "cmp_other", ["cld_abc123"])

Sequences

Python
from foxreach import SequenceCreate, SequenceUpdate

# List steps for a campaign
steps = client.campaigns.sequences.list("cmp_xyz789")

# Add a step
step = client.campaigns.sequences.create("cmp_xyz789", SequenceCreate(
    subject="Quick question about {{company}}",
    body="Hi {{firstName}}, ...",
    delay_days=0,
))

# Update
client.campaigns.sequences.update("cmp_xyz789", "seq_1", SequenceUpdate(delay_days=3))

# Delete
client.campaigns.sequences.delete("cmp_xyz789", "seq_1")

Templates

Python
from foxreach import TemplateCreate, TemplateUpdate

page = client.templates.list()
template = client.templates.get("tpl_abc123")
template = client.templates.create(TemplateCreate(name="Cold Intro", body="Hi {{firstName}}"))
client.templates.update("tpl_abc123", TemplateUpdate(name="Updated name"))
client.templates.delete("tpl_abc123")

Email Accounts

Python
page = client.email_accounts.list()
account = client.email_accounts.get("acc_abc123")
client.email_accounts.delete("acc_abc123")

Inbox

Python
from foxreach import ThreadUpdate

# List unread threads
threads = client.inbox.list_threads(is_read=False, category="interested")

# Get a thread
thread = client.inbox.get("rpl_abc123")

# Get the full conversation (all sent and received messages, as a dict)
conversation = client.inbox.get_conversation("rpl_abc123")
for msg in conversation["messages"]:
    print(f"[{msg['direction']}] {msg['subject']}: {(msg['body'] or '')[:100]}")

# Send a reply (returns a dict)
result = client.inbox.send_reply("rpl_abc123", body="Thanks for your interest! Let's schedule a call.")
print(f"Sent: {result['message_id']}")

# Mark as read and categorize
client.inbox.update("rpl_abc123", ThreadUpdate(is_read=True, category="interested"))

# Get inbox stats (returns a dict)
stats = client.inbox.stats()
print(f"Total: {stats['total']}, Unread: {stats['unread']}, Interested: {stats['interested']}")

Analytics

Python
# Dashboard overview
overview = client.analytics.overview()
print(f"Leads: {overview.total_leads}, Reply rate: {overview.reply_rate}%")

# Campaign stats with daily breakdown
stats = client.analytics.campaign("cmp_xyz789")
print(f"Sent: {stats.sent}, Replied: {stats.replied}")
for day in stats.daily_stats:
    print(f"  {day.date}: {day.sent} sent, {day.replied} replied")

Webhooks

Python
from foxreach import WebhookCreate, WebhookUpdate

# List available event types
event_types = client.webhooks.list_events()
print(event_types)  # ["email.sent", "reply.received", ...]

# List webhooks
page = client.webhooks.list(page=1, page_size=20)
for wh in page:
    print(f"{wh.id}: {wh.url} (active={wh.is_active})")

# Create a webhook. The secret is only returned on creation, or when an active
# webhook with the same URL and events already exists (that one is returned instead).
webhook = client.webhooks.create(WebhookCreate(
    url="https://your-app.com/webhooks/outreach",
    events=["email.sent", "reply.received", "campaign.completed"],
    is_active=True,
))
print(f"Created: {webhook.id}, Secret: {webhook.secret}")  # save the secret!

# Update a webhook
webhook = client.webhooks.update("cwh_abc123", WebhookUpdate(events=["email.sent", "lead.created"]))

# Delete a webhook
client.webhooks.delete("cwh_abc123")

Account, jobs and workspaces

Python
me = client.me()  # the key, its workspace, the plan, the rate limit and the credits
print(me.plan, me.rate_limit)

# Background jobs (lead imports, verification runs, exports, bulk actions)
job = client.jobs.get("job_abc123")
print(job.status, job.progress, job.result)
jobs = client.jobs.list(type="lead_import", status="running")

# An agency key can act as one of its client workspaces
for ws in client.workspaces.list():
    print(ws)
acting = FoxReach(api_key="otr_your_api_key", workspace_id="ws_client123")

Bulk lead actions, export and labels

Python
# Bulk actions take lead_ids or a filter, and return a Job
impact = client.leads.bulk_delete_impact(lead_ids=["cld_1", "cld_2"])  # campaigns affected
job = client.leads.bulk_tag(["hot"], lead_ids=["cld_1", "cld_2"])
job = client.leads.bulk_untag(["cold"], lead_ids=["cld_1"])
job = client.leads.bulk_verify(lead_ids=["cld_1"])   # spends verification credits
job = client.leads.bulk_delete(lead_ids=["cld_3"])   # irreversible

# CSV export: start the job, then download when it has completed
job = client.leads.export(tags="enterprise")
csv_text = client.leads.download_export(job.id)

variables = client.leads.variables()  # merge tags you can use in copy

# Interest status, set by hand or cleared with None
client.leads.set_interest_status("cld_abc123", "interested")

# Lead labels
label = client.lead_labels.create("Champion", color="success", meaning="positive")
client.lead_labels.assign("cld_abc123", label.id)
client.lead_labels.unassign("cld_abc123", label.id)
labels = client.lead_labels.list()

# Block list
client.block_list.add("competitor.com", note="never email")
entries = client.block_list.list(kind="domain")

Campaign operations

Python
copy = client.campaigns.duplicate("cmp_xyz789")        # new draft "<name> (Copy)", no leads
share = client.campaigns.share("cmp_xyz789")           # public report page: share["share_url"]
client.campaigns.unshare("cmp_xyz789")

preview = client.campaigns.preview("cmp_xyz789", "Hi {{firstName}}", "Body", lead_id="cld_abc123")
client.campaigns.send_test_email(                       # sends one REAL email
    "cmp_xyz789", to_email="me@example.com", account_id="acc_1", subject="Test", body="Hello",
)
client.campaigns.bulk_remove_leads("cmp_xyz789", ["cld_1", "cld_2"])  # campaign must not be active

activity = client.campaigns.activity("cmp_xyz789", type="reply", page_size=20)
cohorts = client.campaigns.cohorts("cmp_xyz789", days=14)        # per UTC day
day = client.campaigns.cohort_detail("cmp_xyz789", "2026-11-01")  # day["emails"], cut at 200 per side
emails = client.campaigns.lead_emails("cmp_xyz789", "cld_abc123") # newest 20

A/B variants

Python
from foxreach import VariantCreate, VariantUpdate

variants = client.campaigns.sequences.list_variants("cmp_xyz789", "seq_1")
b = client.campaigns.sequences.create_variant("cmp_xyz789", "seq_1", VariantCreate(
    label="B", subject="Another angle", body="Hi {{firstName}}, ...",
))  # not allowed while the campaign is active
client.campaigns.sequences.update_variant("cmp_xyz789", "seq_1", b.id, VariantUpdate(weight=2))
for row in client.campaigns.sequences.variant_stats("cmp_xyz789", "seq_1"):
    print(row.label, row.sent, row.reply_rate)
client.campaigns.sequences.delete_variant("cmp_xyz789", "seq_1", b.id)

Inbox actions and AI drafts

Python
client.inbox.mark_read("rpl_abc123")
client.inbox.mark_all_read(category="interested")
client.inbox.bulk_update(["rpl_1", "rpl_2"], is_starred=True)  # up to 100 ids
client.inbox.add_note("rpl_abc123", "Called, wants a demo on Friday")
notes = client.inbox.list_notes("rpl_abc123")
sent = client.inbox.list_sent(campaign_id="cmp_xyz789")

# AI reply drafts
drafts = client.inbox.drafts.list(category="interested")
draft = client.inbox.drafts.get("rpl_abc123")
client.inbox.drafts.update("rpl_abc123", "Thanks! Does Thursday at 10 work?")
client.inbox.drafts.send("rpl_abc123")        # sends a real email, once
client.inbox.drafts.regenerate("rpl_abc123")
client.inbox.drafts.dismiss("rpl_abc123")

Webhook tools and the event log

Python
client.webhooks.test("cwh_abc123")                       # sends a signed webhook.test event
failed = client.webhooks.deliveries("cwh_abc123", status="failed")
client.webhooks.resume("cwh_abc123")                     # after 10 failed deliveries in a row
events = client.events.list(type="reply.received", start_date="2026-11-01")

Copy judge

Python
result = client.copy.judge(subject="Quick question", body="Hi {{firstName}}, ...")  # free
print(result["verdict"]["score"], result["verdict"]["placement"])
rewrite = client.copy.rewrite(subject="Quick question", body="...")  # 1 AI credit

More resources

ResourceMethods
workspaceget, update, members, invite, update_member_role, remove_member, invites, revoke_invite, resend_invite, defaults, update_defaults (changes need a key with the admin scope)
api_keyslist, create, revoke (admin scope)
agencyoverview, list_clients, create_client, rename_client, delete_client, get_branding, update_branding (agency keys)
audit_loglist(source=, actor=, since=, until=, campaign_id=, account_id=, cursor=)
analyticsaccount, report, export_report (CSV text), leaderboard, activity, campaign_daily, campaign_steps
lead_finderlists (create_list, get_list, rename_list, delete_list, list_items, add_items, remove_items, reveal_list, add_list_to_leads, export_list) and saved searches (create_saved_search, get_saved_search, update_saved_search, delete_saved_search, run_saved_search)
warmupcreate_tag, update_tag, delete_tag, assign_tag, unassign_tag
email_accountstest_connection, check_domain_auth
templatespublish, unpublish, clone

Pagination

List endpoints return PaginatedResponse objects:

Python
page = client.leads.list(page=1, page_size=50)

# Iterate current page
for lead in page:
    print(lead.email)

# Check pagination metadata
print(f"Page {page.meta.page}/{page.meta.total_pages}")

# Get next page
if page.has_next_page():
    next_page = page.next_page()

# Auto-paginate through ALL results
for lead in client.leads.list(page_size=100).auto_paging_iter():
    print(lead.email)

Async Support

All operations are available asynchronously via AsyncFoxReach:

Python
import asyncio
from foxreach import AsyncFoxReach, LeadCreate

async def main():
    async with AsyncFoxReach(api_key="otr_your_api_key") as client:
        # Create a lead
        lead = await client.leads.create(LeadCreate(email="jane@example.com"))

        # Auto-paginate
        async for lead in (await client.leads.list()).auto_paging_iter():
            print(lead.email)

        # Analytics
        overview = await client.analytics.overview()
        print(f"Total leads: {overview.total_leads}")

asyncio.run(main())

Error Handling

Python
from foxreach import (
    FoxReach,
    FoxReachError,
    AuthenticationError,
    NotFoundError,
    RateLimitError,
    ValidationError,
    BadRequestError,
    ServerError,
    ConnectionError,
)

try:
    lead = client.leads.get("cld_nonexistent")
except NotFoundError:
    print("Lead not found")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except ValidationError as e:
    print(f"Validation failed: {e.response_body}")
except ServerError as e:
    print(f"Server error ({e.status_code})")
except FoxReachError as e:
    print(f"API error: {e}")

Source Code

Was this page helpful?