Skip to main content

Python SDK for the Lassare Gateway

Project description

Lassare Python SDK

A Python client library for the Lassare Gateway.

The SDK is designed to BLOCK agent execution until a human decision is made. This is the core purpose of Lassare - forcing agents to stop and wait for approval.

Installation

pip install lassare

Quick Start

from lassare import LassareClient, PauseRequest, RequestStatus

# Initialize client with API key
client = LassareClient(api_key="lsk_prod_xxx...")

# Use as context manager for automatic connect/disconnect
with client:
    # This call BLOCKS until a human approves, rejects, or the request expires
    decision = client.pause_for_human(
        PauseRequest(
            project_id="proj_abc123",
            policy_id="pol_xyz789",
            payload={"amount": 50000, "destination": "new_account"},
            title="Approve large transaction",
            description="User requested withdrawal of $50,000 to new account",
        )
    )

    # Code only reaches here AFTER human decision
    if decision.status == RequestStatus.APPROVED:
        print(f"Approved by {decision.decided_by}")
        execute_transaction()
    elif decision.status == RequestStatus.REJECTED:
        print(f"Rejected: {decision.comment}")
        cancel_transaction()
    else:  # EXPIRED
        print("Request expired without decision")
        handle_timeout()

Blocking Behavior

The pause_for_human() method blocks via WebSocket until a decision is made. This ensures your agent cannot proceed without human approval.

With Timeout

from lassare import DecisionTimeoutError

try:
    # Block for max 5 minutes (300 seconds)
    decision = client.pause_for_human(request, timeout=300)
except DecisionTimeoutError as e:
    print(f"No decision after {e.timeout_seconds}s")

Non-Blocking

For cases where you need to create a request and return immediately:

# Creates request and returns immediately (does not wait for decision)
response = client.create_approval_request(
    PauseRequest(
        project_id="proj_abc123",
        policy_id="pol_xyz789",
        payload={"amount": 50000},
        title="Approve transaction",
    )
)
print(f"Created request: {response.request_id}")
# Check status later with get_request_status() or use callbacks

Policy-Based Routing

Use policy_id to route approval requests through policies configured in the Lassare Portal:

decision = client.pause_for_human(
    PauseRequest(
        project_id="proj_abc123",
        policy_id="pol_default",  # Configured in Portal
        payload={"amount": 50000, "customer_id": "cust_123"},
        title="High-value transaction",
    )
)

Policies define:

  • Which approvers receive notifications
  • Notification channels (email, Slack, Microsoft Teams, webhooks)
  • Urgency levels and escalation rules

API Reference

LassareClient

Constructor

LassareClient(
    api_key="lsk_prod_xxx...",
    ws_url="wss://ws.lassare.com",  # optional, defaults to production
)

Methods

  • pause_for_human(request, timeout=3600) - BLOCKS until decision
  • create_approval_request(request) - Creates request, returns immediately
  • get_request_status(request_id) - Get current status of a request
  • cancel_request(request_id) - Cancel a pending request
  • connect() / disconnect() - Manual connection management (or use with statement)

Types

  • PauseRequest - Request with project_id, policy_id, payload, title, etc.
  • DecisionResponse - Response with status, decided_by, comment, request_id
  • RequestStatus - Enum: PENDING, APPROVED, REJECTED, EXPIRED
  • Urgency - Enum: CRITICAL, STANDARD, EXTENDED

Documentation

For full documentation, visit https://docs.lassare.com/sdks/python

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lassare-0.3.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lassare-0.3.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file lassare-0.3.0.tar.gz.

File metadata

  • Download URL: lassare-0.3.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for lassare-0.3.0.tar.gz
Algorithm Hash digest
SHA256 182a2296ad8e2634167f7522e89d463ef367fe1f7443e9a70d662a5075dd7b91
MD5 d290c0cb1342244859263fb997553b3f
BLAKE2b-256 5cc58341903835af844da51c6b15aba53598cfb572a788f3f8542f805b5a502b

See more details on using hashes here.

File details

Details for the file lassare-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: lassare-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for lassare-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccd189fd2cdecb1a6b3bdbd2ec9eb392eeed26f5cf886b65117857f5f9370564
MD5 8615eca28777beb6837de5bd8f7ec6ff
BLAKE2b-256 a5610d2244a21edac08fe4645a40e4397178b397b1aad7f8684e00beaf40463d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page