Integration Walkthrough
Register the SDK, sign a player in, send an action, and read back player state. This is the shortest path to a working integration, in the order you would build it.
The detail behind each step is in Authentication, SDK Guide, and Sending Actions. Follow this page first, then use those as reference.
Prerequisites
.NET 10 if you're using the typed SDK (
Game.Sdktargetsnet10.0). Any other stack needs an HTTP and JSON client and must implement the device-key authentication the SDK otherwise handles: generate a P-256 keypair, store the private key, and sign the proof-of-possession on sign-in, refresh, and handoff (see Authentication). The rest of the flow is the same against the HTTP API.A registered app id and a gateway address to point at. App registration is hand-run today: get in touch to have your app set up. You'll get back an app id and, for the game door, the gateway URL to use.
The SDK itself. There is no public NuGet package; the .NET SDK is delivered as part of onboarding, the same step covered in Getting access.
The examples below use the .NET Game.Sdk through the gateway; any other stack follows the same steps against the HTTP API.
1. Register the SDK
At startup, register Game.Sdk with the gateway address and app id you were given:
builder.Services.AddGameSdk(opts =>
{
opts.GatewayUrl = "https://your-gateway.example";
opts.AppId = "your-app-id";
});This registers Bearer auth, the baked X-App-Id header, one typed client per domain, and a single IAppFacade that exposes all of them under your app id.
AddGameSdk does not register the two host-supplied services the SDK depends on. You provide both, because both are platform decisions the SDK cannot make for you:
IDeviceCryptoProvider holds the device's P-256 keypair and signs the proof of possession. ISecretStorage decides where the private key and the refresh token are kept. The SDK ships a plaintext ISecretStorage suitable for development only; a shipping client stores these in the platform keystore.
From there you get the clients either by injecting IAppFacade and reading its members, or by injecting a specific client directly. The rest of this page works inside one class, so every service the later steps use is declared once here:
IAppFacade carries the domain clients. IPlayerSession holds the signed-in player's id and tokens, and IDirectiveProcessor runs any directives an action returns. All three come from the registration above.
2. Sign a player in
A device that the platform has not seen before is bootstrapped as a guest, and the server does not check a proof it has no registered key for. The client sends the same body either way:
Send all four members. The SDK always signs and sends a proof, and on every later sign-in the server verifies it against the key it registered on first contact. A raw HTTP client that sends only deviceId and publicKey works once and then has no way to sign in again.
On success you get back { accessToken, refreshToken, accessTokenExpiresAt }.
Two things the SDK does not do for you. It does not generate the keypair: your IDeviceCryptoProvider owns the key and signs the proof. It does not persist tokens or mark the session as signed in, so activate the session yourself:
Until you call Activate, the session is not authenticated and the automatic refresh path has nothing to work from. Authentication covers the full signing contract and what changes once the device is already known.
3. Send an action
An action needs two values you supply yourself. The first is the player id: IPlayerSession.PlayerId is a Guid?, while ActionRequestDto takes a Guid, so unwrap it and treat a missing value as "not signed in yet". The second is clientKey, the idempotency token for this call. Generate a fresh one for each genuinely new action and reuse the same one only when retrying that action, because it is what lets the platform recognise a repeat.
Those three outcomes need different handling:
Transport failure
The request may or may not have reached the engine
The action's fate is unknown. Recovery depends on its deduplication mode
Skipped action
The engine answered and declined to apply it
A configuration or wiring problem. A retry will not fix it
Business rejection
A 400 with a stable code, on the pool and quest verbs
Correct the input or the state
Production Operations sets out what is safe to resend in each case.
Two client behaviours matter when you build error handling around this. The SDK sets no request timeout, so a call falls back to HttpClient's 100 second default, and it retries nothing automatically. A transport failure arrives as IsSuccess == false with StatusCode 0, which is how you tell a timeout or a DNS failure from a status the server actually returned.
tap has to be an action id your app configuration declares. An action the engine does not apply comes back in the response's skipped count with HTTP 200 rather than as an error, so confirm skipped is 0 before treating the call as done. Several different conditions produce a skip, including a duplicate client key on an action that deduplicates, so do not assume a skip means the action id is wrong. Sending Actions lists the causes and how to tell them apart. response.Data is the ClientResponse envelope, and its .Data is ActionBatchResult { Processed, Skipped }. On the wire, the raw envelope looks like:
If skipped is not 0, find the cause before resending: a blind retry re-applies whatever did succeed. Sending Actions covers the failure rule and how to choose between TrackActionsAsync and ExecuteActionsAsync, and App Configuration covers how actions get declared.
4. Read player state
This returns composite player state directly, with no envelope to unwrap. If the action in step 3 touched any resources or derived values, the action response already echoed the change through its effects channel, so you do not need this call just to see what the last action did. SDK Guide lists every domain client and which ones return an envelope versus plain data.
Confirming the integration worked
At this point you should be able to check off:
Sign-in returned a token pair (
accessToken,refreshToken,accessTokenExpiresAt) without an error.The
tapaction returnedskipped: 0.GetStateAsync()returns your player's state, including whatever thetapaction touched.
If a call fails or behaves unexpectedly, Troubleshooting lists the common symptoms and their causes. If skipped is not 0, start with the two most common causes: the action is not declared in your configuration, or it was sent on the lane its configuration does not select. Sending Actions lists the rest, including a duplicate client key, which means the work already happened rather than that anything is misconfigured. If neither applies, confirm that your AppId and GatewayUrl match what you were given at registration.
After this
One player signed in through a device keypair, one action recorded against your configuration, and their state readable back. Everything past this point is the same loop: declare a new action or resource in configuration, send it, read the result. What You Can Build covers the rest of the engine (quests, packages, bundles, the cross-game currency bridge) on top of these same steps.
Last updated