Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • Built-in tools
  • Functions
  • Create a function

Write code in Zapier Functions

Written by Owner

Updated at August 20th, 2025

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Tables
    Work with tables Manage tables Create tables Troubleshoot Zapier Tables
  • Product updates
    Product updates: January 2023 Product updates: March 2023 Product updates: February 2023 Product updates: April 2023 Product updates: May 2023 Product updates: June 2023 Product updates: July 2023 Product updates: August 2023 Product updates: September 2023 Product updates: October 2023 Product updates: November 2023 Product updates: December 2023 Product updates: January 2024 Product updates: February 2024 Product updates: March 2024 Product updates: April 2024 Product updates: May 2024 Product updates: June 2024 Product updates: July 2024 Product updates: August 2024 Product updates: September 2024 Product updates: October 2024 Product updates: November 2024 Product updates: December 2024 Product updates: January 2025 Product updates: February 2025 Product updates: March 2025 Product updates: April 2025 Product updates: May 2025 Product updates: June 2025 Product updates: July 2025 Product updates: August 2025
  • Zaps
    Zap basics Zap history Troubleshoot Zaps Manage your Zaps Do more with Zaps
  • Your Zapier account
    Plans Billing Account profile Notifications Data privacy & security Get help User roles and permissions
  • Interfaces
    Troubleshoot Zapier Interfaces Create an interface Use interface components Manage interfaces
  • Canvas
    Create a canvas Collaborate on a canvas
  • Chatbots
    Add logic and knowledge to chatbots Troubleshoot chatbots Create chatbots Manage chatbots
  • Getting started
    Intro to Zapier Set up your Zapier account Use case templates
  • Agents
    Create agents Manage agents Troubleshoot agents
  • MCP
    Set up MCP
  • Built-in tools
    Filter & Paths Formatter Schedule & Delay Email, IMAP, SMTP, & Email Parser Webhooks & Code Storage, Digest, & RSS Sub-Zap & Looping Other built-in tools Custom Actions & API Requests Functions AI by Zapier & AI actions Copilot Human in the Loop
  • Lead Router
    Create routers
  • Apps
    Connect and manage your app connections AI apps on Zapier Apps on Zapier
+ More

Table of Contents

Working with the main.py file Add actions to your code Reference trigger outputs Debug and inspect data Create and use other code files Use Python packages Provide feedback and get help

With Zapier Functions, you have one main Python file that is run whenever your triggers have new output. You can also create multiple Python code files to separate and organize your functions. 

miscBoltAlt icon Beta

This product is in open beta. It’s available for use but still in active development and may change.

Working with the main.py file

The main.py file is added automatically when you create a new function. When your functions are deployed, this is the file that runs whenever your trigger events occur. You can reference trigger fields in it, import common Python packages, and reference other code files you create. You cannot delete this file.

Add actions to your code

You can add actions from any public Zapier app to your code. To insert a new action into your code:

  1. In any line of your code file, start typing zapier.action. to display a list of available apps in a dropdown menu. You can continue typing to find the one you want. To select the app, press the Enter or Tab key.
  2. Enter a period to see the dropdown menu of available actions.
  3. Select the action and press the Enter or Tab key. The account_id field will be added to the code.
  4. Move the cursor to the account_id field and press the CTRL + Space keys to display a list of existing connections.
  5. Start typing the connection's name to filter the list. You can also add a new connection.
  6. Once the connection is done, the code will populate the parameters for that action, and you can insert variables or references to trigger outputs.
ratingStar icon Tip
  • You can use CTRL + Space with most parameters to see if Zapier has auto-complete options to help you set up your action.
  • You can change the CTRL + Space hotkey in the code editor settings.
  • To find a private app, select Search all apps and enter the search term in the dialog box that will open.

    Screen Shot 2025-07-08 at 5.12.02 PM.png

Reference trigger outputs

While you edit a code file, you can reference the output from any of your trigger files. To reference a trigger output field:

  1. On the right sidebar, click the Selected trigger dropdown menu.
  2. Select the trigger output you want to reference in your code.
  3. In the code editor, start typing zapier.trigger_output. to display a dropdown menu with available fields.
  4. Move through the list and press the Enter or Tab key to select a field.
ratingStar icon Tip

Use Tab to autocomplete the suggestions that appear while you type in the code editor.

Debug and inspect data

When you run your functions, you can add a print() statement to output and inspect the data that passed through the function, such as action responses. This allows you to test and debug your code. You can also view logs for all function runs and tests.

Create and use other code files

You can create separate code files to organize Python functions and then reference them in your main.py file.

To add a new code file:

  1. On the left sidebar, click the Explorer icon .
  2. In the CODE FILES section, click the plus sign +.
  3. In the text field that appears, enter the file name and press Enter.
  4. Import the new file into your main.py file so it can be run.

 

actionEdit icon Example

You create a file called "new_file.py" with a function called hello. You can import the whole file by adding the following to your main.py file:

Import new_file

Then, call the hello function by typing:

new_file.hello()

Or, you can import only the hello function from your file by adding the following:

from new_file import hello

Then you can use the function anywhere on your code by typing:

hello()

Use Python packages

You can also use most common Python packages with Zapier Functions by referencing them on your file, using import <package_name>. You can change which version you use from the Packages menu.

 Learn how to import and change package versions.

Provide feedback and get help

Submit a feature request, provide feedback on existing features, or get help from the Zapier Functions team. You can also discuss Functions with other users on Zapier's Early Access Program Slack.

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Create a workflow using Python with Functions
  • Create trigger events for your functions
  • Import packages in Zapier Functions
  • Use secrets in Zapier Functions
  • Error handling in Zapier Functions

Copyright 2025 – OBZ-Zapier.

Knowledge Base Software powered by Helpjuice

Expand