> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperx.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Initialization

> Connect the Unity/.NET SDK to your production HyperX project.

Initialize the HyperX SDK once during startup. After initialization succeeds, user, data, LiveOps, and social APIs are ready to call.

## Basic Initialization

```cs theme={null}
await HyperX.Core.Init("PROJECT_CODE");
```

`PROJECT_CODE` is the unique code for your Console project. Initialization fails if the code is missing, wrong, or unavailable.

## Recommended Unity Bootstrap

```cs theme={null}
using System;
using UnityEngine;
using HyperX;

public class HyperXBootstrap : MonoBehaviour
{
    async void Start()
    {
        try
        {
            await Core.Init(new HyperXInitOptions
            {
                ProjectCode = "PROJECT_CODE",
                Environment = HyperXEnvironment.Production,
                Timeout = TimeSpan.FromSeconds(10)
            });

            Debug.Log("HyperX ready");
        }
        catch (HyperXInitializationException ex)
        {
            Debug.LogError($"HyperX init failed: {ex.ErrorCode}");
        }
    }
}
```

Production games should use `HyperXEnvironment.Production` only.

## Initialization Errors

Initialization errors are thrown as `HyperXInitializationException`.

| ErrorCode                       | Meaning                            | Check                                                   |
| ------------------------------- | ---------------------------------- | ------------------------------------------------------- |
| `PROJECT_CODE_REQUIRED`         | The project code is empty.         | Build settings or constants.                            |
| `PROJECT_NOT_FOUND`             | HyperX could not find the project. | The project code copied from Console.                   |
| `INITIALIZATION_TIMEOUT`        | The project check timed out.       | Network state and retry behavior.                       |
| `INITIALIZATION_REQUEST_FAILED` | The network request failed.        | Internet access, firewall, platform network permission. |

API errors after initialization are handled as `HyperXServerException`. See [Error Handling](/guide/en/dotnet/error-handling).

## Create a Player Session After Init

For gameplay code that calls authenticated APIs often, prefer the `PlayerSession` flow.

```cs theme={null}
await HyperX.Core.Init("PROJECT_CODE");

var player = await HyperX.Core.Users.StartGuestSession(
    authenticationToken: SystemInfo.deviceUniqueIdentifier,
    country: "US",
    language: "en"
);

var me = await player.Me();
await player.PutUserData("save_state", new { chapter = 3 });
await player.RefreshIfNeeded();
```

The existing `Core.Users.StartGuest`, `Core.Users.LoginCustom`, and `Core.Users.LoginSocial` APIs remain supported. `PlayerSession` removes repeated access-token plumbing and gives you one place to refresh tokens with `RefreshIfNeeded`.

## Request IDs

The SDK sends SDK version, runtime, trace ID, and request ID with requests. Use these values when checking logs or contacting support.

```cs theme={null}
await HyperX.Core.Init(new HyperXInitOptions
{
    ProjectCode = "PROJECT_CODE",
    TraceId = "game-boot",
    RequestId = Guid.NewGuid().ToString("N")
});
```

If you do not provide them, the SDK generates request IDs automatically.
