> For the complete documentation index, see [llms.txt](https://docs.seabed.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seabed.so/open-source-primitives/pre-authorized-debit-v1/program/instructions/init-pre-authorization.md).

# Init Pre Authorization

[Github Source](https://github.com/seabed-labs/pre-authorized-debit/blob/main/programs/pre-authorized-debit-v1/src/instructions/init_pre_authorization.rs)

```rust
#[instruction(params: InitPreAuthorizationParams)]
pub struct InitPreAuthorization<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    pub owner: Signer<'info>,

    #[account(
        seeds = [
            b"smart-delegate",
        ],
        bump = smart_delegate.bump,
    )]
    pub smart_delegate: Account<'info, SmartDelegate>,

    #[account(
        mut,
        has_one = owner @ CustomProgramError::InitPreAuthorizationUnauthorized
    )]
    pub token_account: InterfaceAccount<'info, TokenAccount>,

    #[account(
        init,
        space = 8 + PreAuthorization::INIT_SPACE,
        seeds = [
            b"pre-authorization",
            token_account.key().as_ref(),
            params.debit_authority.as_ref(),
        ],
        bump,
        payer = payer,
    )]
    pub pre_authorization: Account<'info, PreAuthorization>,

    pub token_program: Interface<'info, TokenInterface>,

    pub system_program: Program<'info, System>,
}

pub struct InitPreAuthorizationParams {
    pub variant: InitPreAuthorizationVariant,
    pub debit_authority: Pubkey,
    pub activation_unix_timestamp: i64,
}
```

This instruction can be used to create a [Pre Authorization account](/open-source-primitives/pre-authorized-debit-v1/program/account-model/pre-authorization.md) that represents a pre-authorization between a token account and a debit authority (authorized signer for debits via the pre-auth).

The token account's owner at the time of creation of this pre-auth has to sign for this instruction. This instruction also sets the delegate of the token account to the Smart Delegate for reasons mentioned [here](/open-source-primitives/pre-authorized-debit-v1/program/account-model/smart-delegate.md).

The caller can specify the variant (recurring or one-time) via the instruction params.

If you wish to change any of the configuration's in a pre-authorization, please close it via the [close IX](/open-source-primitives/pre-authorized-debit-v1/program/instructions/close-pre-authorization.md) and recreate it via this instruction.

More in-depth information can be found [here](https://github.com/seabed-labs/pre-authorized-debit/blob/main/programs/pre-authorized-debit-v1/src/instructions/init_pre_authorization.rs).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.seabed.so/open-source-primitives/pre-authorized-debit-v1/program/instructions/init-pre-authorization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
