Skip to main content
Tenants represent your customers in Ark’s white-label architecture. Each tenant gets isolated domains, credentials, webhooks, suppressions, and usage tracking.

Architecture Overview

Understand the Platform → Tenant → Domain → Email hierarchy before diving into management operations

Create a Tenant

from ark import Ark

client = Ark()

tenant = client.tenants.create(
    name="Acme Corp",
    metadata={"plan": "enterprise", "customer_id": "cust_123"}
)

print(f"Tenant ID: {tenant.data.id}")
print(f"Name: {tenant.data.name}")
Use metadata for correlation. Store your internal customer ID, plan level, or other identifiers in the metadata field. This makes it easy to map Ark tenants back to your own database.

List Tenants

tenants = client.tenants.list()

for tenant in tenants.data:
    print(f"{tenant.id}: {tenant.name}")

Update a Tenant

tenant = client.tenants.update(
    "tenant_abc123",
    name="Acme Corp (Renamed)",
    metadata={"plan": "scale", "customer_id": "cust_123"}
)

Delete a Tenant

Deleting a tenant removes all associated domains, credentials, webhooks, and suppressions. This action cannot be undone.
client.tenants.delete("tenant_abc123")

Per-Tenant Credentials

Each tenant can have its own API keys and SMTP credentials. This lets your customers authenticate directly, or lets you scope access per-tenant in your backend.

Create Credentials

credential = client.tenants.credentials.create(
    "tenant_abc123",
    name="Production API Key"
)

print(f"API Key: {credential.data.key}")
print(f"SMTP Username: {credential.data.smtp_username}")
The credential key is only returned once at creation time. Store it securely — you cannot retrieve it again.

Per-Tenant Webhooks

Configure webhook endpoints scoped to a specific tenant. Only events for that tenant will be delivered.
webhook = client.tenants.webhooks.create(
    "tenant_abc123",
    name="Acme Webhook",
    url="https://acme.com/webhooks/email",
    events=["MessageSent", "MessageBounced", "MessageDeliveryFailed"]
)

Per-Tenant Suppressions

Suppressions are tenant-scoped. A bounce on Tenant A’s domain doesn’t affect Tenant B’s sending.
# List suppressions for a tenant
suppressions = client.tenants.suppressions.list("tenant_abc123")

for suppression in suppressions.data:
    print(f"{suppression.email}: {suppression.reason}")

# Manually suppress an address
client.tenants.suppressions.create(
    "tenant_abc123",
    email="bounced@example.com"
)

# Remove a suppression
client.tenants.suppressions.delete("tenant_abc123", "bounced@example.com")

Per-Tenant Usage

Track sending volume, bounces, and engagement per tenant:
usage = client.tenants.usage.retrieve("tenant_abc123")

print(f"Emails sent: {usage.data.emails_sent}")
print(f"Bounces: {usage.data.bounces}")

# Timeseries data
timeseries = client.tenants.usage.timeseries("tenant_abc123")
for point in timeseries.data:
    print(f"{point.date}: {point.emails_sent} sent")

Common Patterns

Provisioning on Customer Signup

When a new customer signs up for your platform, create a tenant and add their domain:
from ark import Ark

client = Ark()

def onboard_customer(customer_name, customer_domain, customer_id):
    # 1. Create tenant
    tenant = client.tenants.create(
        name=customer_name,
        metadata={"customer_id": customer_id}
    )

    # 2. Add their domain
    domain = client.tenants.domains.create(
        tenant.data.id,
        name=customer_domain
    )

    # 3. Create credentials for them
    credential = client.tenants.credentials.create(
        tenant.data.id,
        name=f"{customer_name} API Key"
    )

    return {
        "tenant_id": tenant.data.id,
        "domain_id": domain.data.id,
        "dns_records": domain.data.dns_records,
        "api_key": credential.data.key
    }

Domain Onboarding

Build complete domain setup flows for your customers, including DNS verification and error handling

Multi-Tenant Usage Export

Export usage across all tenants for billing reconciliation:
# Export all tenant usage as CSV
curl "https://api.arkhq.io/v1/usage/export?format=csv" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -o usage-export.csv

# Compare tenant usage
curl https://api.arkhq.io/v1/usage/tenants \
  -H "Authorization: Bearer $ARK_API_KEY"

Next Steps