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
  • Webhooks & Code
  • Code

Use Python code in Zaps

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

1. Add a code trigger 2. Set up your code step 3. Test your code trigger 1. Add a code action 2. Set up your code action 3. Test your code action The Python environment Input data for Code steps Output data from code steps Utilities in Code steps Testing and debugging Code steps Limitations with Code steps How floats and integers are handled

Code steps allow Zaps to run small snippets of Python or JavaScript. This tutorial is for Python code steps, but you can also learn how to use JavaScript code in your Zaps.

Code steps can be used as both triggers and actions.

miscEye icon Note

Python is an advanced programming language.

  • If you're not familiar with Python, you should ask a developer for help.
  • If you require assistance with how Code by Zapier processes code (not writing or debugging), contact Support based on your plan.
  • For additional resources, visit the Zapier Community's Code resources.
Code trigger Code action

1. Add a code trigger

  • In the Zap editor, click the Trigger step.
  • Search for and select Code by Zapier.
  • Click the Event dropdown menu and select Run Python.
  • Click Continue.

2. Set up your code step

  • In the Code field, enter your Python code.
  • Click Continue.

3. Test your code trigger

  • Click Test trigger.

If your code is valid, the step will show it was successful and display the data. Once the trigger is set up, you can continue to add your action step.

1. Add a code action

The Code action step allows you to write code that interacts with data coming from the trigger or a previous action step.

  • In the Zap editor, click the + icon to add a new step.
  • Search for and select Code by Zapier.
  • Click the Event dropdown menu and select Run Python.
  • Click Continue.

2. Set up your code action

  • In the Code field, enter your Python code.
    • You can also define data fields to be provided to the code as strings with the Input Data fields. Provide a key and a value for each field.
  • Click Continue.

3. Test your code action

  • Click Test step.
  • If your code is valid, the step will show it was successful and display the data sent.

The Python environment

The environment is vanilla Python 3.7.2 (2.7.10 for Zaps created before January 24, 2019). Your script is sandboxed and can only run for a limited amount of time and within a limited amount of memory—the exact limits depend on your Zapier plan.

miscEye icon Note

Dates and times in Code actions use the UTC timezone, even if a different one is set for the account or the Zap.

Input data for Code steps

Access data from previous steps within your code steps using the  inputData dictionary. The amount of data that may feed into your script may be large or dynamic. To address this, you must define a inputData mapping by providing a key and value in Zapier's GUI.

Mapping fields from previous Zap steps in the Code field is not supported. You must use the inputData dictionary.

Create a key/value pair in the Input Data field for each mapped field you want to use in your code.

In Python, access the values within the inputData dictionary using the input_data['keyName'] notation. Key names are case-sensitive and must be an exact match for successful data retrieval.

actionEdit icon Example

In the example below, the key name is "name" and the value is supplied by the Name field that's mapped from a previous step. In this example, the value supplied by the mapped Name field is "Erin".

The field `defineName` defined on the `inputData` dictionary, based on trigger data.

miscEye icon Note

It's not possible to map inputData in Code by Zapier triggers.

Output data from code steps

Code steps return a single output variable, which is a dictionary or list of dictionaries that will be the result of this step.

  • You can explicitly return early.
  • The output must be JSON serializable.
  • Setting the output to a list of dictionaries will run the subsequent steps multiple times, once for each item in the list.

If you use Code by Zapier as the Zap's trigger and an empty array is returned, nothing will happen. The behavior will be similar to a polling trigger that did not get any results in the HTTP response. This functionality is exclusive to triggers.

Utilities in Code steps

There are a few utilities available in Code steps:

  • requests: an easy-to-use HTTP client.
  • StoreClient : a built-in utility for storing and retrieving data between Zap runs.
  • print: this utility allows you to debug your function. You'll need to test your Zap to see the values. The logs are returned in a runtime_meta added automatically to the output.
  • BeautifulSoup: for parsing HTML and XML content.

Testing and debugging Code steps

Running your Zap via the dashboard is the canonical way to confirm the behavior you expect. Your Zap History will have all relevant details around the Code step's input_data, output and logs. The test step in the editor can be used for a tighter feedback loop.

Limitations with Code steps

  • Code steps include the standard library, the requests packages, and the BeautifulSoup library. You cannot install additional libraries or pip modules directly.
  • There are different Code rate limits and throttling, depending on what plan you’re on. Your Zap will error if it exceeds these limits.
  • If you need to make more than 2 HTTP requests or make authenticated HTTP requests, Zapier recommends creating a custom app on the Zapier platform.

How floats and integers are handled

The Zapier web UI does not distinguish between integers and float values—they are all presented as numbers. For example, if your Python code step returns a value like this:

return {'result': 1.0}

This may appear as 1, rather than 1.0, in your Zap history and test results. This is an artifact of the Zapier UI. You can use int(aNumber) or float(aNumber) in your Python code step to convert the value to the data type you require.

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Generate a Code step using AI (Beta)
  • Code by Zapier rate limits
  • JavaScript code examples in Zaps
  • Python code examples in Zaps
  • Store data from code steps with StoreClient

Copyright 2025 – OBZ-Zapier.

Knowledge Base Software powered by Helpjuice

Expand