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

# Remove a role

> Revoke a role's access without moving the wallet's assets.

## Introduction

Removing a role revokes its authority, permissions, and any session attached to that role.

* **Use when:** a user disconnects an app, rotates service access, or withdraws a delegated permission set.
* **For:** apps that let administrators manage wallet access.

## How it works

1. Fetch the wallet and choose the exact role ID to revoke.
2. Authorize with an administrator that has `All` or `ManageAuthority`.
3. Submit the removal and wait for confirmation.
4. Refetch the wallet and verify that the role is absent.

## Removal rules

* Root role `0` cannot be removed; use [Recovery](https://build.onswig.com/solana/use-cases/recovery.md) to replace a protected key.
* Close any live V1 subaccounts attached to the target role before removing it.
* Keep at least one administrator with `All` or `ManageAuthority`; removal cannot leave the wallet without one.
* Active authorization locks must be captured, released, or expired before removal.
* Other roles belonging to the same signer remain active.
* Assets stay at the wallet address.

## SDK example

Supply an Ed25519 administrator and the target role's on-chain ID. The administrator pays the fee in this example.

```typescript theme={null}
import {
  type Connection,
  type Keypair,
  type PublicKey,
  Transaction,
  sendAndConfirmTransaction,
} from "@solana/web3.js";
import { fetchSwig, getRemoveAuthorityInstructions } from "@swig-wallet/classic";

async function removeRole(
  connection: Connection,
  configAddress: PublicKey,
  admin: Keypair,
  adminRoleId: number,
  roleToRemoveId: number,
) {
  const swig = await fetchSwig(connection, configAddress);
  const instructions = await getRemoveAuthorityInstructions(
    swig,
    adminRoleId,
    roleToRemoveId,
    { payer: admin.publicKey },
  );
  const signature = await sendAndConfirmTransaction(
    connection,
    new Transaction().add(...instructions),
    [admin],
    { commitment: "confirmed" },
  );
  const updated = await fetchSwig(connection, configAddress, {
    commitment: "confirmed",
  });
  if (updated.findRoleById(roleToRemoveId)) {
    throw new Error("Role is still present after confirmation");
  }
  return signature;
}
```


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