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

# Secrets

Read a secret from a secret store while your automation runs. Intuned resolves the reference with your Project's credentials for the store. Your code gets the secret's value but never sees the credentials.

```typescript theme={null}
import { withoutTracing } from "@intuned/runtime";
import { resolveSecret } from "@intuned/runtime/secrets";

await withoutTracing(async () => {
  const password = await resolveSecret("op://Portal/Login/password");
  await page.getByLabel("Password").fill(password);
});
```

## Supported stores

The reference's scheme picks the store.

| Store | Reference | Setup |
| - | - | - |
| 1Password | `op://<vault>/<item>/<field>` | [1Password integration](https://intunedhq.com/docs/main/04-integrations/1password.md). AuthSessions don't have to be enabled. |

## Available helpers

* [`resolveSecret`](#resolvesecret) — Read a secret from a secret store
* [`isSecretReference`](#issecretreference) — Check that a string is a supported secret reference

## Function reference

### resolveSecret

```typescript theme={null}
import { resolveSecret } from "@intuned/runtime/secrets";

type SecretReference = `op://${string}/${string}/${string}`;

function resolveSecret(reference: SecretReference): Promise<string>;
```

Resolves a secret reference and returns its value. Each call reads from the store again.

> [!WARNING]
>
> **Call it inside [`withoutTracing`](https://intunedhq.com/docs/main/05-references/runtime-sdk-typescript/pause-tracing).** On a traced Run, calling it outside a `withoutTracing` block throws, so the secret can't be captured by the browser trace, a screenshot, or an automation log. On a Run that isn't traced, the block isn't required.

**Parameters**

**reference** `SecretReference` *required*

The secret reference. For 1Password, a [secret reference](https://developer.1password.com/docs/cli/secret-reference-syntax/): `op://<vault>/<item>/<field>`, or `op://<vault>/<item>/<section>/<field>`, optionally followed by a query such as `?attribute=otp`.

The type is checked at compile time. A string literal that isn't a supported reference, such as `"op://vault"`, doesn't compile. A `string` variable has to be narrowed first with [`isSecretReference`](#issecretreference).

**Returns**

Returns the secret's value as a `string`.

**Throws**

* An `Error` if the Run is traced and no `withoutTracing` block is open.
* A `TypeError` if `reference` isn't a supported secret reference.
* `SecretResolveError` if the secret can't be read. This happens when the store's integration isn't enabled, its credentials are missing or can't read the item, or the machine running the Run doesn't answer in time. The message names the reference, never the secret.

> [!NOTE]
>
> For 1Password, every call counts toward your service account's [rate limits](https://developer.1password.com/docs/service-accounts/rate-limits/). Resolve a secret once per Run and reuse it rather than calling it in a loop.

### isSecretReference

```typescript theme={null}
import { isSecretReference } from "@intuned/runtime/secrets";

function isSecretReference(value: unknown): value is SecretReference;
```

Returns `true` if `value` is a supported secret reference. Use it to pass a reference that arrives as a `string`, such as a Run parameter:

```typescript theme={null}
import { NonRetryableError, withoutTracing } from "@intuned/runtime";
import { isSecretReference, resolveSecret } from "@intuned/runtime/secrets";

export default async function login(params: { passwordRef: string }, page: Page) {
  if (!isSecretReference(params.passwordRef)) {
    throw new NonRetryableError("passwordRef must be a secret reference");
  }
  const passwordRef = params.passwordRef;
  await withoutTracing(async () => {
    await page.getByLabel("Password").fill(await resolveSecret(passwordRef));
  });
}
```

## Related

* [1Password integration](https://intunedhq.com/docs/main/04-integrations/1password.md): Set up the vault, the service account, and the token.
* [Pause tracing](https://intunedhq.com/docs/main/05-references/runtime-sdk-typescript/pause-tracing.md): Control what gets recorded around a sensitive step.
* [Ephemeral parameters](https://intunedhq.com/docs/main/05-references/runtime-sdk-typescript/ephemeral-parameters.md): For a secret that belongs to a single Run.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.