Client Installation
The vaultsandbox SDK provides a developer-friendly interface for integrating email testing into your Python applications and test suites.
Requirements
Section titled “Requirements”- Python: 3.10 or higher (tested on 3.10, 3.11, 3.12)
- VaultSandbox Gateway: Running instance with API access
Installation
Section titled “Installation”pip install vaultsandboxpoetry
Section titled “poetry”poetry add vaultsandboxuv add vaultsandboxQuick Start
Section titled “Quick Start”Basic Usage
Section titled “Basic Usage”import asynciofrom vaultsandbox import VaultSandboxClient
async def main(): async with VaultSandboxClient( base_url="https://mail.example.com", api_key="your-api-key", ) as client: inbox = await client.create_inbox() print(f"Send email to: {inbox.email_address}")
email = await inbox.wait_for_email() print(f"Received: {email.subject}")
await inbox.delete()
asyncio.run(main())Verifying Installation
Section titled “Verifying Installation”Create a test file test_vaultsandbox.py:
import asyncioimport osfrom vaultsandbox import VaultSandboxClient
async def test(): async with VaultSandboxClient( base_url=os.environ["VAULTSANDBOX_URL"], api_key=os.environ["VAULTSANDBOX_API_KEY"], ) as client: try: server_info = await client.get_server_info() print("Connected to VaultSandbox") print(f"Allowed domains: {server_info.allowed_domains}")
inbox = await client.create_inbox() print(f"Created inbox: {inbox.email_address}")
await inbox.delete() print("Cleanup successful")
print("\nInstallation verified!") except Exception as e: print(f"Error: {e}") raise SystemExit(1)
asyncio.run(test())Run it:
export VAULTSANDBOX_URL=https://mail.example.comexport VAULTSANDBOX_API_KEY=your-api-keypython test_vaultsandbox.pyType Hints Support
Section titled “Type Hints Support”The SDK includes full type annotations and ships with a py.typed marker, providing IDE support out of the box.
IDE Integration
Section titled “IDE Integration”Most modern IDEs (VS Code with Pylance, PyCharm, etc.) will automatically pick up the type hints:
from vaultsandbox import VaultSandboxClient, Email, Inbox
async def example(): async with VaultSandboxClient( base_url="https://mail.example.com", api_key="your-api-key", ) as client: inbox: Inbox = await client.create_inbox() email: Email = await inbox.wait_for_email()
print(email.subject) # IDE knows this is a stringType Checking with mypy
Section titled “Type Checking with mypy”For static type checking, add vaultsandbox to your mypy.ini or pyproject.toml:
[tool.mypy]plugins = []strict = trueVirtual Environment Best Practices
Section titled “Virtual Environment Best Practices”Always use a virtual environment for your projects:
Using venv
Section titled “Using venv”python -m venv .venvsource .venv/bin/activate # Linux/macOS# or.venv\Scripts\activate # Windows
pip install vaultsandboxUsing poetry
Section titled “Using poetry”poetry new my-projectcd my-projectpoetry add vaultsandboxpoetry shellUsing uv
Section titled “Using uv”uv init my-projectcd my-projectuv add vaultsandboxDependencies
Section titled “Dependencies”The SDK installs these dependencies automatically:
httpx- Async HTTP clienthttpx-sse- Server-Sent Events supportpqcrypto- Post-quantum cryptography (ML-KEM-768, ML-DSA-65)cryptography- AES-256-GCM and HKDF
Next Steps
Section titled “Next Steps”- Configuration - Configure the client for your environment
- Core Concepts - Understand inboxes, emails, and authentication
- Guides - Learn common usage patterns
- Testing Patterns - Integrate with your test suite