The Code block lets you write your own Python in a workflow when the ready-made blocks can't do what you need, such as a calculation, text formatting, or reshaping data from a previous step. You bind values from earlier steps as inputs and name the results you want to pass on. Your code runs in its own isolated environment, so your monday.com credentials stay protected.
Add a Code block
1Select the + where you want the step, choose Action, and select Code.
2Under Input, bind the values you need from earlier steps.
3Under Code, write your Python.
4Under Output, select Add output, name each result, and choose its type.
Inputs and outputs
When you bind a value from an earlier step, the block names it after that step's field plus the step number. For example, a Board ID field from step 1 becomes board_id_1, and your code reads it as input["board_id_1"]. Under Rename inputs, you can give any input a more readable name.
Each output has a name and a type: string, number, boolean, or array. Whatever your code produces under those names becomes available to every block that runs after the Code block.
What you can use it for
Reshape JSON from another block
Blocks that call an AI agent or an MCP-connected tool often return JSON that isn't in the shape the next step needs, with nested fields, arrays to filter, or keys to rename. Bind that output as an input, write a few lines of Python to pull out or reformat what you need, and pass a clean result forward. For example, if a block returns a list of tickets and your next step needs only the customer names for open tickets from gold-tier customers, one Code block can do it instead of several filter and branch blocks. Declare the list of names as an output, and the next block can use it.
Add custom logic
Use it for calculations, string formatting, date math, and conditional logic that would take many chained no-code blocks to express.
Call the monday.com API
Your code can call the monday.com API directly, and you don't need to supply an API token yourself. monday.com handles authentication automatically for code running inside a Code block. For example, you can take a board ID as an input and return the board's name and item names as outputs.
Available Python packages
Beyond the Python standard library, such as re, json, os, math, datetime, and collections, these packages are preinstalled and ready to import with no setup:
- pandas and numpy for data manipulation and numerical work, including pandas support for reading and writing .xlsx, .xls, .ods, and .xlsb files
- matplotlib and pillow for plotting and image handling
- requests and httpx for HTTP requests, such as calls to the monday.com API
- psutil and ipython for process and introspection utilities
Limits
Code blocks are built for quick transformation logic, not long-running jobs.
| Limit | Detail |
|---|---|
| Code length | 20,000 lines in the editor. Lines beyond that aren't saved. |
| Inputs and outputs | Up to 30 bound inputs and 30 declared outputs per block. |
| Run time | 5 minutes. If your code hasn't finished by then, the run stops and the block fails. |
| Code size | 1 MB (1,048,576 bytes) per block. This is the size of the code, not the data it processes. |
| Network access | The monday.com API only. Your code can't call any other host. |
| Secrets | You can't store API keys or credentials in a Code block. Pass sensitive values in as an input from another step. |
| State | Every run starts fresh. Data doesn't persist between runs. |
When something goes wrong
If your code fails because of an error, bad input, or a non-zero exit, the run history shows that the Code block failed, along with an error message that describes what happened. Use the message to find and fix the issue in your code.
Security
Each time your code runs, it gets its own temporary, isolated environment that's destroyed right after the run. Nothing persists, and no other run can see into it. By default your code has no general internet access, and the only place it can reach is the monday.com API. Your monday.com credentials never enter your code or the environment. They're attached securely to the request as it leaves for monday.com's servers.
FAQs
If you have any questions, please reach out to our team right here. We’re available 24/7 and happy to help.