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

# useRequestUnvault

> Ask for a vaulted item back: the owner's wallet sends the request to unvault, and the waiting period starts.

```ts theme={null}
function useRequestUnvault(): {
  requestUnvault: (args: { requestId: string }) => Promise<WalletSubmission>;
  status: "idle" | "pending" | "success" | "error";
  data: WalletSubmission | null;
  error: Error | null;
  reset: () => void;
};
```

`requestUnvault({ requestId })` waits for the wallet and sends the owner's
request to unvault from it, with the cost covered by Endstate. It resolves
once the network included the send. It needs no tap session, only a wallet
that holds the item now: the vault holds the item, so its owner cannot tap it.
`requestId` is the `id` of the vault request
[`useVault`](https://docs.endstate.io/sdks/web/reference/react/useVault) opened, which your server
kept.

The waiting period starts once Endstate sees the send. Nothing else is asked
of the owner: the vault records the item's dispatch with its own tap and
Endstate completes the unvault.

## Example

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

// requestId is the id vault() returned, kept by your server.
function UnvaultButton({ requestId }: { requestId: string }) {
  const { requestUnvault, status, error } = useRequestUnvault();
  if (status === "success") return <p>We asked the vault for your item.</p>;
  return (
    <>
      <button
        disabled={status === "pending"}
        // `error` shows a refusal, so the click drops the rejection.
        onClick={() => requestUnvault({ requestId }).catch(() => {})}
      >
        Send this item back to me
      </button>
      {error && <p role="alert">{error.message}</p>}
    </>
  );
}
```

## Outcome

The hook holds the outcome of its latest call, and `data.resourceId` names the
vault request that outcome is for. On a page that shows several vaulted items,
render one component per item with `key={requestId}`, so each item has its own
outcome.

The outcome belongs to the wallet that sent it and to the sign-in. Another
wallet, a sign-out, a sign-in or `reset()` returns the hook to `"idle"`. A new
tap does not, because an unvault takes no tap.

## Returns

**requestUnvault** `(args: \{ requestId: string \}) =\> Promise\<WalletSubmission\>`

Resolves with `{ transactionHash, address, resourceId }`. Rejects with
`submission.not_executable` when an unvault is already under way or
finished, with `unvault.in_progress` while an earlier unvault is still
settling (retry after `error.details.retry_at`), and with `auth.forbidden`
when this wallet does not hold the item.

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

The outcome of the latest call for the current wallet and sign-in.

**data** `WalletSubmission | null`

The latest request the wallet sent. `data.resourceId` is the vault request
it was sent for.

**error** `Error | null`

The failure that moved `status` to `"error"`. A refusal is an
[`EndstateWalletError`](https://docs.endstate.io/sdks/web/reference/wallet/EndstateWalletError) with
the API's `code` and `details`.

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

Returns the hook to `"idle"`.


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