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:
git clone https://github.com/outflareai/outflarepip install ./outflare/sdk/pythonfrom outflare import Outflare
client = Outflare() # reads OUTFLARE_TOKEN, and OUTFLARE_URL for a self-hosted server
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.
How methods are named
Section titled “How methods are named”- Methods are the API’s operation IDs in snake case:
listLeadsislist_leads,createWebhookiscreate_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_=.
Workspace
Section titled “Workspace”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 slugacme = client.with_options(workspace="acme") # a copy that shares the connectionA slug can change, so store the workspace ID in long-lived configuration.
Answers and errors
Section titled “Answers and errors”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.
Retries and idempotency
Section titled “Retries and idempotency”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.
Paging
Section titled “Paging”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).
Newer endpoints and fields
Section titled “Newer endpoints and fields”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.
Held changes
Section titled “Held changes”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.
Webhooks
Section titled “Webhooks”import osfrom 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.