> ## 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.

# useVault

> Ask to vault the tapped item: the owner's wallet signs the approval for the vault useCanVault named, and the vault request opens pending.

```ts theme={null}
function useVault(): {
  vault: (args: { vaultId: string }) => Promise<VaultRequest>;
  status: "idle" | "pending" | "success" | "error";
  data: VaultRequest | null;
  error: Error | null;
  reset: () => void;
};
```

`vault({ vaultId })` waits for the wallet, has it sign the owner's approval for
that vault through the Endstate wallet frame, and opens the request with the
active tap session (`POST /v1/units/{unit_id}/vault-requests`). Pass the id
[`useCanVault`](https://docs.endstate.io/sdks/web/reference/react/useCanVault) returned: the SDK never
picks a vault for the owner, and Endstate refuses one the brand does not allow.

## Example

```tsx theme={null}
"use client";
import { useCanVault, useVault } from "@endstate-sdk/web/react";

function VaultButton() {
  const { data: eligibility } = useCanVault();
  const { vault, status, data } = useVault();
  if (data) return <p>Vault request {data.status}.</p>;
  if (!eligibility?.vaultable || !eligibility.vault) return null;
  return (
    <button
      disabled={status === "pending"}
      onClick={() => vault({ vaultId: eligibility.vault!.id })}
    >
      Vault this item with {eligibility.vault.name}?
    </button>
  );
}
```

## Returns

**vault** `(args: \{ vaultId: string \}) =\> Promise\<VaultRequest\>`

Resolves with the request, `pending` until the vault confirms it has the item,
once [`useCanVault`](https://docs.endstate.io/sdks/web/reference/react/useCanVault) names it as
`requestId`. Throws when there is no active tap session.

**status** `"idle" | "pending" | "success" | "error"`

The outcome of the latest call for the current tap, wallet and sign-in. A new
tap, another wallet, a sign-out or a sign-in returns it to `"idle"`.

**data** `VaultRequest | null`

The request the latest call opened. Its `id` is what
[`useCancelVault`](https://docs.endstate.io/sdks/web/reference/react/useCancelVault) takes.

**error** `Error | null`

The failure, such as `vault.not_permitted`, `vault.in_progress` or a
`wallet.*` code from the wallet.

**reset** `() =\> void`

Returns the hook to `"idle"`; a call still in flight no longer lands.


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