Overview
User-defined templates allow you to create reusable code patterns for blocks and pipelines, enabling faster development and consistent coding standards across your organization. Templates can include placeholders for customization and can be shared across projects.Block Templates
Creating block templates
Block templates are reusable code patterns that can be customized with variables. They help standardize common patterns across your organization. Steps to create a block template:- Navigate to Block templates - Click “Templates” in the left navigation menu, then open Block templates. You can also go directly to
/apps/templates/blocks. - Create new template - Click “New block template” button
- Define template properties:
- Template UUID - Enter a unique identifier (e.g.,
sql_data_loader) - Block type - Select the type (Data loader, Transformer, Data exporter, etc.)
- Language - Choose the programming language (Python, SQL, R, YAML, etc.)
- Template UUID - Enter a unique identifier (e.g.,
- Edit template content - Write the template code with placeholders
- Save template - Click “Save template” to create the template
Template UUIDs can include letters, numbers, underscores, hyphens, and folder separators (
/). They must start with a letter or number, cannot include empty, . or .. folder segments, and must be 255 characters or fewer. The block type and language are locked after the template is created.Template File Structure
When you create a block template, Mage automatically creates the following file structure:metadata.yaml- Contains template metadata, block type, language, and other configuration{template_uuid}.py- The actual template code file that users will customize
.py, SQL templates use .sql, R templates use .r, and YAML templates use .yaml.
Example structure for test_template:
Template Library Interface
The template library provides a centralized location to manage all your block and pipeline templates: Template Library Features:- Template categories - Filter templates by type (Blocks or Pipelines)
- Block template categories - Filter block templates by block type
- Team pipeline templates - Manage pipeline templates created from pipelines in your project; built-in starting points are available from the pipeline creation flow
- Pipeline template discovery - Search and filter the broader built-in catalog from New pipeline > From a template; the customization page remains focused on Team templates
- Template preview - View template details before using
- Template management - Edit, delete, or duplicate existing templates
- From left navigation - Click “Templates” to access the template library. The default Templates page redirects to the block template library at
/apps/templates/blocks. - From pipeline editor - Use “Browse templates” when adding new blocks
- From pipeline creation - Select “From a template” when creating new pipelines
- Template organization - Templates are organized by type and category for easy discovery
- Open Pipeline templates - Click the Pipelines tab in the template library or go directly to
/apps/templates/pipelines - Manage team templates - This customization page lists only reusable pipeline templates created and maintained in your Mage project
- Browse built-in starting points - From the Pipelines page, choose New pipeline, then From a template to browse Basics, General purpose, and Industry solutions alongside Team templates
- View template details - See template name, description, and metadata
- Select a team template - Click a Team template to inspect or customize it
Using block templates
Steps to use a block template:- Open pipeline editor - Navigate to the pipeline where you want to add the block
- Add new block - Click the ”+” button to add a new block
- Browse templates - Select “Browse templates” from the block creation options
- Select template - Choose the template you want to use from the available templates
- Name the block - Enter a specific name for your new block instance
- Customize as needed - Modify the generated code for your specific use case
Pipeline Templates
Built-in pipeline template catalog
Mage Pro provides three built-in sources alongside templates created by your team:- Basics are remotely provided example pipelines for learning Mage fundamentals and common block patterns.
- General purpose templates are starting points for recurring workflows such as ingestion, data quality, streaming, and AI context preparation.
- Industry solutions adapt common patterns to outcomes in areas such as retail, financial services, healthcare, manufacturing, and logistics.
General purpose and Industry solution templates are production-oriented starting points, not zero-configuration demos. Review and adapt them before using them with production data.
- Put non-sensitive settings in each block’s USER CONFIGURATION dictionary. Runtime variables can override matching lowercase settings when they must differ by run or environment.
- Put credentials in
io_config.yaml. Source and destination blocks select connections by their configured tags, so keep secrets out of block configuration and runtime variables.
- Read the overview and setup block.
- Supply the required settings and create the named connection profiles.
- Start in
dry_runmode. Loaders return a sample DataFrame and exporters skip destination writes, so you can inspect the transformation without connecting to external systems. - Turn off
dry_run, then run the blocks in order with the smallest representative input supported by the template. - Before scheduling, choose an idempotent write policy and add your organization’s monitoring, recovery, privacy, and retention controls.
MAGE_PRO_TEMPLATES_ENDPOINT and the server-side MAGE_PRO_TEMPLATES_API_TOKEN. Catalog updates do not require a new Mage image, and Mage keeps the last successfully fetched catalog available during temporary refresh failures.
Creating pipeline templates
Pipeline templates define complete pipeline structures that can be customized for different use cases. Steps to create a pipeline template:- Navigate to Team pipeline templates - Open Templates, then Pipeline templates, or go directly to
/apps/templates/pipelines. This customization page lists only templates created and maintained by your team. - Create new template from an existing pipeline - From the pipeline list, right-click the pipeline you want to reuse and select the action to create a template. This opens
/apps/templates/pipelines/new?pipeline_uuid={pipeline_uuid}. - Configure template settings - Set the template UUID, name, description, and other properties.
- Save template - The pipeline structure will be saved as a reusable template.
Pipeline template UUIDs follow the same rules as block template UUIDs: letters, numbers,
underscores, hyphens, and folder separators (
/) are allowed, the value must start with a
letter or number, . and .. folder segments are rejected, and the value must be 255
characters or fewer.Using pipeline templates
Steps to use a pipeline template:- Navigate to the pipelines page in your project
- Click “New” button to open the pipeline creation menu
- Select “From a template” from the dropdown options
- Choose a source - Start in All templates, or select Basics, General purpose, Industry solutions, or Team
- Find a template - Search the catalog or apply the filters available for the selected source
- Choose your template from the available pipeline templates
- Review the configuration guidance - For a General purpose or Industry solution template, open its first overview and setup Markdown block and supply the required credentials, identifiers, schemas, and business rules
- Customize the pipeline - Modify blocks, connections, and settings as needed
- Save the pipeline with your specific configuration
Note: Pipeline templates are created from existing pipelines using the right-click context menu. This allows you to reuse successful pipeline patterns across your projects.
Best Practices
Template design
- Keep templates focused - Each template should serve a specific purpose
- Use clear variable names - Make variable purposes obvious
- Include comprehensive documentation - Explain usage and customization options
- Test with different configurations - Ensure templates work with various inputs
- Follow coding standards - Maintain consistent style and practices
Template maintenance
- Regular updates - Keep templates current with latest Mage features
- User feedback - Collect and incorporate user suggestions
- Performance optimization - Monitor and improve template performance
- Security review - Ensure templates follow security best practices