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

# secretKey

> Narrows an environment value to a secret key. `process.env.X` is `string | undefined`, and the client wants the `end_sk_` prefix proved, so this is the bridge: it turns a missing or wrong-prefixed key into a startup failure that names the problem, instead of a 401 on the first call.

```ts theme={null}
secretKey(value: string | undefined | null): EndstateSecretKey
```

## Example

```ts theme={null}
const endstate = new EndstateClient({
  apiKey: secretKey(process.env.ENDSTATE_API_KEY),
});
```
