> For the complete documentation index, see [llms.txt](/llms.txt).

- Snap

# snap_getState

Get the state of the Snap, or a specific value within the state. By default, the data is automatically encrypted using a Snap-specific key and automatically decrypted when retrieved. You can set `encrypted` to `false` to use unencrypted storage (available when the client is locked).

## Parameters[​](#parameters "Direct link to Parameters")

object

An object containing the parameters for the `snap_getState` method.

### key

string

The key of the state to retrieve. If not provided, the entire state is retrieved. This may contain Lodash-style path syntax, for example, `a.b.c`, with the exception of array syntax.

### encrypted

boolean

Whether to use the separate encrypted state, or the unencrypted state. Defaults to the encrypted state. Encrypted state can only be used if the client is unlocked, while unencrypted state can be used whether the client is locked or unlocked.

Use the encrypted state for sensitive data (such as private keys or secrets), and the unencrypted state for non-sensitive data that needs to be accessed while the client is locked.

## Returns[​](#returns "Direct link to Returns")

JSON

The state of the Snap. If a key was provided in the request parameters, this is the value of that key in the state. Otherwise, this is the entire state.

## Example

- Manifest
- Usage

```
{
  "initialPermissions": {
    "snap_manageState": {}
  }
}

```

```
const state = await snap.request({
  method: 'snap_getState',
  params: {
    key: 'some.nested.value', // Optional, defaults to entire state
    encrypted: true, // Optional, defaults to `true`
  },
})

```
