SuccessMortgagePartners.TotalExpert.Client
0.1.0
dotnet add package SuccessMortgagePartners.TotalExpert.Client --version 0.1.0
NuGet\Install-Package SuccessMortgagePartners.TotalExpert.Client -Version 0.1.0
<PackageReference Include="SuccessMortgagePartners.TotalExpert.Client" Version="0.1.0" />
<PackageVersion Include="SuccessMortgagePartners.TotalExpert.Client" Version="0.1.0" />
<PackageReference Include="SuccessMortgagePartners.TotalExpert.Client" />
paket add SuccessMortgagePartners.TotalExpert.Client --version 0.1.0
#r "nuget: SuccessMortgagePartners.TotalExpert.Client, 0.1.0"
#:package SuccessMortgagePartners.TotalExpert.Client@0.1.0
#addin nuget:?package=SuccessMortgagePartners.TotalExpert.Client&version=0.1.0
#tool nuget:?package=SuccessMortgagePartners.TotalExpert.Client&version=0.1.0
SuccessMortgagePartners.TotalExpert.Client
A .NET client for the Total Expert public API, published to NuGet.org.
- Client-credentials tokens, cached for their lifetime and renewed automatically (and once more after a
401). - Create, read, update and delete for contacts, users, lead opportunities, contact groups and loans (where Total Expert supports each operation).
- Filtering, sorting and paging, including
ListAllAsync, which walks every page. - Retries that never repeat a create or update Total Expert may already have saved.
IHttpClientFactoryintegration and one-line setup from configuration.- Targets
net10.0andnetstandard2.0.
Install
dotnet add package SuccessMortgagePartners.TotalExpert.Client
Configure
Bind the TotalExpert configuration section (appsettings, Azure App Configuration, Key Vault references, environment variables…):
builder.Services.AddTotalExpertClient(builder.Configuration);
| Key | Notes |
|---|---|
TotalExpert:BaseUrl |
API host. Defaults to https://public.totalexpert.net. A trailing /v1 is optional. |
TotalExpert:ClientId |
Required. |
TotalExpert:ClientSecret |
Required. Keep it in Key Vault or user secrets, never in source control. |
TotalExpert:Scope |
Optional. Leave unset to get every scope granted to the client. Lead opportunities need leadOpportunitiesSalesPipelineInteraction; loans need loanInteraction. |
TotalExpert:MaxRetries |
Optional, default 3. See Retries. |
TotalExpert:TokenRefreshSkew, TotalExpert:Timeout |
Optional TimeSpans: renew tokens this long before they expire (default 5 minutes); per-request timeout (default 100 seconds). |
Or set the options in code:
builder.Services.AddTotalExpertClient(options =>
{
options.ClientId = "...";
options.ClientSecret = "...";
});
Settings are validated when the host starts.
Use
Inject ITotalExpertClient. Each API area is a property: Contacts, Users, LeadOpportunities, ContactGroups, Loans.
public sealed class LeadIntake(ITotalExpertClient totalExpert)
{
public async Task<string> CreateLeadAsync(string loanOfficerEmail, CancellationToken ct)
{
var loanOfficer = await totalExpert.Users.FindByEmailAsync(loanOfficerEmail, ct);
if (loanOfficer is null || !loanOfficer.IsActive)
{
throw new InvalidOperationException("Unknown or inactive loan officer.");
}
var contact = await totalExpert.Contacts.FindFirstAsync(
new TotalExpertQuery().Where("owner_id", loanOfficer.Id).Where("email", "john.doe@example.com"), ct);
var contactId = contact?.Id ?? (await totalExpert.Contacts.CreateAsync(new ContactInput
{
FirstName = "John",
LastName = "Doe",
Email = "john.doe@example.com",
Source = "Website",
Owner = UserReference.ById(loanOfficer.Id),
}, ct)).Id;
var lead = await totalExpert.LeadOpportunities.CreateAsync(new LeadOpportunityInput
{
FirstName = "John",
LastName = "Doe",
Email = "john.doe@example.com",
Source = "Website",
ContactId = contactId,
AssignedUser = AssignedUser.ById(loanOfficer.Id),
Product = new LeadProduct("mortgage", new JsonObject { ["loan_purpose"] = "Purchase" }),
}, ct);
return lead.Id;
}
}
Operations
| Area | Get | List / ListAll / FindFirst | Create | Update | Delete |
|---|---|---|---|---|---|
Contacts |
✓ | ✓ | ✓ | ✓ | ✓ |
Users |
✓ | ✓ (plus FindByEmailAsync) |
✓ | ✓ | Total Expert has none; set Status = "0" |
LeadOpportunities |
✓ | ✓ (plus ListForContactAsync) |
✓ | ✓ | Total Expert has none; move the lead to stage 8 (Closed) |
ContactGroups |
✓ | ✓ | ✓ | ✓ | ✓ |
Loans |
✓ | ✓ | ✓ | ✓ | ✓ |
GetAsyncreturnsnullwhen the record doesn't exist. Every other non-success response throwsTotalExpertApiExceptionwith the status code, the operation, Total Expert'serror/messagetext and the raw body. The body and message can quote what you sent, so treat them as personal data when logging.- Creates dedupe. Total Expert matches contacts (and loans) against existing records.
CreateResult.Createdisfalsewhen it matched and updated an existing record instead of creating one. - Updates are partial.
*Inputclasses send only the properties you set, soUpdateAsync(id, new ContactInput { City = "Anytown" })changes only the city. - Lead opportunity updates always need
ContactId. Total Expert saves assignment, stage and the other fields separately, so checkUpdateLeadOpportunityResult.Errorsfor the parts that failed.ReferredByContactsreplaces the whole list; send an empty list to clear it. A207(lead saved, custom fields not) shows asCustomFieldsFailed. - Fields the models don't name are still available. Responses keep them in
AdditionalProperties(raw JSON), and inputs send anything inAdditionalFields:
await totalExpert.Contacts.UpdateAsync(contactId, new ContactInput
{
AdditionalFields = new Dictionary<string, object?> { ["do_not_contact"] = "1" },
});
- Loose types are handled. Total Expert often sends amounts, ids and flags as strings (
"325000.00","1"). The models read them asdecimal?,long?andbool?, and an empty string reads asnull. Dates stay as the strings Total Expert sends, because their format varies by field. - Loan status, type, program and purpose are plain strings on
Loan/LoanInput(LoanStatus = "Funded"). Total Expert wraps each one in an object ({"loan_status": {"loan_status": "Funded"}}), and the client reads and writes that shape for you. Which loan fields are filled in depends on the loan's account class and your organization's setup.
Filtering, sorting and paging
var query = new TotalExpertQuery()
.Where("owner_email", "jane.lo@example.com")
.Where("internal_updated_at_start", "2026-01-01T00:00:00Z")
.OrderBy("-internal_updated_at");
await foreach (var contact in totalExpert.Contacts.ListAllAsync(query, ct))
{
// every matching contact, 100 per request
}
var page = await totalExpert.Contacts.ListAsync(query.Page(1, 25), ct); // one page
Each resource accepts its own filter and sort fields. These were checked against a live org (the integration tests check that results really are filtered and in order, and that pages don't overlap):
| Area | Filters | Sorts |
|---|---|---|
Contacts |
owner_id, owner_email, email, email_contains, last_name, last_name_contains, phone_cell, external_id, group_id, internal_updated_at_start (_end needs _start too), source (not exact) |
internal_updated_at, internal_created_at, last_name, id |
Users |
email, username, status |
internal_updated_at |
LeadOpportunities |
user_id, contact_id |
created_at, updated_at, lead_stage |
Loans |
owner_id, owner_email, external_id, loan_number, borrower_id, loan_status, internal_updated_at_start |
internal_updated_at, loan_amount, id |
ContactGroups |
none (Total Expert rejects filters with 422) | group_name |
Paging works on every list. Filter values can't contain commas. Total Expert's rate limit is 1,000 requests per minute.
Retries
The client retries on its own, so don't add a generic retry handler on top:
- Any request is retried after
429, which means Total Expert rejected it before processing it (usingRetry-Afterwhen sent, otherwise 1 s, 2 s, 4 s…). - A
GETis also retried after408,500,502,503,504, a timeout or a network error. - A create or update is not retried after those, because Total Expert may already have saved it and a retry could create a duplicate contact or lead.
If your app adds a standard resilience handler to every HttpClient (for example ConfigureHttpClientDefaults(b => b.AddStandardResilienceHandler())), remove it from this client:
builder.Services.AddTotalExpertClient(builder.Configuration)
.RemoveAllResilienceHandlers(); // Microsoft.Extensions.Http.Resilience
AddTotalExpertClient returns the API client's IHttpClientBuilder, so you can add your own handlers (logging, telemetry) the same way.
Build and test
dotnet build # warnings are errors
dotnet test
dotnet pack src/SuccessMortgagePartners.TotalExpert.Client -c Release -o artifacts
Integration tests against a real Total Expert org are in tests/SuccessMortgagePartners.TotalExpert.Client.IntegrationTests and are skipped unless TOTALEXPERT_INTEGRATION=1; see the README there.
docs/ holds the Total Expert OpenAPI export and an extract of the Postman documentation for the endpoints this client covers.
CI and release
CI runs on Azure Pipelines from azure-pipelines.yml; the code stays on GitHub.
developis the default branch. Pull requests targetdevelop.- Every push and pull request to
developormainbuilds, tests and packs. - Every merge (push) to
mainalso pushes the package to NuGet.org and creates thevX.Y.Ztag and GitHub release. The version is<Version>insrc/SuccessMortgagePartners.TotalExpert.Client/SuccessMortgagePartners.TotalExpert.Client.csproj; a version with a suffix (1.2.0-preview.1) is published as a prerelease. - To release: bump
<Version>ondevelop, then mergedevelopintomain. If that version is already on NuGet.org from another commit, the run warns and publishes nothing. If a release run fails after the NuGet push, wait until the version shows on nuget.org, then use Rerun failed jobs on that run. Don't push release tags by hand.
One-time setup in Azure DevOps (the same as encompass-client):
- In the Development project, Pipelines → New pipeline → GitHub (YAML), pick this repo and the existing
azure-pipelines.yml. Use the existinggithub.com_SuccessMortgagePartnersconnection. - Library → Variable group
totalexpert-client-releasewith secret variableNuGetApiKey(a NuGet.org key with Push new packages and package versions for the globSuccessMortgagePartners.*; 0.1.0 creates the package). Allow the pipeline to use it, and add a Branch control check that allows onlyrefs/heads/main. - Service connection (GitHub) named
github-releases-totalexpert-client, for creating the tag and GitHub release (OAuth, or a fine-grained token limited to this repo with Contents: read and write), with a Branch control check allowing onlyrefs/heads/main. - Environment
totalexpert-client-nuget, with a Branch control check forrefs/heads/main. Add an approval check too if you want a person to confirm each publish. releaseEnabledinazure-pipelines.ymlis'true'. Set it to'false'to stop publishing; runs onmainthen build and pack only.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
-
net10.0
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 105 | 11/11/2026 |