# Partner Module — Full Endpoints Flow

**Scope:** White-labeling / Partner module endpoints, organized by when they run in the application lifecycle — Pre-Login, Post-Login, and Partner Setup (admin/onboarding).

---

## 1. Pre-Login (Unauthenticated)

Runs before the user has credentials — resolves branding and boots the app.

| # | Endpoint | Description | Database | Table(s) |
|---|---|---|---|---|
| 1 | `GET /ClientDomain/GetDomainTenant` | Resolves a custom hostname (e.g. `demo.goodbookserp.in`) to a `ConnectionName`, before any tenant is known | GB5System | `TCLIENTDOMAIN` |
| 2 | `GET /fws/VersionUrlIdentifer/GetVersionUrlIdentifier` | Core boot step — resolves the base URL for a given `ConnectionName` *(core framework, not Partner)* | GB5System | `MSERVERCONFIG` |
| 3 | `GET /fws/Version/VersionCheck` | Core boot step — version handshake, issues the Digest auth challenge *(core framework, not Partner)* | GB5System | `MSERVERCONFIG` |
| 4 | `GET /Partner/GetPublicBrandByConnection` | **The white-labeling entry point.** Resolves `ConnectionName → ClientId → PartnerProductId → Brand`; paints the login screen (colors, logo, app name) before authentication | GB5System → Tenant | `MSERVERCONFIG`, `MCLIENTDETAILS` → `TPARTNERPRODUCT`, `TPARTNER`, `TPARTNERBRAND`, `TPARTNERPRODUCTBRAND`, `MFILE` |
| 5 | `GET /PartnerBrand/GetPartnerLogoFile` | Same resolution as above, but streams the raw logo/favicon image file directly (for `<img>`/favicon tags) | GB5System → Tenant | Same as above |
| 6 | `POST /fws/ServerService/authenticate` | Digest auth challenge/response — issues the real `Login` session header *(core framework, not Partner)* | GB5System | `MUSER`, session tables |

---

## 2. Post-Login (Authenticated — `Login` header required)

| # | Endpoint | Description | Database | Table(s) |
|---|---|---|---|---|
| 1 | `GET /PartnerBrand/GetResolvedBrandForClient` | Re-confirms branding via the authenticated session (`LoginDTO.ClientId`) instead of `ConnectionName` | GB5System → Tenant | `MCLIENTDETAILS` → `TPARTNERPRODUCT`, `TPARTNER`, `TPARTNERBRAND` |
| 2 | `GET /PartnerBundle/GetTerminologyBundle` | Loads terminology overrides for the logged-in user's language (`EN`/`TN`) | Tenant | `TPARTNERTERM` |
| 3 | `GET /fws/UserLoginDetail/GetUserLoginDetail` | Core post-login user detail fetch — also resolves partner branding as part of its join *(core framework, not Partner)* | GB5System → Tenant | `MUSER`, `MCLIENTDETAILS` → `TPARTNERPRODUCT`, `TPARTNER`, `TPARTNERBRAND`, `TPARTNERPRODUCTBRAND` |
| 4 | `GET /PartnerTerm/GetPartnerTerm` | Fetch terms for a specific product/language (finer-grained than the bundle) | Tenant | `TPARTNERTERM` |
| 5 | `GET /ClientDetail/GetClientDetailList` | Admin view — lists all sites for a client with their current partner assignment | GB5System | `MCLIENTDETAILS` |

---

## 3. Partner Setup (Authenticated — admin/onboarding flow)

### 3.1 Phase 0 — Connect a Client (2 calls)

| # | Endpoint | Description | Database | Table(s) |
|---|---|---|---|---|
| 1 | `POST /ClientDetail/RegisterConnection` | Registers a new `ConnectionName` onto an existing physical database (e.g. `Sankar` → `DEMO`) | GB5System | `MSERVERCONFIG` |
| 2 | `POST /ClientDetail/CreateClientDetail` | Creates the `MCLIENTDETAILS` row for that client (fills a confirmed gap — nothing else in the codebase creates this) | GB5System | `MCLIENTDETAILS` |

### 3.2 Phase 1 — Build the Partner (1 combined call, writes 9 tables)

| # | Endpoint | Description | Database | Table(s) |
|---|---|---|---|---|
| 1 | `POST /Partner/SetupPartnerComplete` | **One call** — creates Partner, Product, Brand, assigns the client, and creates ProductBrand, Terms, ApiKey, Domain, Webhook. All fields required, all-or-nothing | GB5System + Tenant | `MCLIENTDETAILS` (update) + `TPARTNER`, `TPARTNERPRODUCT`, `TPARTNERBRAND`, `TPARTNERPRODUCTBRAND`, `TPARTNERTERM`, `TPARTNERAPIKEY`, `TCLIENTDOMAIN`, `TPARTNERWEBHOOK` |

### 3.3 Individual CRUD Endpoints

Used internally by `SetupPartnerComplete`; also callable standalone for updates/edits/deletes.

| Endpoints | Description | Database | Table |
|---|---|---|---|
| `POST /Partner/SavePartner`<br>`GET /Partner/GetPartner`<br>`GET /Partner/GetPartnerList`<br>`POST /Partner/GetSelectListPartner`<br>`DELETE /Partner/DeletePartner` | Partner CRUD | Tenant | `TPARTNER` |
| `POST /PartnerProduct/SavePartnerProduct`<br>`GET /PartnerProduct/GetPartnerProduct`<br>`GET /PartnerProduct/GetPartnerProductList`<br>`POST /PartnerProduct/GetSelectListPartnerProduct`<br>`DELETE /PartnerProduct/DeletePartnerProduct` | Product CRUD | Tenant | `TPARTNERPRODUCT` |
| `POST /PartnerBrand/SavePartnerBrand`<br>`GET /PartnerBrand/GetPartnerBrand`<br>`POST /PartnerBrand/GetSelectListPartnerBrand` | Brand CRUD | Tenant | `TPARTNERBRAND` |
| `POST /PartnerProductBrand/SavePartnerProductBrand`<br>`GET /PartnerProductBrand/GetPartnerProductBrand` | Product-level brand override CRUD | Tenant | `TPARTNERPRODUCTBRAND` |
| `POST /PartnerTerm/SavePartnerTerm`<br>`GET /PartnerTerm/GetPartnerTerm`<br>`DELETE /PartnerTerm/DeletePartnerTerm` | Terminology CRUD | Tenant | `TPARTNERTERM` |
| `POST /ClientDetail/AssignPartnerProduct` | Links a client's site to a `PartnerProductId` | GB5System | `MCLIENTDETAILS` |
| `POST /PartnerKey/SavePartnerApiKey`<br>`GET /PartnerKey/GetPartnerApiKeyList`<br>`DELETE /PartnerKey/DeletePartnerApiKey` | M2M API key CRUD | GB5System | `TPARTNERAPIKEY` |
| `POST /PartnerToken/AuthToken` | Partner's external system exchanges an API key for a JWT | GB5System | `TPARTNERAPIKEY` |
| `POST /ClientDomain/SaveClientDomain`<br>`GET /ClientDomain/GetClientDomain`<br>`POST /ClientDomain/VerifyClientDomain`<br>`DELETE /ClientDomain/DeleteClientDomain` | Custom domain CRUD | GB5System | `TCLIENTDOMAIN` |
| `POST /PlatformCnameTarget/SavePlatformCnameTarget`<br>`GET /PlatformCnameTarget/GetPlatformCnameTarget` | Global CNAME default (not per-partner) | GB5System | `TPLATFORMSETTINGS` |
| `POST /PartnerWebhook/SavePartnerWebhook`<br>`GET /PartnerWebhook/GetPartnerWebhookList`<br>`DELETE /PartnerWebhook/DeletePartnerWebhook` | Webhook CRUD | Tenant | `TPARTNERWEBHOOK` |
| `POST /PartnerSync/ProvisionPartnerSync`<br>`POST /PartnerSync/RefreshPartnerSyncProducts` | Syncs a partner's data across multiple tenant DB instances (only needed if one partner spans more than one client database) | Multiple Tenant DBs | `TPARTNER`, `TPARTNERPRODUCT`, `TPARTNERBRAND` |

---

## 4. Notes

- **`MFILE`** is referenced (via `LogoFileId`/`LogoDarkFileId`/`FaviconFileId`) throughout Pre-Login and Setup, but is never created by any Partner endpoint. Logo/favicon files are uploaded through the core framework's separate file-upload endpoint first; the resulting `FileId` is then passed into the relevant brand fields.
- **`TPLATFORMSETTINGS`** is a global, platform-wide setting (e.g. default CNAME target) — set once for the entire system, not once per partner.
- **`SetupPartnerComplete`** is all-or-nothing: every section of its request body is required, and any step failing aborts the whole call. Rows already committed earlier in the same call are not automatically rolled back (each underlying Save runs its own independent transaction) — treat a failure as "fix input and retry the whole call," not "some tables succeeded."
