> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.instabase.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.instabase.com/_mcp/server.

# Using user-defined functions

> Leverage user-defined functions in the flow editor.

Enterprise Single-tenant

Extend flows with custom Python user-defined functions (UDFs). Learn to use map and reduce processing functions, lifecycle hooks, reusable functions, and shared packages.

## Creating UDFs

Create a UDF module from the modules panel, generate the scripts folder, and edit `scripts.py` in the built-in editor. This overview covers how UDFs register into the flow and the main UDF types you'll use in later videos.

## Map & reduce UDFs

* **Map UDFs** -- Process one document at a time in parallel for throughput. Each call receives an `input_record` with metadata, content, and output naming.

* **Reduce UDFs** -- Aggregate outputs across preceding files into consolidated batch results.

## Pre-flow & post-flow UDFs

This tutorial shows how to use lifecycle hooks to run Python code at the start and end of a flow. It covers using pre-flow hooks to prepare inputs, post-flow hooks to export verified results, and platform decorators to register hooks for use in the flow editor.

## Reusable functions

This tutorial shows how to work with document and platform libraries inside UDFs. It covers loading OCR documents, reading and modifying text, records, layouts, metadata, and fields, registering reusable functions, and using tools for logging, file operations, and runtime configuration. It also explains how available tools differ between map UDFs and Refiner modules.

## Using Marketplace

This video shows how to package helper functions for reuse across projects. It covers defining `package.json` metadata, publishing the package to the catalog, and using it as shared steps or libraries in other projects.

## Related documentation

* [Working with flows](/flow/working-in-flow-editor)

* [Flow step reference](/flow/step-config-reference)

* [Using custom functions (UDFs)](/flow/using-custom-functions)