Skip to content

Python

EmBoux is a REST API — no SDK needed. Use requests or httpx:

Terminal window
pip install requests
import requests
EMBOUX_URL = "https://api.emboux.com"
API_KEY = "your-api-key-here"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
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']})")
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']}")
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()
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")
resp = requests.put(
f"{EMBOUX_URL}/domains/mycompany.com/suspend",
headers=headers,
)
resp.raise_for_status()
print(f"Status: {resp.json()['message']}")

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!")
# Usage
provision_customer("acme.com", "admin@acme.com", "super-secure-pass")
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!")