Skip to content

Python SDK

linnia wraps the REST API with a method for every command, long-polling, retries and webhook verification. It needs Python 3.9+ and uses only the standard library.

Terminal window
pip install linnia
from linnia import Linnia
linnia = Linnia() # reads LINNIA_API_KEY
account = linnia.list_accounts()[0]
# Reads finish in seconds: read() waits and returns the result.
people = linnia.read(account["id"], "company_employees", {"company": "northwind", "title": "sales"})
# Writes are queued and paced inside the account's working hours and limits.
job = linnia.commands.connect(account["id"], {"person": "jana-novak", "note": "Hi Jana, enjoyed your post on RevOps hiring."})
print(job["status"]) # "queued", "scheduled" or "awaiting_approval"

linnia.commands has one method per command in the API reference: search_people, company_employees, search_posts, search_jobs, list_connections, get_profile, send_message, connect and the rest. Inputs are TypedDicts generated from the OpenAPI spec, so type checkers and editors know every field.

Each method returns the job as a dict. Keyword options: wait (seconds to wait for it to finish) and idempotency_key (retries return the same job).

Failures raise LinniaError with type, message, status and often next:

from linnia import LinniaError
try:
linnia.commands.send_message(account_id, {"person": "cold-carl", "text": "Hi"})
except LinniaError as e:
if e.type == "notConnected":
print(e.next)
from linnia import verify_webhook
created = linnia.create_webhook("https://example.com/linnia", events=["message.received"])
secret = created["secret"] # shown once: store it
# In your handler, with the raw request body:
valid = verify_webhook(secret=secret, body=raw_body, signature=headers["linnia-signature"], timestamp=headers["linnia-signature-timestamp"])

Accounts (list_accounts, daily_brief, health_report, pause_account), jobs (get_job, wait_for_job, cancel_job), workflow, approvals, person_timeline, add_note and webhooks. linnia.request(method, path, ...) reaches any endpoint directly.