PINGWorks.SitecoreAI.ContentItemsSDK 1.0.0

dotnet add package PINGWorks.SitecoreAI.ContentItemsSDK --version 1.0.0
                    
NuGet\Install-Package PINGWorks.SitecoreAI.ContentItemsSDK -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.ContentItemsSDK" 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.ContentItemsSDK" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PINGWorks.SitecoreAI.ContentItemsSDK" />
                    
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.ContentItemsSDK --version 1.0.0
                    
#r "nuget: PINGWorks.SitecoreAI.ContentItemsSDK, 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.ContentItemsSDK@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.ContentItemsSDK&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PINGWorks.SitecoreAI.ContentItemsSDK&version=1.0.0
                    
Install as a Cake Tool

PINGWorks.SitecoreAI.ContentItemsSDK

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

Features

  • Typed, DI-friendly service for interacting with the SitecoreAI Content Items 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 operations that support it, 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.ContentItemsSDK

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 Items 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.AddSitecoreEEContentItemsSDK( 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

Most operations accept an optional environmentId parameter that targets a specific SAI environment. When omitted, the default environment is used. TranslateContentItem does not take one.

// Target a specific environment
var item = await sdk.GetContentItem( itemId, language: "en", 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 values

UpdateFieldValue.Value is an object?. Pass a string, number, boolean or object and it is serialised as that JSON value. A null value is omitted from the request, so to clear a field send an empty string.

await sdk.UpdateContentItem( itemId, new UpdateContentItemInput {
	Fields = [ new UpdateFieldValue { Id = fieldId, Value = "New title" } ]
} );

Paging

ListContentItems and GetHierarchyChildren page with a continuation token that is sent in the x-sc-continuation request header. Pass the token returned by the previous page (ContentItemList.Next, HierarchyChildrenResult.ContinuationToken) as continuationToken; a null token means there are no more pages.

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

	// ... use page.Result.Results
	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 ISitecoreContentItemsSdk

Content items
Method Description
ListContentItems(contentItemId, search?, language?, pageSize?, ids?, continuationToken?, environmentId?) Lists content items beneath a content item. search and ids cannot be combined.
CreateContentItem(request, environmentId?) Creates a content item.
GetContentItem(id, language?, version?, environmentId?) Retrieves a content item with its fields.
UpdateContentItem(id, request, language?, version?, environmentId?) Partially updates a content item.
ReplaceContentItem(id, request, language?, version?, environmentId?) Replaces a content item; omitted fields are cleared.
DeleteContentItem(id, permanently?, environmentId?) Deletes a content item.
ValidateContentItem(id, environmentId?) Runs field validators for a content item.
ListLiveContentItems(items, environmentId?) Retrieves the published representation of content items.
Versions
Method Description
ListVersions(id, language?, environmentId?) Lists the language versions of a content item.
CreateVersion(id, request, environmentId?) Creates a language version.
DeleteVersion(id, versionNumber, language, environmentId?) Deletes a language version.
Hierarchy
Method Description
GetHierarchy(contentItemId, childrenModelIds?, language?, environmentId?) Retrieves a content item with its ancestors and children.
GetHierarchyChildren(id, language?, limit?, continuationToken?, environmentId?) Retrieves one page of a content item's children.
Translation
Method Description
TranslateContentItem(id, request) Translates a content item using AI (async job).
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 86 11/30/2026

v1.0.0 Initial release