---
sidebar_position: 0
---

# autoRecovery

The `sos.management.autoRecovery` API provides methods for managing the auto-recovery feature of the signageOS app.

The Auto Recovery feature is designed to automatically recover the signageOS app in case of a crash or unexpected shutdown
or switching input to a different value, e.g., HDMI.

<details>
    <summary>Auto Recovery Management Capabilities</summary>
		| Capability | Description |
		|:------------|:-------------|
		| `AUTO_RECOVERY` | If the device can enable or disable the auto recovery function. |

		If you want to check if the device supports this capability, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
</details>

## Methods

### get()

The `get()` method retrieves the current auto-recovery configuration.

```ts expandable
get(): Promise<IAutoRecoveryConfiguration>;
// show-more
type IAutoRecoveryConfiguration = {
    enabled: false;
    autoEnableTimeoutMs?: number;
} | {
    enabled: true;
    healthcheckIntervalMs: number;
};

```

#### Return value

A promise that resolves to the current auto-recovery configuration.

#### Example

```ts
const autoRecoveryConfig = await sos.management.autoRecovery.get();
if (autoRecoveryConfig.enabled) {
  console.log(`Auto-recovery is enabled with a healthcheck interval of ${autoRecoveryConfig.healthcheckIntervalMs} ms.`);
}
```

<Separator />

### set()

The `set()` method allows to enable or disable the auto-recovery feature and configure its settings.

:::note
The configuration object has different properties depending on if enabled is true or false.
:::

```ts expandable
set(configuration: IAutoRecoveryConfiguration): Promise<void>;
// show-more
type IAutoRecoveryConfiguration = {
    enabled: false;
    autoEnableTimeoutMs?: number;
} | {
    enabled: true;
    healthcheckIntervalMs: number;
};

```

#### Params

| Name                                  | Type                         | Required         | Description                                                                                                 |
|---------------------------------------|------------------------------|------------------|-------------------------------------------------------------------------------------------------------------|
| `configuration`                       | `IAutoRecoveryConfiguration` |  <div>Yes</div>  | The configuration object for auto-recovery settings.                                                        |
| `configuration.enabled`               | `boolean`                    |  <div>Yes</div>  | A boolean to set auto-recovery to enabled or disabled state.                                                |
| `configuration.autoEnableTimeoutMs`   | `number`                     |  <div>No</div>   | The timeout in milliseconds after which the auto-recovery will be automatically enabled if it was disabled. |
| `configuration.healthcheckIntervalMs` | `number`                     |  <div>Yes</div>  | The interval in milliseconds for the health check if application is running in foreground.                  |

#### Return value

A promise that resolves when the auto-recovery settings are successfully set.

#### Possible errors

If the configuration is invalid.

#### Example

```ts
// Enable auto-recovery with a healthcheck interval of 5000 ms
await sos.management.autoRecovery.set({
	enabled: true,
	healthcheckIntervalMs: 5000,
});
```