Key Capabilities
Python 3.13
Write and run Python code in a secure environment.
Use Workflow Data
Read data from earlier steps and pass results to later steps.
Custom Logic
Do calculations, transformations, validations—anything you can code.
Call APIs
Connect to services not supported by integrations or External Service.
When to Use It
Use Opus Code when you need to do something that other tasks can’t handle. Common examples:- Transform data into a different format
- Calculate values or run business logic
- Clean up messy data before using it
- Call an API that isn’t supported by the Integration Marketplace or External Service task
- Validate that data matches what you expect
Keep your code simple and focused. If you need to do multiple things, use multiple Opus Code tasks instead of a big one—it’s easier to debug.
Reading and Writing Data
Your code can read data from earlier steps and pass results to later steps using a special syntax:Working with Files
Inside an Opus Code task, anOpus object is pre-defined and ready to use—no import needed. Use it to work with files in Opus storage: download an existing file, create a new one, and upload results back to storage so later steps can use them.
All file operations live under Opus.file:
Opus.file.download(url)— fetch a file from Opus storage by URL, returning anOpusFileyou can read and modify locally.Opus.file.create(name, type)— create a new emptyOpusFileof a given type (for example"CSV"or"PDF").Opus.file.upload(file)— upload anOpusFileback to storage and get a new file URL.
Opus.file.presigned_download(url) (for a temporary download link) and the read/write methods on the returned OpusFile (such as read_text, write_text, read_bytes, write_bytes, and open) round out the API.
Downloaded files are modified locally only. Changes aren’t saved back to Opus storage until you call
Opus.file.upload, which creates a new file and returns a new URL—the original remote file is never modified.OpusFile interface and error handling), and Working with File Formats for per-format recipes covering CSV, XLSX, PDF, DOCX, and more.
Supported Packages
Opus Code comes with these Python packages pre-installed. See Available Packages for the complete, up-to-date list.How to Add Opus Code
1
Drop it into your workflow
Drag an Opus Code task into your workflow.
2
Set up your inputs
Add input variables and connect them to data from earlier steps.
3
Write your code
Write your Python code in the editor. Read inputs and assign values to outputs.
4
Set up your outputs
Add output variables that later steps can use.
5
Test it
Run a preview to make sure your code works with real data.
Tips for Better Results
Keep it simple
Keep it simple
One task, one job:
- Do one focused thing per Opus Code task
- Use multiple small tasks instead of one big one
- Easier to debug when something goes wrong
Check your inputs first
Check your inputs first
Validate data at the start of your code:
- Make sure required fields exist
- Check that data is the type you expect
- Handle empty or missing data gracefully
Handle errors
Handle errors
Plan for things going wrong:
- Use try/except to catch errors
- Set an error output so later steps know something failed
- Write clear error messages
Test with preview
Test with preview
Before activating your workflow:
- Run preview with realistic test data
- Check that outputs look correct
- Try edge cases to make sure your code handles them
Related
Opus SDK
Work with files in Opus storage using the pre-defined
Opus object.Working with File Formats
Per-format recipes for CSV, XLSX, PDF, DOCX, and more.
Available Packages
Browse the full list of Python packages you can import.
External Service
Call external APIs without writing code.
Opus Agent
Use AI to handle tasks instead of writing code.
Custom Agent
Get structured outputs from an LLM.
Workflows
Learn how all the pieces fit together.
Builder
Design, configure, and test your workflow in the visual editor.