# Group state backup

Export and restore encrypted private group device state.

[Read the shared private collections guide](/docs/groups/). Signatures below come from the published SDK declarations. Access SDK services through `db`; use their constructors only when integrating at a lower level.

## GroupStateBackupEntry


```ts
interface GroupStateBackupEntry {
  key: string;
  value: string;
}
```

## GroupStateBackup


```ts
interface GroupStateBackup {
  format: "nostrbase-group-state";
  version: 1;
  namespace: string;
  account: string;
  device: string;
  entries: GroupStateBackupEntry[];
  checksum: string;
}
```

## GroupStateBackupImport


```ts
interface GroupStateBackupImport {
  imported: number;
  skipped: number;
}
```

## exportGroupStateBackup


```ts
/** Export encrypted Marmot state without exposing plaintext MLS material. */
declare function exportGroupStateBackup(
  adapter: GroupStateAdapter,
  namespace: string,
  account: string,
  device: string,
): Promise<GroupStateBackup>;
```

## importGroupStateBackup


```ts
/** Import encrypted state for the same account, namespace, and stable device ID. */
declare function importGroupStateBackup(
  adapter: GroupStateAdapter,
  archive: GroupStateBackup | string,
  namespace: string,
  account: string,
  device: string,
): Promise<GroupStateBackupImport>;
```
