| name | contentstack-management-dotnet-sdk |
|---|---|
| description | Use when changing or using the CMA client API, authentication, or NuGet package surface for Contentstack.Management.Core. |
- Adding or changing
ContentstackClientbehavior, options, or service entry points. - Documenting how consumers authenticate (management token, authtoken, login).
- Reviewing breaking vs compatible changes for the NuGet package
contentstack.management.csharp.
Official API reference: Content Management API.
| Package ID | Project | Role |
|---|---|---|
contentstack.management.csharp |
Contentstack.Management.Core/ |
Main SDK; ContentstackClient, models, services. |
contentstack.management.aspnetcore |
Contentstack.Management.ASPNETCore/ |
ASP.NET Core registration helpers; see ../aspnetcore-integration/SKILL.md. |
- Primary type:
ContentstackClient(IContentstackClient). - Configuration:
ContentstackClientOptions(and related options types).
- Management token: stack-scoped token; typical pattern
client.Stack(apiKey, managementToken)per product docs. - Authtoken: user/session token on the client options.
- Login with credentials:
ContentstackClient.Login/LoginAsyncwithNetworkCredential(see rootREADME.mdexamples).
OAuth-related code lives under Services/OAuth/, OAuthHandler.cs, and Utils/PkceHelper.cs. Prefer small, testable changes; preserve existing public contracts unless doing a major version bump.
- JSON serialization and converters are configured in
ContentstackClient(e.g. customJsonConvertertypes for fields and nodes). - Domain models live under
Models/. Follow existing patterns when adding types.
- Exceptions and error mapping:
Exceptions/. Keep messages and HTTP status handling consistent with existing patterns.
- The SDK talks to Contentstack Management HTTP APIs. Do not confuse with Delivery API clients.
- Retries, handlers, and pipeline details:
../http-pipeline/SKILL.md. TFMs and packaging:../framework/SKILL.md.
This describes how requests flow through this SDK. It is not the Content Delivery (CDA) client: there is no HttpWebRequest-only layer or delivery-token query-string-only rule set here.
ContentstackClient(ContentstackClient.cs) is the public entry point.ContentstackClientOptions(ContentstackClientOptions.cs) holdsHost, tokens, proxy, retry settings, and optional customRetryPolicy.- The client builds a
ContentstackRuntimePipelineinBuildPipeline():HttpHandler→RetryHandler(see../http-pipeline/SKILL.md).
Stack(Models/Stack.cs) is obtained from the client (e.g.client.Stack(apiKey, managementToken)or overloads). Most management operations are stack-relative.- Domain types under
Models/(entries, assets, content types, etc.) expose methods that construct or callIContentstackServiceimplementations.
IContentstackService(Services/IContentstackService.cs) defines one CMA operation: resource path, HTTP method, headers, query/path resources, body (HttpContent), and hooks to build the outbound request and handle the response.- The client executes services via
InvokeSync/InvokeAsync, which run the pipeline and returnContentstackResponse.
Important members on IContentstackService:
Parameters—ParameterCollectionfor typed query/body parameters (used by list/query flows).QueryResources,PathResources,AddQueryResource,AddPathResource— URL composition.UseQueryString— some operations send parameters as query string instead of body.CreateHttpRequest/OnResponse— integrate withContentstackHttpRequestand response parsing.
Concrete services live under Services/ (including nested folders by domain, e.g. stack, organization, OAuth).
Implementation details span OAuthHandler, Services/OAuth/, and client token dictionaries on ContentstackClient (high-level behavior is under Authentication above).
- Confirm the CMA contract (path, method, query vs body) from official API docs.
- Implement or extend an
IContentstackService(or reuse patterns from a sibling service inServices/). - Expose a method on the appropriate
Stack/ model type; keep public API consistent with existing naming. - Add unit tests (MSTest + mocks); add integration tests only when live API coverage is required.
- If behavior touches HTTP retries or status codes, coordinate with
../http-pipeline/SKILL.md.
The management SDK exposes a fluent Query type for listing resources (stacks, entries, assets, roles, etc.). It is separate from the Content Delivery SDK’s query DSL.
| Type | Location | Role |
|---|---|---|
Query |
Queryable/Query.cs |
Fluent methods add entries to an internal ParameterCollection, then Find / FindAsync runs QueryService. |
ParameterCollection |
Queryable/ParameterCollection.cs |
SortedDictionary<string, QueryParamValue> with overloads for string, double, bool, List<string>, etc. |
Models such as Entry, Asset, Role, Stack expose Query() returning a Query bound to that resource path. Chain parameters, then call Find() or FindAsync():
// Illustrative — see XML examples on Query/Stack/Entry in the codebase.
ContentstackResponse response = client
.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.ContentType("<CONTENT_TYPE_UID>")
.Entry()
.Query()
.Limit(10)
.Skip(0)
.Find();Requirements enforced by Query:
- Stack must be logged in where applicable (
ThrowIfNotLoggedIn). - Stack API key must be present for the call (
ThrowIfAPIKeyEmpty).
Find(ParameterCollection collection = null) and FindAsync merge an optional ParameterCollection into the query before building QueryService. Use this when ad-hoc parameters are not exposed as fluent methods.
- Add a method on
Querythat calls_collection.Add("api_key", value)(or the appropriateParameterCollectionoverload). - Return
thisfor chaining. - Add XML documentation with a short
<example>consistent with existingQuerymembers. - Add unit tests if serialization or parameter keys are non-trivial.
List operations ultimately construct a QueryService that implements IContentstackService and is executed through ContentstackClient.InvokeSync / InvokeAsync. Path and HTTP details live on the service; the fluent API only shapes ParameterCollection. For the overall request path, see Architecture above.