Python
Installation
Section titled “Installation”EmBoux is a REST API — no SDK needed. Use requests or httpx:
pip install requestsimport requests
EMBOUX_URL = "https://api.emboux.com"API_KEY = "your-api-key-here"
headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json",}Create a Domain
Section titled “Create a Domain”resp = requests.post( f"{EMBOUX_URL}/domains/", json={"name": "mycompany.com"}, headers=headers,)resp.raise_for_status()domain = resp.json()print(f"Domain created: {domain['name']} (id={domain['id']})")Create a Mailbox
Section titled “Create a Mailbox”resp = requests.post( f"{EMBOUX_URL}/users/", json={ "domain_name": "mycompany.com", "email": "hello@mycompany.com", "password": "secure-password-123", }, headers=headers,)resp.raise_for_status()mailbox = resp.json()print(f"Mailbox created: {mailbox['email']}")Create an Alias
Section titled “Create an Alias”resp = requests.post( f"{EMBOUX_URL}/aliases/", json={ "domain_name": "mycompany.com", "source": "info@mycompany.com", "destination": "hello@mycompany.com", }, headers=headers,)resp.raise_for_status()Set Mailbox Quota
Section titled “Set Mailbox Quota”resp = requests.put( f"{EMBOUX_URL}/users/hello@mycompany.com/quota", json={"quota_mb": 2048}, headers=headers,)resp.raise_for_status()print(f"Quota set: {resp.json()['quota_mb']} MB")Suspend a Domain
Section titled “Suspend a Domain”resp = requests.put( f"{EMBOUX_URL}/domains/mycompany.com/suspend", headers=headers,)resp.raise_for_status()print(f"Status: {resp.json()['message']}")Full Provisioning Example
Section titled “Full Provisioning Example”A complete function to set up a new customer:
def provision_customer(domain_name: str, admin_email: str, password: str): """Create domain + admin mailbox + catch-all in one go."""
# 1. Create domain requests.post( f"{EMBOUX_URL}/domains/", json={"name": domain_name}, headers=headers, ).raise_for_status()
# 2. Create admin mailbox requests.post( f"{EMBOUX_URL}/users/", json={ "domain_name": domain_name, "email": admin_email, "password": password, }, headers=headers, ).raise_for_status()
# 3. Catch-all → admin requests.post( f"{EMBOUX_URL}/aliases/", json={ "domain_name": domain_name, "source": f"@{domain_name}", "destination": admin_email, }, headers=headers, ).raise_for_status()
print(f"Customer {domain_name} provisioned successfully!")
# Usageprovision_customer("acme.com", "admin@acme.com", "super-secure-pass")Error Handling
Section titled “Error Handling”resp = requests.post( f"{EMBOUX_URL}/domains/", json={"name": "mycompany.com"}, headers=headers,)
if resp.status_code == 400: print(f"Domain already exists: {resp.json()['detail']}")elif resp.status_code == 403: print(f"Quota exceeded: {resp.json()['detail']}")elif resp.status_code >= 500: print("Server error — retry later")else: resp.raise_for_status() print("Success!")