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

# Hooks Reference

> A generated reference of all hooks and filters available in Anki for add-on development.

This page lists all available hooks in Anki. It is generated from [`pylib/tools/genhooks.py`](https://github.com/ankitects/anki/blob/main/pylib/tools/genhooks.py) and [`qt/tools/genhooks_gui.py`](https://github.com/ankitects/anki/blob/main/qt/tools/genhooks_gui.py).

See [Hooks & Filters](https://docs.ankiweb.net/addons/hooks-and-filters.md) for usage instructions.

## Backend Hooks (`anki.hooks`)

### `card_odue_was_invalid`

No arguments.

No docstring.

***

### `schema_will_change`

**Args:** `proceed: bool`\
**Returns:** `bool`

No docstring.

***

### `notes_will_be_deleted`

**Args:** `col: anki.collection.Collection`, `ids: Sequence[anki.notes.NoteId]`

No docstring.

***

### `note_will_be_added`

**Args:** `col: anki.collection.Collection`, `note: anki.notes.Note`, `deck_id: anki.decks.DeckId`

Allows modifying a note before it's added to the collection.

This hook may be called both when users use the Add screen, and when
add-ons like AnkiConnect add notes. It is not called when importing. If
you wish to alter the Add screen, use gui\_hooks.add\_cards\_will\_add\_note
instead.

***

### `media_files_did_export` *(Obsolete)*

**Args:** `count: int`

> [!WARNING]
>
> Obsolete, do not use.

***

### `legacy_export_progress` *(Obsolete)*

**Args:** `progress: str`

> [!WARNING]
>
> Obsolete, do not use.

***

### `exporters_list_created`

**Args:** `exporters: list[tuple[str, Any]]`

No docstring.

***

### `media_file_filter`

**Args:** `txt: str`\
**Returns:** `str`

Allows manipulating the file path that media will be read from

***

### `field_filter`

**Args:** `field_text: str`, `field_name: str`, `filter_name: str`, `ctx: anki.template.TemplateRenderContext`\
**Returns:** `str`

Allows you to define custom `{{filters:..}}`

Your add-on can check filter\_name to decide whether it should modify
field\_text or not before returning it.

***

### `note_will_flush`

**Args:** `note: Note`

Allow to change a note before it is added/updated in the database.

***

### `card_will_flush`

**Args:** `card: Card`

Allow to change a card before it is added/updated in the database.

***

### `card_did_render`

**Args:** `output: anki.template.TemplateRenderOutput`, `ctx: anki.template.TemplateRenderContext`

Can modify the resulting text after rendering completes.

***

### `importing_importers` *(Obsolete)*

**Args:** `importers: list[tuple[str, Any]]`

> [!WARNING]
>
> Obsolete, do not use.

***

### `deck_added` *(Obsolete)*

**Args:** `deck: anki.decks.DeckDict`

> [!WARNING]
>
> Obsolete, do not use.

***

### `note_type_added` *(Obsolete)*

**Args:** `notetype: anki.models.NotetypeDict`

> [!WARNING]
>
> Obsolete, do not use.

***

### `sync_stage_did_change` *(Obsolete)*

**Args:** `stage: str`

> [!WARNING]
>
> Obsolete, do not use.

***

### `sync_progress_did_change` *(Obsolete)*

**Args:** `msg: str`

> [!WARNING]
>
> Obsolete, do not use.


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