Sub-accounts
If your software sends email for many customers, each customer gets a sub-account with its own domain, templates, logs and reputation. Billing goes through your main account.
Sub-accounts are available from the Business plan (up to 10) and in the Scale plan (unlimited). Without a matching plan the endpoints answer 403 plan_limit.
How it fits together
- A sub-account is an account of its own below your main account (
sub_account: trueinGET /v1/account). It has its own domains, keys, webhooks, templates, logs, suppression list and statistics. Its reputation (bounce and complaint rate) is judged separately, so a problem with one customer does not pause the others. - The main account creates sub-accounts, sees their usage, provides templates and pays. A sub-account is billed and deleted through the main account (
403 billed_by_main_account), it cannot have sub-accounts of its own and takes its languages and SSO from the main account. - Management needs an admin key of the main account. See Authentication.
Create a sub-account
curl https://api.sendtide.ch/v1/tenants \
-H "Authorization: Bearer $SENDTIDE_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{ "slug": "moser-bakery", "name": "Moser Bakery" }'
The slug identifies the sub-account in all further calls. GET /v1/tenants lists all of them with sent_30d (emails sent in 30 days) and the number of adapted templates.
How you send for a customer
There are two ways:
1. With a key of the sub-account. Create a key for it (scope full, send or read, never admin). Everything this key does happens inside the sub-account, including adding its domain:
curl https://api.sendtide.ch/v1/tenants/moser-bakery/keys \
-H "Authorization: Bearer $SENDTIDE_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Production", "env": "live", "scope": "send" }'
2. With the main key and tenant. You send with your own key and name the sub-account in the body ("tenant": "moser-bakery"). Read calls take ?tenant= (search emails, get an email, statistics, cancel and reschedule, erase a recipient):
curl "https://api.sendtide.ch/v1/stats?days=30&tenant=moser-bakery" \
-H "Authorization: Bearer $SENDTIDE_API_KEY"
Sendtide checks the sender against the domains of the sub-account. The customer brings their own domain, so their email comes from their own address. An unknown slug answers 422 tenant_not_found.
Inherited templates
You maintain templates once in the main account. Sub-accounts use them through the same alias. The main account controls adaptation:
sub_allow: trueon the template lets sub-accounts adapt it. Otherwise403 template_locked.- You mark single blocks with
locked: true(for example the footer with legal details). Adaptations by the sub-account do not change locked blocks.
As the main account you set the adaptation for a sub-account like this:
curl -X PUT https://api.sendtide.ch/v1/tenants/moser-bakery/templates/welcome \
-H "Authorization: Bearer $SENDTIDE_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{ "langs": { "en": { "subject": "Welcome to Moser Bakery" } } }'
DELETE on the same path restores the template of the main account. More about templates in Templates.
Usage and limits
The usage of sub-accounts counts against the quota of the main account. You see it per sub-account in sent_30d and in statistics with tenant.
Delete a sub-account
DELETE /v1/tenants/{slug} (admin key) removes the sub-account with all its data. This cannot be undone.