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

# useCancelUnvault

> Cancel a waiting unvault from the owner's wallet, so the item stays vaulted.

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

`cancelUnvault({ requestId })` waits for the wallet and sends the owner's
cancel of a waiting unvault from it, with the cost covered by Endstate. It
resolves once the network included the send, and the item stays vaulted. It
needs no tap session, only a wallet that holds the item now.

The owner can cancel while the unvault waits, including while it is on hold.
Once the item is ready to ship the call rejects with
`submission.not_executable`, and `error.details.cancellable_at` is the time a
cancel opens again if the vault has not dispatched the item: 7 days after the
waiting period ended. It is present only while the item is ready to ship and
not dispatched.

## Example

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

// requestId is the id vault() returned, kept by your server.
function KeepInVaultButton({ requestId }: { requestId: string }) {
  const { cancelUnvault, status, error } = useCancelUnvault();
  return (
    <>
      <button
        disabled={status === "pending" || status === "success"}
        // `error` shows a refusal, so the click drops the rejection.
        onClick={() => cancelUnvault({ requestId }).catch(() => {})}
      >
        Keep this item in the vault
      </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

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

Resolves with `{ transactionHash, address, resourceId }`. Rejects with
`submission.not_executable` when no unvault is waiting or the item is ready
to ship, 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 cancel 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.