Skip to main content

LoftBox Python SDK - Email infrastructure for AI agents

Project description

LoftBox Python SDK

AI 에이전트를 위한 이메일 인프라 SDK.

설치

pip install loftbox

요구사항: Python 3.9+.

빠른 시작

from loftbox import LoftBox

with LoftBox(api_key="lb_live_xxx") as client:
    # 에이전트 + 메일박스
    agent = client.agents.create(name="Support Bot", slug="support-bot")
    mailbox = client.mailboxes.create(agent.id, local_part="support")

    # 발송 (멱등 키로 중복 방지)
    msg = client.messages.send(
        mailbox_id=mailbox.id,
        to=["recipient@example.com"],
        subject="Hello",
        body_text="World",
        idempotency_key="welcome-42",
    )

    # 수신 폴링 → ack
    inbox = client.mailboxes.list_inbox(mailbox.id)
    client.mailboxes.ack_inbox(mailbox.id, [m.id for m in inbox.data])

기능

  • 발송: messages.send(...) — 텍스트/HTML/Markdown 본문, 첨부, cc, 답장 헤더
  • 예약 발송: send(..., send_at="2030-01-01T09:00:00Z") (미래 RFC3339)
  • 멱등 발송: send(..., idempotency_key="...") — 중복 발송 방지
  • 수신: mailboxes.list_inbox(...) 폴링 + ack_inbox(...). message.extracted_text 로 인용 제거된 답장 본문
  • 라벨: messages.add_labels(...), remove_label(...), list(label=...)
  • 전문검색: messages.list(q="..."), threads.list(q="...")
  • 스레드: threads.list(...), list_messages(...)
  • 승인 워크플로: messages.approve(id, reason=...), reject(...)
  • 웹훅: webhooks.create(agent_id, url, event_types)
  • 도메인 / suppression: domains.*, suppressions.*

오류 처리

모든 호출은 실패 시 LoftBoxError 하위 예외를 던집니다:

from loftbox import RateLimitError, NotFoundError, ValidationError

try:
    client.messages.send(...)
except RateLimitError as e:
    print(f"{e.retry_after_secs}s 후 재시도")
except (NotFoundError, ValidationError) as e:
    print(e.status_code, e.message)

페이지네이션

목록 메서드는 Page 를 반환합니다 (.data, .next_cursor):

page = client.messages.list(mailbox_id=mailbox.id, limit=50)
while True:
    for m in page.data:
        ...
    if not page.next_cursor:
        break
    page = client.messages.list(mailbox_id=mailbox.id, limit=50, cursor=page.next_cursor)

예제

examples/quickstart.py 참고.

라이선스

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

loftbox-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

loftbox-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file loftbox-0.1.0.tar.gz.

File metadata

  • Download URL: loftbox-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for loftbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2c5d7d5c1941a7b4abdc91f0937ebbaebf3b56fa9b0743e17674362ec2c144e
MD5 29b20938de2df8cc6f5b9d5f765920d9
BLAKE2b-256 86d6da7b2d74373da0dea776908d3e1884dc1f0167e870b2d2c2e25e6c639194

See more details on using hashes here.

File details

Details for the file loftbox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: loftbox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for loftbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53fa2676295ebff8dc71768a8b0a915a367ee80b1e48ca71ac46e9d9f8b8e0de
MD5 57ce61ed181ead6ac756870bd171547d
BLAKE2b-256 e78ae05337586827f30b6f19c8ac40b83cef9cd491f6972cec9898584c0fe0e7

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