Samples
The MyCRM API samples repository is home to the C# sample client, the OpenAPI Specification and the Postman collections. Open the repository to find these developer resources, or explore the sample client below.
See a working MyCRM integration from inside a C# application. The sample client lets you choose an example, run it against the API and inspect the result, then follow the code to understand how it works.
What is the sample client?
The MyCrmSampleClient is an interactive .NET console application. It provides a menu of examples so developers can see how authentication, API requests and JSON:API responses fit together in C#.
Its HTTP client is generated from OpenAPI using Microsoft Kiota. Helper methods make query construction more readable, and shared sample state lets related examples reuse selected records. It is a learning application and reference implementation, rather than a hosted integration service or a promise of a separately supported SDK.
The examples cover:
| Area | What it demonstrates |
|---|---|
| Authentication | Obtain an OAuth token and attach authentication and adviser headers |
| Advisers | List advisers and retrieve profile details |
| Contacts | Read, filter, sort and include related addresses |
| Contact groups | Follow related contacts and select fields |
| Deals | Read recent deals and related information |
| Marketing consent | Update a contact's consent through PATCH |
| Leads | Create a new lead |
| Deal notes | Create a note, then update it |
Run your first example
You will need the .NET SDK and the credentials and URLs issued for your application. Clone or download the samples repository, then configure MyCrmSampleClient/appsettings.json locally:
| Setting | What to supply |
|---|---|
Auth.Url | Complete authentication URL |
Auth.ClientID and Auth.ClientSecret | Issued application credentials |
Auth.Scopes | Space-separated approved scopes |
MyCRM.Url | API base URL |
MyCRM.AdviserContactId | Adviser contact identifier |
Keep populated configuration private and out of source control. From the repository directory, run:
cd MyCrmSampleClient
dotnet run
Use the arrow keys to choose an example and press Enter. Start with a read example your credentials permit, such as latest-contacts. The results appear in the console. Some examples save record identifiers in a local state file for later examples to reuse; you can view or clear that state from the menu.
Creation and update examples make real changes. Use an agreed test environment and appropriate test records, and check the selected record before running a write example. Your application’s access may not permit every example in the menu.
See the sample client README in the repository for prerequisites, configuration, running instructions and the current list of samples.
For production, apply your own secure configuration, token caching, retry policy, monitoring and validation. Treat generated schemas as the contract for their recorded API version; keep your generated client aligned with the version you use.