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

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Revoke Abandoned Delegations And Subscriptions

> Guide for reclaiming rent from a delegation or subscription whose Subscription Authority is gone.

Delegations and subscriptions hold rent that normally returns to their recorded
payer on revoke. If a sponsor funded the account and the user later closes or
replaces their Subscription Authority, the account is stranded and its rent
stuck. `RevokeAbandonedDelegation` and `RevokeAbandonedSubscription` let the
recorded payer reclaim it.

To run these snippets on a local network, first
[set up a local environment](/developers/docs/payments/subscriptions/overview#set-up-a-local-environment).

## When It Applies

Allowed only when the account's Subscription Authority is provably terminal —
closed, or closed and recreated (so `init_id` no longer matches). A live
delegation or subscription can never be closed this way.

|                                  | `RevokeAbandonedDelegation`                                                                                     | `RevokeAbandonedSubscription`                                                                                                      |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Closes                           | Fixed or recurring delegation PDA                                                                               | Subscription PDA                                                                                                                   |
| Signer                           | Recorded payer                                                                                                  | Recorded payer                                                                                                                     |
| Accounts                         | Delegation + recorded authority                                                                                 | Subscription + recorded authority + plan                                                                                           |
| Eligible when                    | Authority closed, or recreated (`init_id` mismatch)                                                             | Same, for the plan's mint — the mint is read from the bound plan, so an unrelated authority cannot be substituted to force a close |
| Use ordinary revoke instead when | Delegation is [expired or fully spent](/developers/docs/payments/subscriptions/recurring-delegation#revoke-the-delegation) | Subscription is [cancelled and expired](/developers/docs/payments/subscriptions/subscription-plan#cancel-and-revoke)                          |

`RevokeAbandonedDelegation` is also the recorded payer's only recovery path for
a never-expiring delegation (`expiry_ts == 0`) that isn't fully spent: ordinary
revoke fires for the payer only on expiry or, for a fixed delegation, full
spend.

## Revoke An Abandoned Delegation

The recorded payer signs. Pass the dead delegation PDA and its recorded
Subscription Authority (which may already be closed). Rent returns to the payer.

<Tabs>
  <Tab title="TypeScript">
    ```ts
    import { getRevokeAbandonedDelegationInstruction } from '@solana/subscriptions';

    // Build the instruction and send it in a transaction like any other.
    const revokeAbandonedIx = getRevokeAbandonedDelegationInstruction({
      payer: payerSigner,
      delegationAccount: delegationPda,
      subscriptionAuthority: subscriptionAuthorityPda,
    });
    ```

  </Tab>

  <Tab title="Rust">
    ```rust
    use solana_address::{address, Address};
    use subscriptions::generated::instructions::*;

    let payer: Address = address!("PAYER_THAT_FUNDED_RENT_HERE");
    let delegation_pda: Address = address!("DELEGATION_PDA_ADDRESS_HERE");
    let subscription_authority: Address = address!("RECORDED_SUBSCRIPTION_AUTHORITY_HERE");

    let revoke_abandoned_ix = RevokeAbandonedDelegationBuilder::new()
        .payer(payer)
        .delegation_account(delegation_pda)
        .subscription_authority(subscription_authority)
        .instruction();
    ```

  </Tab>
</Tabs>

## Revoke An Abandoned Subscription

The recorded payer signs. Pass the abandoned subscription PDA, its recorded
Subscription Authority (which may already be closed), and the plan the
subscription belongs to. Rent returns to the payer.

<Tabs>
  <Tab title="TypeScript">
    ```ts
    import { getRevokeAbandonedSubscriptionInstruction } from '@solana/subscriptions';

    // Build the instruction and send it in a transaction like any other.
    const revokeAbandonedIx = getRevokeAbandonedSubscriptionInstruction({
      payer: payerSigner,
      subscriptionAccount: subscriptionPda,
      subscriptionAuthority: subscriptionAuthorityPda,
      planPda,
    });
    ```

  </Tab>

  <Tab title="Rust">
    ```rust
    use solana_address::{address, Address};
    use subscriptions::generated::instructions::*;

    let payer: Address = address!("PAYER_THAT_FUNDED_RENT_HERE");
    let subscription_pda: Address = address!("SUBSCRIPTION_PDA_ADDRESS_HERE");
    let subscription_authority: Address = address!("RECORDED_SUBSCRIPTION_AUTHORITY_HERE");
    let plan_pda: Address = address!("PLAN_PDA_ADDRESS_HERE");

    let revoke_abandoned_ix = RevokeAbandonedSubscriptionBuilder::new()
        .payer(payer)
        .subscription_account(subscription_pda)
        .subscription_authority(subscription_authority)
        .plan_pda(plan_pda)
        .instruction();
    ```

  </Tab>
</Tabs>

## Notes

- The recorded payer signs, not the delegator, delegatee, or subscriber.
- Both instructions fail if the Subscription Authority is still live for the
  account — use ordinary revoke instead.
- `RevokeAbandonedDelegation` works for both fixed and recurring delegations.
