Add Flock to your Unity game with the official C# SDK.
The Flock Unity SDK connects your game to the Flock backend: player auth, save data, economy,
remote config, downloadable assets, and analytics — configured from one in-editor window, with
strongly typed C# generated from your own schemas.
Download the Unity SDK
Get the latest .unitypackage from the releases page.
Open Flock → Settings and fill in the four fields from your game’s page on the
dashboard:
Field
Value
API URL
Leave the default (https://api-flock.qwacks.com) unless told otherwise
API Key
Identifies your game — treat it like a password
Game ID
Your game’s unique ID
Game Version
A version name that exists on the dashboard (e.g. v1.0.0)
Enter your credentials in the Flock → Settings window.
Values are saved to Assets/Resources/FlockConfig.asset. As you fill them in, the window prepares
the two things the SDK needs before it can start:
Resolve Game Version — your version name is looked up and its ID is baked into the
config. Runtime init uses that baked ID directly and never calls the server, so it must
resolve before you play or build. The window resolves it automatically when your credentials
change (or click Resolve Game Version).
Verify — the Setup checklist’s Verify button confirms your credentials actually reach
Flock.
Green checks across the Setup checklist mean you’re ready to initialize.
Connection verified and Game Version resolved — both required before init.
The API Key ships inside your build (it’s loaded from Resources at runtime). Use a key scoped to
the right environment, and rotate it on the dashboard if it leaks.
With auto-init on, the SDK is already running — just use FlockClient.Instance.
using Flock;// 1. Sign a player in. Auth methods throw on failure.await FlockClient.Instance.Authentication.LoginWithDeviceAsync("device-uuid");// 2. Call any service through the singleton.var game = await FlockClient.Instance.Game.GetGameAsync();Debug.Log($"Signed in as {FlockClient.Instance.CurrentPlayerId}, playing {game.Name}");
The SDK can start three ways. Automatic is the default and fits most games; the other two trade
a little setup for control over when init runs (after a splash screen, EULA, etc.).
Automatic (default)
Scene component
Manual
Nothing to call — the SDK initializes from FlockConfig.asset before the first scene loads and
restores a saved session in the background. React to lifecycle events if you need to:
Turn off Auto-Initialize On Load, then click Add to Scene in the Flock window (or add a
FlockBootstrap component yourself). It reads your config asset and initializes in Awake. Put
it in a boot scene with Don’t Destroy On Load on.
The FlockBootstrap component, pointed at your FlockConfig asset.
Turn off Auto-Initialize On Load and create the client yourself — e.g. after a splash screen
or EULA. Create is synchronous and makes no network call.
var config = Resources.Load<FlockConfigAsset>("FlockConfig");FlockClient.Create(config.ToInitConfig());// Manual init does NOT resume a saved session — do it yourself if you persist sessions:bool signedIn = await FlockClient.Instance.Authentication.TryRestoreSessionAsync();
Init is fail-fast. A bad config throws (the auto-init path logs instead of crashing), and
FlockClient.Instance throws until init succeeds. Guard with FlockClient.IsInitialized, inspect
FlockClient.InitializationError, or handle FlockEvents.OnInitializationFailed.
Signing in does not create an account — registering is a separate RegisterWith…Async call.
Registering an identity that already has one succeeds rather than failing, so you can send the player
to a login instead. Auth methods throw on failure, so wrap them in try/catch.
Run Code Generation → Sync Schemas in the Flock window to turn your dashboard’s player
templates, configs, and shops into typed C# accessors under Assets/Flock/Generated/.
The Code Generation tab — Sync Schemas, then browse the generated content catalog.
// Player data — typed accessor generated from your "PlayerProgress" template.var progress = await FlockClient.Instance.Player.GetPlayerProgressAsync();progress.Level = 5;await progress.UpdateAsync();// Remote config — change values on the dashboard without rebuilding.var gameplay = await FlockClient.Instance.Config.GetGameplayAsync();float speed = gameplay.BaseMoveSpeed;// Shop — enum-keyed purchase; the SDK resolves ids for you.await FlockClient.Instance.Shop.PurchaseAsync(FlockShopItemId.GemPack);
These accessors don’t exist until you sync.GetPlayerProgressAsync above is generated from a
PlayerProgress template on your dashboard. Write the call before the template exists — or before
the first Sync Schemas — and it fails to compile, not at runtime:
'PlayerProvider' does not contain a definition for 'GetPlayerProgressAsync'
The order is always: author the schema on the dashboard → Sync Schemas → write the call. Adding
or renaming a template later means syncing again.Unity’s own compiler error can’t tell you any of that, so the SDK watches compilation and prints
the missing step in the Console when it recognises one of these. The Code Generation tab also
shows whether a sync has ever run, and which game version it last synced for.
Each sync also writes a read-only FlockContentCatalog asset — designers can browse every shop,
config, and template in the Inspector without touching code or the dashboard.
The generated FlockContentCatalog — shops, configs, and templates with their values.
The Advanced Settings tab tunes analytics, HTTP retries, the asset and offline caches, and
editor tools (including Auto-Initialize On Load). The defaults are sensible — change them only
when you need to.
Advanced Settings — analytics, retries, caching, and editor tools.
Every SDK failure raises FlockException. Its Message names the call that failed, the server’s own
reason, the coded identifier, the HTTP status — and a Fix: line telling you what to do next.
Device login failed: Invalid login credentials [player.invalid_login_credentials, HTTP 400]Fix: This device is not registered yet. Call Authentication.RegisterWithDeviceAsync(deviceId) once to create the account, then Authentication.LoginWithDeviceAsync(deviceId) on later launches.
The same server code can mean different things depending on how the player signed in, so the fix is
specific to the credential — the message above says “register this device”, while the identical code
on an email sign-in says the password was wrong.
If you’d rather build your own text, every piece is on the exception:
Property
What it holds
Message
Everything below, composed into the line shown above.
ServerMessage
The server’s reason on its own ("Invalid login credentials"), or null.
Hint
The Fix: text on its own, or null when the SDK has nothing to add.
Operation
The call that failed ("Device login").
Code
The coded identifier as a string ("player.invalid_login_credentials").
ErrorCode
The same code as a FlockErrorCode enum value, for switch statements.
StatusCode
HTTP status, or null when the request never reached the server.
Body
The raw response body, for logs.
Branch on ErrorCode, never on message text. Codes are a stable contract; wording is not and will
change between versions.
catch (FlockException ex) when (ex.ErrorCode == FlockErrorCode.ShopInsufficientFunds){ ShowNotEnoughCoinsDialog();}
Hint is written for you, not your players — it names SDK methods and dashboard steps. Show it
in your own debug overlay or logs, and write separate player-facing copy for your UI. You can pull
the same text for any code with FlockErrorHints.For(errorCode).
A failure with no StatusCode never reached the server — that is a connectivity problem on the
device, not something the backend rejected.
The full API reference, codegen details, offline cache, and analytics tuning live in the
SDK README.