# Cloud Archive Quickstart

## Prerequisites

1. The main `cn.indiegp.sdk.unity` package is installed.
2. This `cn.indiegp.sdk.unity.cloud-archive` package is installed.
3. `IGPConfig.appId` is configured.
4. The game is attached to Desktop and Desktop reports `cloudArchive`.

## Load

```csharp
using IGP.UnitySDK.CloudArchive;

var result = await IGPCloudArchive.LoadCloudArchiveAsync(
    runtimeManager,
    IGPCloudArchive.Slot1);

var data = result.data;
var version = result.version;
```

## Save

```csharp
var save = await IGPCloudArchive.SaveCloudArchiveAsync(
    runtimeManager,
    IGPCloudArchive.Slot1,
    "{\"hp\":10}",
    new IGPCloudArchiveSaveOptions
    {
        baseVersion = version,
    });

version = save.version;
```

Omit `baseVersion` only when creating a slot for the first time.

## Conflict

```csharp
try
{
    await IGPCloudArchive.SaveCloudArchiveAsync(
        runtimeManager,
        IGPCloudArchive.Slot1,
        serializedSave,
        new IGPCloudArchiveSaveOptions { baseVersion = version });
}
catch (IGPCloudArchiveException ex) when (ex.HttpStatus == 409 || ex.ApiCode == 10005)
{
    var currentVersion = ex.Conflict?.currentVersion;
    // Reload, reconcile, then save again.
}
```

## Slot Rules

Slots are fixed save slots, not file names. Use one of:

- `IGPCloudArchive.Slot1`
- `IGPCloudArchive.Slot2`
- `IGPCloudArchive.Slot3`
- `IGPCloudArchive.Slot4`
- `IGPCloudArchive.Slot5`
