Skip to main content

Official Python SDK for hedwig.bot

Project description

hedwigbot

Official Python SDK for hedwig.bot — real inboxes for AI agents.

Installation

pip install hedwigbot

Quick Start

from hedwigbot import Hedwig

client = Hedwig(api_key="your-api-key")

# Create an inbox
inbox = client.inboxes.create(
    email_address="support-agent",
    display_name="Support Agent"
)

print(f"Created inbox: {inbox['email_address']}")

# List messages
response = client.inboxes.messages(inbox["id"])
messages = response["messages"]

# Send a message
client.inboxes.send(
    inbox["id"],
    to="customer@example.com",
    subject="Re: Your question",
    body_text="Thanks for reaching out!"
)

Configuration

from hedwigbot import Hedwig

client = Hedwig(
    api_key="your-api-key",
    base_url="https://api.hedwig.bot"  # optional, defaults to production
)

API Reference

Inboxes

# List all inboxes
response = client.inboxes.list(limit=50, page_token="optional-cursor")
inboxes = response["inboxes"]
next_page = response.get("next_page_token")

# Create an inbox
inbox = client.inboxes.create(
    email_address="agent-123",      # optional, auto-generated if omitted
    display_name="Agent Name",       # optional
    metadata={"team": "support"}     # optional
)

# Get an inbox
inbox = client.inboxes.get("inbox_id")

# Delete an inbox
client.inboxes.delete("inbox_id")

# List messages in an inbox
response = client.inboxes.messages("inbox_id", limit=25)
messages = response["messages"]

# Get a specific message
message = client.inboxes.get_message("inbox_id", "message_id")

# Send a message
sent = client.inboxes.send(
    "inbox_id",
    to="recipient@example.com",
    subject="Hello",
    body_text="Plain text body",
    body_html="<p>HTML body</p>",  # optional
    from_name="Custom Name",        # optional
    reply_to="other@example.com"   # optional
)

# List threads
response = client.inboxes.threads("inbox_id", limit=20)
threads = response["threads"]

Webhooks

# List all webhooks
response = client.webhooks.list()
webhooks = response["webhooks"]

# Create a webhook
webhook = client.webhooks.create(
    url="https://yourapp.com/webhook",
    event_types=["message.received", "message.sent"]
)

# Get a webhook
webhook = client.webhooks.get("webhook_id")

# Delete a webhook
client.webhooks.delete("webhook_id")

API Keys

# List all API keys
response = client.api_keys.list()
keys = response["api_keys"]

# Create an API key
result = client.api_keys.create(
    name="Production Key",
    inbox_id="inbox_123"  # optional, for inbox-scoped keys
)

# Save the key immediately - it won't be shown again!
print(f"New API Key: {result['key']}")

# Revoke an API key
client.api_keys.revoke("key_id")

Error Handling

from hedwigbot import Hedwig, HedwigApiError

try:
    inbox = client.inboxes.create()
except HedwigApiError as error:
    print(f"API Error ({error.status}): {error}")
    print(f"Details: {error.details}")

Pagination

All list endpoints support cursor-based pagination:

page_token = None

while True:
    response = client.inboxes.list(limit=50, page_token=page_token)
    
    # Process inboxes
    for inbox in response["inboxes"]:
        print(inbox["email_address"])
    
    # Check for more pages
    page_token = response.get("next_page_token")
    if not page_token:
        break

Type Hints

The SDK includes complete type hints:

from hedwigbot import Hedwig
from hedwigbot.types import Inbox, Message, Webhook

client = Hedwig(api_key="your-key")

inbox: Inbox = client.inboxes.get("inbox_id")

Requirements

  • Python 3.8+
  • requests>=2.31.0

License

MIT

Support

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

hedwigbot-1.0.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

hedwigbot-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file hedwigbot-1.0.0.tar.gz.

File metadata

  • Download URL: hedwigbot-1.0.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for hedwigbot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0f105bfddeed22bcbcb3b3c2d82c78fece3e093d5a25c1d6d45260890f147c8d
MD5 1c018913932ff1ffd41bdf0d88c7a87d
BLAKE2b-256 2bde82100c53929bf2e4fc12b0e77d989e34c0292a722eab5661dee797f2dd4c

See more details on using hashes here.

File details

Details for the file hedwigbot-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hedwigbot-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for hedwigbot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0327e7042d2c0c01008e9dd22350976d9c5cf38143c3674dd7ea9b758dff12e0
MD5 d60844022917d7a1882160e7adcca2c2
BLAKE2b-256 11fb5327dfd4ddac3077f01243b4f583f64938d2e1310ccf1f9ccbe2b4797305

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