Skip to content

Python SDK

outflare is the Python client for the Outflare API. Every operation in api/openapi.yaml is a method, generated from the same file as the server, the CLI and the TypeScript SDK, and the engine’s tests fail if it falls behind. It needs Python 3.9 or newer, depends only on httpx, ships type hints, and is licensed Apache-2.0.

Not on PyPI The package is not published yet. Install it from the repository:

Terminal window
git clone https://github.com/outflareai/outflare
pip install ./outflare/sdk/python
from outflare import Outflare
client = Outflare() # reads OUTFLARE_TOKEN, and OUTFLARE_URL for a self-hosted server
lead = client.upsert_lead(email="[email protected]", first_name="Ana", company="Acme")
for mailbox in client.paginate(client.list_mailboxes, status="active"):
print(mailbox["email"], mailbox["daily_limit"])
with open("mailboxes.csv") as f:
client.import_mailboxes(content=f.read(), pool="Warm")

Outflare(token=..., base_url=...) takes the same settings as arguments. Without base_url it calls https://app.outflare.ai.

  • Methods are the API’s operation IDs in snake case: listLeads is list_leads, createWebhook is create_webhook. They match the CLI’s commands (outflare list-leads).
  • IDs in the path are positional: client.get_lead(lead_id). Query parameters and body fields are keyword arguments, and the required ones have no default.
  • help(client.create_webhook) shows the operation’s description, the scope it needs and its HTTP call, the same text as the API reference. Editors show it too.
  • A field that is a Python keyword gets a trailing underscore: from_=.

Calls go to the token’s own workspace, which the client looks up with GET /v1/whoami on first use. A person working in several workspaces passes one:

client = Outflare(workspace="acme") # an ID or a slug
acme = client.with_options(workspace="acme") # a copy that shares the connection

A slug can change, so store the workspace ID in long-lived configuration.

Answers are the JSON the API returns, as dicts and lists. Exports come back as text.

Any status other than 2xx raises OutflareError:

from outflare import OutflareError
try:
client.create_sequence(name="Q3 founders")
except OutflareError as e:
print(e.status, e.code, e.param, e.request_id)

code is stable and listed at GET /v1/error-codes, param names the field a 400 is about, and request_id is what to quote when asking for help. A 403 explains which scope is missing and how to get it.

The client retries network errors, 429, 502, 503 and 504 up to max_retries times (3 by default). It waits as long as Retry-After asks, up to a minute, or else backs off from half a second with jitter.

Every write carries an Idempotency-Key, the same one on each retry, so a retry after a timeout gets the first answer back instead of creating a second lead. Pass idempotency_key= to choose the key yourself, for example to make a job safe to run twice.

client.paginate(method, **params) yields every item of a list, following next_cursor from page to page. To page by hand, pass cursor= and read next_cursor from each answer.

Paged lists also take fields=["email", "status"], which answers only those fields of each item (and id).

  • extra_body={...} sends body fields this version of the SDK doesn’t know yet.
  • client.request("GET", "/v1/workspaces/{ws}/...", query={...}) calls any path. {ws} is filled in for you.

When your token’s changes wait for a person (agent actions), a write answers 202 with the held action instead of running. It runs once someone approves it on the Agents page.

import os
from outflare import verify_webhook, WebhookVerificationError
event = verify_webhook(raw_body, request.headers, os.environ["OUTFLARE_WEBHOOK_SECRET"])
if event["type"] == "lead.replied":
...

Pass the raw body, before any JSON parsing. verify_webhook raises WebhookVerificationError when no signature matches or the delivery is more than five minutes old. See Webhooks for the events, and outflare listen --forward-to http://localhost:8000/webhooks to test a receiver on your machine.