PINGWorks.SitecoreAI.ContentTypesSDK 1.0.0

dotnet add package PINGWorks.SitecoreAI.ContentTypesSDK --version 1.0.0
                    
NuGet\Install-Package PINGWorks.SitecoreAI.ContentTypesSDK -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PINGWorks.SitecoreAI.ContentTypesSDK" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PINGWorks.SitecoreAI.ContentTypesSDK" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PINGWorks.SitecoreAI.ContentTypesSDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PINGWorks.SitecoreAI.ContentTypesSDK --version 1.0.0
                    
#r "nuget: PINGWorks.SitecoreAI.ContentTypesSDK, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PINGWorks.SitecoreAI.ContentTypesSDK@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PINGWorks.SitecoreAI.ContentTypesSDK&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PINGWorks.SitecoreAI.ContentTypesSDK&version=1.0.0
                    
Install as a Cake Tool

PINGWorks.SitecoreAI.ContentTypesSDK

This is a .NET SDK for working with SitecoreAI's Content Types API.<br /> More information about Sitecore's API is at Content Types API Doc (official)

Features

  • Typed, DI-friendly service for interacting with the SitecoreAI Content Types API
  • Async-first API with CancellationToken support and full XML documentation comments
  • NetStandard 2.1 for wide compatibility
  • Automatic token maintenance using client credentials flow
  • Optional environmentId parameter on every operation, for targeting specific environments

Getting started

Prerequisites

To work with the SDK you will require credentials which are created in the SitecoreAI Deployment Portal.

Create an Environment credential of type Automation for the project and environment combination for which you wish to grant access.

Install

From your project directory:

dotnet add package PINGWorks.SitecoreAI.ContentTypesSDK

AppSettings

Properties are available to configure the SDK through configuration binding. The snippet below shows all options along with their default values. You do not need to include values where you wish to use the defaults.

{
    /* The base URL of the Content Types API */
    "ServiceEndpoint": "https://edge-platform.sitecorecloud.io/authoring/api/v1/",

    /* The URL of the Token Request API */
    "TokenEndpoint": "https://auth.sitecorecloud.io/oauth/token",

    /* The auth audience */
    "Audience": "https://api.sitecorecloud.io",

    /* The auth grant type */
    "GrantType": "client_credentials",

    /* The value of ClientID from the SitecoreAI Deploy Portal */
    "ClientID": "[Created in SitecoreAI Deploy portal's Credentials pane]",

    /* The value of ClientSecret from the SitecoreAI Deploy Portal */
    "ClientSecret": "[Created in SitecoreAI Deploy portal's Credentials pane]"
}

We recommend the use of Visual Studio's User Secrets feature to store sensitive information such as ClientId and ClientSecret during development.

Register services

Register the SDK in Program.cs, e.g. when using the minimal hosting model:

// Program.cs
var builder = WebApplication.CreateBuilder(args);

// Register SDK services - set options through binding or manually
builder.Services.AddSitecoreEEContentTypesSDK( opt => config.GetSection( "mySettings" ).Bind( opt ) );

HttpClient defaults. This call (via AddSitecoreEECommon) applies AddStandardResilienceHandler() and a DEBUG-only console request/response logger to every HttpClient in your container — not just the SDK's own. See the PINGWorks.SitecoreExperienceEdge.Common README for how to customize the resilience options per-client.

Shared credentials. This SDK shares one DefaultTokenProvider with the other SitecoreAI and Experience Edge SDKs and uses the credentials of the last SDK registered, so configure the same automation client for all of them in one container. The Transfer SDK uses its own per-environment credentials.

This library uses Json serialization through System.Text.Json.

Using the environment ID

Every operation accepts an optional environmentId parameter that targets a specific SAI environment. When omitted, the default environment is used.

// Target a specific environment
var type = await sdk.GetContentType( modelId, environmentId: "main" );

Identifiers

Identifier parameters are strings. Plain GUIDs and braced upper-case GUIDs ({110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}) are both accepted and are sent as given.

Field default values

CreateContentModelFieldInput.Value and UpdateContentModelFieldInput.Value are object?. Pass a string or object and it is serialised as that JSON value.

await sdk.CreateContentType( new CreateContentModelInput {
	Name = "Promo",
	FieldGroups = [ new CreateContentModelFieldGroupInput {
		Name = "Data",
		Fields = [ new CreateContentModelFieldInput { Name = "PromoText", Type = "Single-Line Text", Value = "Hello" } ]
	} ]
} );

Paging

ListContentTypes, GetFieldSource and GetFieldSources page with a continuation token that is sent in the x-sc-continuation request header. Pass the token returned by the previous page (ContentModelsList.Next, FieldSourceModelPaged.ContinuationToken, BulkFieldSourcesResponse.ContinuationToken) as continuationToken; a null token means there are no more pages.

string? token = null;
do
{
	var page = await sdk.ListContentTypes( pageSize: 50, continuationToken: token );
	if ( !page.IsSuccessful ) break;

	// ... use page.Result.Models
	token = page.Result.Next;
}
while ( token != null );

Errors

A failed call returns an ApiResponse<T> with IsSuccessful == false and an Error (RFC 7807 problem details: Title, Detail, Status).

Available services

Injectable interface ISitecoreContentTypesSdk

Content types
Method Description
ListContentTypes(search?, ids?, rootItemIds?, pageSize?, continuationToken?, environmentId?) Lists content types.
CreateContentType(request, environmentId?) Creates a content type.
GetContentType(modelId, environmentId?) Retrieves a content type with its field groups and fields.
UpdateContentType(modelId, request, environmentId?) Partially updates a content type.
ReplaceContentType(modelId, request, environmentId?) Replaces a content type.
DeleteContentType(modelId, environmentId?) Deletes a content type.
Validation rules
Method Description
ListValidationRules(environmentId?) Lists the validation rules assignable to fields.
Field sources
Method Description
GetFieldSource(modelId, fieldId, siteId?, pageSize?, continuationToken?, environmentId?) Retrieves one page of a field's source items.
GetFieldSources(modelId, request, siteId?, pageSize?, sourcePageSize?, continuationToken?, environmentId?) Retrieves the source items of several fields in one call.
Product 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 was computed.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 97 11/30/2026

v1.0.0 Initial release