Code steps are a way to extend Zapier to run small snippets of Python or JavaScript as part of your Zaps. This tutorial is for Python Code steps, but you can read about JavaScript code steps here.
Code steps can be used as both triggers and actions.
Python is an advanced programming language. If you're not familiar with using Python, it's recommended to ask a developer for help. Zapier does not offer email support for code steps. If you run into trouble, we recommend asking questions on StackOverflow and tagging them with "Zapier".
For tips and inspiration, check out Python code examples.
The environment is vanilla Python 3.7.2 (2.7.10 for Zaps made before 2019-01-24). Your script is sandboxed and can only run for a limited amount of time and within a limited amount of memory—the exact limits are based on plan level. If you exceed those limits, your script will be stopped.
In your code step, you have access to the input_data
dictionary variable, where all values will be strings. Since the amount of data that might feed into your script might be large or highly dynamic you'll need to define an input_data
mapping via our GUI by providing a key and value.

Mapping input_data
is not available in triggers.
Code steps return a single output
variable, which is a dictionary or list of dictionaries that will be the "return value" of this code. You can explicitly return early if you like. This 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 your Code step is the Zap's trigger and an empty list is returned, nothing happens. You can think of it like a polling trigger that did not get any results in the HTTP response. This functionality is exclusive to triggers—returning an empty list in a code step action does not have the same effect.
Note: you may see old code examples using input
which we changed to input_data
to reduce confusion. Both work but we prefer the less confusing input_data
since input
was a built in function for Python.
There are a few utilities you have access to:
Running your zap via the dashboard is the canonical way to confirm the behavior you expect. Your Task History will have all relevant details around the ran code's input_data
, output
and logs. The test step in the editor can be used for a tighter feedback loop.
If you have a python code step that returns a value like this
return {'result': 1.0}
it may appear as 1, rather than 1.0, in your Task History and test results. This is an artifact of the Zapier UI. The Zapier web UI does not distinguish between int and float values; they are all just numbers. In your Python code step you can use int(aNumber)
or float(aNumber)
to make sure to convert the value to the data type you require.