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

# Create Subscription Authority

> Guide for initializing a user's Subscription Authority account.

A Subscription Authority is a PDA that the program uses as the SPL Token
delegate for one user's token account and one token mint. Create it before
creating fixed delegations, recurring delegations, or subscription plan
subscriptions for that mint.

The user's token account must already exist. Initialization creates the
Subscription Authority PDA and approves it as the token delegate on the user's
token account.

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

## Create The Authority

<Tabs>
  <Tab title="TypeScript">
    ```ts
    import { address, createClient } from '@solana/kit';
    import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
    import { signer } from '@solana/kit-plugin-signer';
    import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';
    import {
      fetchMaybeSubscriptionAuthority,
      findSubscriptionAuthorityPda,
      subscriptionsProgram,
    } from '@solana/subscriptions';

    const client = createClient()
      .use(signer(userSigner))
      .use(solanaLocalRpc({ rpcUrl: 'http://127.0.0.1:8899' }))
      .use(subscriptionsProgram());

    const tokenMint = address('TOKEN_MINT_ADDRESS_HERE');
    const [userAta] = await findAssociatedTokenPda({
      mint: tokenMint,
      owner: userSigner.address,
      tokenProgram: TOKEN_PROGRAM_ADDRESS,
    });

    const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda({
      user: userSigner.address,
      tokenMint,
    });

    const subscriptionAuthority = await fetchMaybeSubscriptionAuthority(
      client.rpc,
      subscriptionAuthorityPda,
    );

    if (!subscriptionAuthority.exists) {
      await client.subscriptions.instructions
        .initSubscriptionAuthority({
          tokenMint,
          tokenProgram: TOKEN_PROGRAM_ADDRESS,
          userAta,
        })
        .sendTransaction();
    }
    ```

  </Tab>

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

    const SYSTEM_PROGRAM_ID: Address = address!("11111111111111111111111111111111");
    const TOKEN_PROGRAM_ID: Address = address!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");

    let user: Address = address!("USER_WALLET_ADDRESS_HERE");
    let user_ata: Address = address!("USER_TOKEN_ACCOUNT_ADDRESS_HERE");
    let token_mint: Address = address!("TOKEN_MINT_ADDRESS_HERE");

    let (subscription_authority, _) = Address::find_program_address(
        &[b"SubscriptionAuthority", user.as_ref(), token_mint.as_ref()],
        &SUBSCRIPTIONS_ID,
    );

    let init_ix = InitSubscriptionAuthorityBuilder::new()
        .owner(user)
        .subscription_authority(subscription_authority)
        .token_mint(token_mint)
        .user_ata(user_ata)
        .system_program(SYSTEM_PROGRAM_ID)
        .token_program(TOKEN_PROGRAM_ID)
        .instruction();
    ```

  </Tab>
</Tabs>

## Notes

- The user signs the initialization transaction.
- Create one Subscription Authority per user and token mint pair.
- Reuse the existing Subscription Authority for later delegations on the same
  mint.
- A sponsor can fund the account: pass an optional `payer` to
  `initSubscriptionAuthority` (also supported on `createFixedDelegation`,
  `createRecurringDelegation`, and `subscribe`), or configure one with
  `.use(payer(sponsorSigner))`. Rent then returns to that sponsor when you close
  with a matching `receiver`. Omit it for the self-funded default.
- Close the Subscription Authority only after every delegation that depends on
  it has been revoked or closed.
