Español →
← How To Guides
ClientManager · Reference

The Tenant Record

What a tenant actually is in the database, and everything created the moment one is provisioned. The companion to Site Admin Navigation, which covers the screens, and Site Settings Field Reference, which covers the settings.

What a tenant is

1

A SiteID, and every row that carries it

There is no "Tenant" table. A tenant is a row in SiteInfo, and everything belonging to it carries that SiteID — 318 tables have a SiteID column. That is why a tenant cannot be deleted casually: removing one means deleting from all of them in foreign-key order.

SiteNameThe company name as typed at signup. Also used as the Organization's name below.
SiteGUIDThe subscription id, not a random GUID. It is what makes provisioning idempotent — a repeat call with the same subscription returns the existing site rather than creating a second one.
PrimaryContactEmailThe admin's email.
CountryID / DefaultCountryIDResolved by name from Ref_Country. Drives the tenant's phone-format mask and date format. An unrecognised or absent country simply leaves it unset.
Address … PhoneStraight from what the customer typed at signup, because SiteInfo is what invoices, quotes and document headers are built from.
IsActiveHow a tenant is taken out of use without deleting 318 tables' worth of rows.
2

The tenant's own business is an Organization

A tenant has a company record of its own, alongside its clients and vendors: an Organization with IsOwnCompany = 1. Before migration 152 that was only knowable by the convention that its CompanyName matched the SiteName — true until somebody renamed either, at which point the compliance monitor would quietly stop watching the tenant's own insurance.

This is the company you land on from Site Settings → Site Info, and the one whose Contacts tab holds the tenant's own staff.

What provisioning creates

3

Nine things, in one transaction

All of it is TenantProvisioningService.ProvisionAsync, inside a single transaction — if the admin user cannot be created, the whole tenant is rolled back rather than left half-built.

#CreatedNotes
1SiteInfoThe tenant itself.
2RolesAdministrators and Users. Roles are SiteID-scoped with no shared-core merge, so a new tenant has zero roles until these are made.
3ChecklistsCopied from Site 1's role checklist templates, or My Tasks would be empty until someone recreated every template by hand.
4Document templatesCopied from the master set — a copy, not a shared read, so the tenant owns its own proposal wording and is free to edit it.
5OrganizationThe tenant's own business, IsOwnCompany = 1.
6ContactThe first admin, as a person — name from what was supplied, or the email's local part as a correctable placeholder.
7CompanyContactLinks that admin to the Organization. They work at the tenant's own business, so they appear where any colleague would.
8ProjectInfo"Internal - {Company}", the IRBS pattern: the catch-all bucket for non-client-billable time and expense. Primary Contact is the admin. Tracks time and expense; excluded from accounting integration.
9ProjectResource + UsersThe admin joins that project as Staff (not Client), then becomes a login holding both roles.
Order matters in two places. The admin Contact is created before the Internal Project, because the project's Primary Contact is that person. And the Staff resource row is created up front, because the only thing that ever populated Resources otherwise filed the Primary Contact as "Primary Client" — which on an internal project would file the tenant as its own client.

A bug worth knowing about

4

Tenants used to get a company as a person

Until 2026-10-05, provisioning also created a Contact whose first and display name were the company name, linked it to the Organization, and used it as the Internal Project's Primary Contact. Every tenant therefore had a company sitting in its People list.

It was spotted on a company's Contacts tab with the obvious question — why would a company become a person record? An ad-hoc script had done the same thing retroactively for ten older tenants.

Fixed, and cleaned up. Provisioning now uses the admin. Migrations 172 and 173 removed 45 such records across five databases, re-pointing each affected project to a real person — and moving one client-portal login that depended on one of them, rather than deleting it. verify-company-shaped-contacts.sql checks every database and should report nothing. The script that made them has been fixed too — deploy/Backfill-MissingInternalProjects.sql still existed, still described itself as safe to re-run, and would have recreated them (plus a duplicate Organization) on any tenant lacking an Internal Project. It now uses the tenant's own flagged company and its first admin, and skips any site missing either rather than inventing rows.
5

A new tenant had no Main Contact

Until 2026-10-05 the admin was linked to the tenant's own Organization but was not marked as its Main Contact, so a freshly provisioned tenant showed "No Main Contact designated for this Company" on its own Contacts tab, and mailouts and other "who do we contact here" features could not reach it. IsMainContact defaults to 0 and provisioning never set it, so this was universal — it was found on one tenant and turned out to affect all of them.

Fixed. Provisioning now sets IsMainContact = 1 on the admin's link. Migration 174 backfilled the tenants that already existed — the site's first admin, only where that person was already linked, and never over an existing Main Contact, since moving it would change who a tenant's mailouts reach.
6

“Which company is us” is recorded twice, and only one of them is read

Organization.IsOwnCompany is the live marker: provisioning sets it, the compliance monitor reads it, and migrations 174 and 177 resolve a tenant's own company through it. SiteInfo.SiteOrganizationID is a second, older pointer, editable as Site Organization on Site Information — but nothing reads it. The only code touching that column is the Site Info form and its repository; no query, view or service consults it, and provisioning never fills it, so it is NULL for every tenant ever provisioned. Do not treat it as the answer to "which company is us", and do not backfill it while it has no reader.

The flag itself was backfilled by migration 152, which matched Organization.CompanyName to SiteInfo.SiteName — and said in its own comment that this would break the moment somebody renamed either one. That is exactly what happened: the IONOS copies of CMDevDB, cmIntgDB and cmTestDB are a re-branded copy of the original seed, with the site renamed ClientManager Demo Site and the company renamed ClientManager LLC, so the names stopped matching and site 1 was left with 17 companies and no own company at all. Migration 177 restored it.

SiteID 1 is not the same tenant in every database. It always means "the shared core" for Ref_ lookups, but as a tenant it is REYESCO LLC on cmProdDB and cmDemoDB and ClientManager Demo Site on the dev, integration and test databases. Anything that resolves "my company" by assuming site 1 is REYESCO will be right in production and wrong in testing.
Copied databases bypass every fix. Provisioning is the guarded path; an environment created by restoring and renaming a database does not run it, so each one can diverge again. That is how this gap arrived. Run db/migrations/verify-tenant-invariants-all-databases.sql after any restore, copy, environment build or tenant import: it is read-only and asserts all thirteen invariants across every database in one command — one own company per site and only one, a Main Contact on it, no company-shaped contacts, an Internal Project on the own company, no row owned by no tenant, and no project, company-contact link or portal account crossing tenants. The last three are data leaks between customers, not cosmetic gaps.

How a tenant gets created

7

Two routes, one service

Site AdminAll Sites → New Tenant (+), at /super-admin/sites, visible only to Site 1 administrators.
WebhookPOST /api/provision-tenant, called by SubscriptionPortal when somebody subscribes. Authenticated with the X-Provisioning-Secret header against Provisioning:Secret — if that setting is empty, every call is rejected.

Both run the same ProvisionAsync, so a tenant created by hand and one created by a subscription are identical.

Re-calling with the same subscription id is safe. It finds the existing site by SiteGUID and returns it rather than building a second one — which is what makes a retried webhook harmless.