PINGWorks.SitecoreCDP.GuestSDK
1.1.0
dotnet add package PINGWorks.SitecoreCDP.GuestSDK --version 1.1.0
NuGet\Install-Package PINGWorks.SitecoreCDP.GuestSDK -Version 1.1.0
<PackageReference Include="PINGWorks.SitecoreCDP.GuestSDK" Version="1.1.0" />
<PackageVersion Include="PINGWorks.SitecoreCDP.GuestSDK" Version="1.1.0" />
<PackageReference Include="PINGWorks.SitecoreCDP.GuestSDK" />
paket add PINGWorks.SitecoreCDP.GuestSDK --version 1.1.0
#r "nuget: PINGWorks.SitecoreCDP.GuestSDK, 1.1.0"
#:package PINGWorks.SitecoreCDP.GuestSDK@1.1.0
#addin nuget:?package=PINGWorks.SitecoreCDP.GuestSDK&version=1.1.0
#tool nuget:?package=PINGWorks.SitecoreCDP.GuestSDK&version=1.1.0
PINGWorks.SitecoreCDP.GuestSDK
This is a .NET SDK for working with Sitecore CDP's Guest API.<br /> More information about Sitecore's API is at Guest API Doc (official)
Features
- Typed, DI-friendly service for interacting with the Sitecore CDP Guest API v2.1
- Async-first API with
CancellationTokensupport and full XML documentation comments - NetStandard 2.1 for wide compatibility
- HTTP Basic Auth using Client Key and API Token from the CDP portal
- Focused sub-interfaces for guest management and data extensions
Getting started
Prerequisites
To work with the SDK you will need a Client Key and API Token from Settings > API access in the Sitecore CDP portal.
Install
From your project directory:
dotnet add package PINGWorks.SitecoreCDP.GuestSDK
AppSettings
Properties are available to configure the SDK through configuration binding. The snippet below shows all options along with their default values.
{
/* The Sitecore CDP API region. Valid values: US, EU, AP, JP (default: US) */
"Region": "US",
/* The Client Key from Settings > API access in the Sitecore CDP portal */
"ClientKey": "[Your Client Key]",
/* The API Token from Settings > API access in the Sitecore CDP portal */
"ApiToken": "[Your API Token]"
}
The regional endpoint URLs default to the standard Sitecore values. If you need to override a specific region's URL, set the corresponding property (ServiceEndpointUs, ServiceEndpointEu, ServiceEndpointAp, or ServiceEndpointJp).
We recommend the use of Visual Studio's User Secrets feature to store sensitive information such as ClientKey and ApiToken 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.AddSitecoreCdpGuestSDK( opt => config.GetSection( "mySettings" ).Bind( opt ) );
HttpClient defaults. This call (via
AddSitecoreEECommon) appliesAddStandardResilienceHandler()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.
This library uses Json serialization through System.Text.Json.
Guest type and status values
Use the enum and string constant types for type-safe API values:
using PINGWorks.SitecoreCDP.GuestSDK.Enums;
var request = new CreateGuestRequest
{
GuestType = GuestType.Customer,
FirstName = "Jane",
LastName = "Smith",
Subscriptions =
[
new GuestSubscription
{
Channel = "EMAIL",
Name = "newsletter",
PointOfSale = "my-store",
Status = SubscriptionStatus.Subscribed
}
]
};
Data extensions
Each guest can have up to six free-form key-value data extension slots. Use
DataExtensionName enum values for the slot name:
using PINGWorks.SitecoreCDP.GuestSDK.Enums;
var ext = await sdk.CreateGuestDataExtension( guestRef, new CreateGuestDataExtensionRequest
{
Name = DataExtensionName.Ext1,
AdditionalData = new Dictionary<string, object>
{
["vipMember"] = true,
["loyaltyTier"] = "gold",
["points"] = 1500
}
});
Available services
Guests — ISitecoreCdpGuestSdk
| Method | Description |
|---|---|
CreateGuest(request) |
Creates a new guest record. |
RetrieveGuests(offset?, limit?, expand?, sort?) |
Lists guests with pagination. |
RetrieveGuest(guestRef, expand?) |
Retrieves a single guest by reference. |
ReplaceGuest(guestRef, request) |
Fully replaces a guest's writable fields (PUT). |
PatchGuest(guestRef, request) |
Partially updates a guest (PATCH). |
DeleteGuest(guestRef) |
Deletes a guest and all associated data. |
Guest data extensions — ISitecoreCdpGuestExtensionsSdk
| Method | Description |
|---|---|
CreateGuestDataExtension(guestRef, request) |
Creates a data extension on a guest. |
RetrieveGuestDataExtensions(guestRef, offset?, limit?, expand?) |
Lists a guest's data extensions. |
RetrieveGuestDataExtension(guestRef, extensionName, expand?) |
Retrieves a single data extension. |
ReplaceGuestDataExtension(guestRef, extensionName, request) |
Fully replaces a data extension's data (PUT). |
PatchGuestDataExtension(guestRef, extensionName, request) |
Partially updates a data extension (PATCH). |
DeleteGuestDataExtension(guestRef, extensionName) |
Deletes an entire data extension. |
DeleteGuestDataExtensionFields(guestRef, extensionName, fieldNames?) |
Deletes specific fields from a data extension. |
| 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 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. |
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Http (>= 10.0.5)
- Microsoft.Extensions.Http.Resilience (>= 10.4.0)
- PINGWorks.SitecoreExperienceEdge.Common (>= 1.3.0)
- System.Net.Http.Json (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.1.0
✔️ Add CancellationToken support
v1.0.0
Initial release