Agencies often reach a ceiling with bespoke client builds: you solve the same workflow problem ten times over, yet every new client requires another standalone server, another codebase fork, and another maintenance headache. Turning that repeatable solution into a white-label SaaS platform lets you run one shared codebase while every client experiences it as their own branded software under their own domain.
The catch is that naive "white-labeling" breaks down fast. Swapping a logo in CSS is easy; isolating transactional emails, custom domains with automatic SSL, OAuth callbacks, and reseller billing hierarchies takes deliberate engineering from the first migration.
1. Model the Two-Level vs. Three-Level Hierarchy Early
Before writing domain routing code, decide whether you are selling directly to end clients (two-tier: Platform -> Tenant) or enabling partner agencies to resell to their own customers (three-tier: Platform -> Partner Agency -> End Workspace).
Reseller Schema Structure
CREATE TABLE partners (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
slug VARCHAR(64) UNIQUE NOT NULL,
brand_name VARCHAR(120) NOT NULL,
custom_domain VARCHAR(255) UNIQUE,
theme_config JSONB NOT NULL DEFAULT '{}'::jsonb,
stripe_account_id VARCHAR(128),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE workspaces (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
partner_id BIGINT NOT NULL REFERENCES partners(id),
name VARCHAR(120) NOT NULL,
plan_code VARCHAR(64) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
Separating partners (who own the brand, domain, and commercial relationship) from workspaces (who own operational data) avoids painful schema rewrites when a partner asks to manage 25 sub-clients under one login. For deeper isolation patterns at the database tier, see our multi-tenant SaaS architecture guide.
2. Automate Custom Domains and On-Demand SSL
Nothing kills white-label credibility faster than telling a client to email support so an engineer can manually edit Nginx configs and run Certbot. Provisioning custom domains (portal.clientbrand.com) should be self-service.
Custom Domain Routing Options Compared
| Approach | Setup Effort | Certificate Lifecycle | Best Use Case |
|---|---|---|---|
| Caddy On-Demand TLS | Low (single Caddyfile + internal ask endpoint) |
Automatic Let's Encrypt issuance & renewal | Self-hosted VPS / container stacks (up to thousands of domains) |
| Cloudflare for SaaS | Medium (API integration + fallback origin) | Managed edge SSL + DDoS protection | Global edge caching and strict enterprise uptime SLAs |
| AWS ACM + ALB | High (listener cert limits, manual validation) | Managed via Route53/CNAME | Low domain count with strict AWS-only compliance |
Guarding the ask Endpoint
With Caddy, never enable unrestricted on-demand TLS without an authorization callback, or bots can point random domains at your IP and exhaust your ACME rate limits:
{
on_demand_tls {
ask https://app.yourplatform.com/internal/domains/verify
}
}
:443 {
tls {
on_demand
}
reverse_proxy app:8080
}
Your /internal/domains/verify?domain=portal.clientbrand.com endpoint simply checks whether domain exists and is verified = true in your domains table, returning 200 OK or 404.
3. Inject Dynamic Branding Without Flash of Unstyled Content
A common frontend bug in white-label apps is loading the default platform colors first, fetching /api/brand on mount, and flashing the wrong logo for 300 milliseconds.
Server-Resolved CSS Custom Properties
Resolve the tenant from the Host header on the initial document request and inject CSS variables directly into the HTML shell (or SSR layout) with short-lived edge/Redis caching:
:root {
--brand-primary: #1d4ed8;
--brand-primary-contrast: #ffffff;
--brand-surface: #f8fafc;
--brand-radius: 0.5rem;
}
Store only constrained design tokens (primary_hex, accent_hex, logo_url, favicon_url, support_email) in theme_config. Avoid letting clients upload raw custom CSS or arbitrary <script> tags—that opens stored XSS vulnerabilities across tenant portals.
4. Eliminate Brand Leaks in Emails, PDFs, and OAuth
White-labeling usually breaks in the places engineers forget to test:
- Transactional Emails & DKIM: Password resets and invoices sent from
noreply@yourplatform.comexpose your underlying brand. Give partners a self-serve DNS verification step (CNAME/TXT records via Postmark, Resend, or AWS SES) so emails ship fromnotifications@clientbrand.com, with a safe fallback likenotifications@portal-mail.comon a neutral domain until verified. - PDF Invoices & Exports: Pass the resolved
partnerbrand object into every background PDF job—never read globalAPP_NAMEenvironment variables inside queue workers. - Error Pages & Magic Links: Generate password-reset and magic-link URLs using the resolved custom domain (
https://portal.clientbrand.com/reset?...), not a hardcodedAPP_URLconstant. - OAuth Redirect URIs: If you offer "Sign in with Google," wildcard redirect URIs are not allowed by most OAuth providers. Route OAuth callbacks through a neutral central auth domain (
auth.yourwhiteapp.net/callback) that validates a signedstatetoken and redirects back to the client's custom domain cleanly.
5. Handle Billing: Direct Reseller vs. Platform Pass-Through
Agencies typically monetize white-label platforms in one of two ways:
- Wholesale Seat / Flat License: You bill the agency via Stripe Billing based on active client workspaces or seats; the agency bills its clients independently on its own terms.
- Stripe Connect Marketplace: End clients pay directly inside the white-label checkout, and funds route to the partner agency's connected Stripe account minus your platform fee.
For most agencies launching their first white-label product, wholesale billing to the partner keeps tax, refunds, disputes, and chargebacks off your plate while letting partners bundle your software into their existing retainers. For an example of cleanly decoupling subscription checkout from product access, see how we implemented web-based subscription workflows for a SaaS platform.
6. Operationalize Client Onboarding in Under 15 Minutes
To make a white-label SaaS profitable, onboarding a new agency or client must be an automated checklist rather than a developer sprint:
- Create partner record + default admin user via onboarding form or API.
- Provision DNS verification target (
cname.yourwhiteapp.net) and poll DNS propagation asynchronously. - Seed default templates, roles, and sample data inside a transactional database job.
- Trigger email domain verification and welcome sequence once SSL status flips to
active.
Having engineered multi-tenant onboarding flows and managed 300+ WordPress sites at server level for a Finnish partner, automating DNS checks, SSL status polling, and tenant seeding is what turns custom software into a scalable agency asset.
Ship Your White-Label SaaS Platform Cleanly
If your agency is ready to stop rebuilding the same client tools and launch a white-label SaaS platform with automated custom domains, isolated branding, and clean billing, SmitDev can architect and build it with you. Through custom web application development and Launch consulting, we work at $55/day (8–9 hours) or $1,999/month dedicated delivery across 170+ shipped case studies.
Ready to map out your white-label domain and tenant architecture? Tell us what you are building.