After over a decade of navigating the fast-paced world of MOPs, I’ve learned the hard way that documentation, especially for Marketo forms, often takes a backseat amidst more pressing priorities.

But the reality is, documenting forms in Marketo is absolutely essential when it comes to audits, inventory management, and ensuring compliance with internal and external regulations.

However, manually documenting each form’s fields, validation rules, and configurations can be incredibly time-consuming and prone to errors.

That is exactly what this guide aims to address.

We’ll walk you through a streamlined, automated approach to documenting Marketo forms using API and Python so you can save time and reduce errors – freeing you up to focus on driving impactful marketing strategies.

Who is this guide for?

If you’re already familiar with using the Marketo API, you’ll find this guide immensely helpful.

We’ll provide you with a Python script that automates the extraction and documentation of form fields directly from Marketo, saving you hours of manual work.

Not familiar with the Marketo API?

For those who aren’t as comfortable with the Marketo API or scripting in Python, don’t worry—we’re here to help. Our team can assist you with your project, ensuring your forms are documented correctly and efficiently. You can book a free 30-minute chat with an expert here to get started.

Alternatively, if you’re keen on learning how to do this yourself, we highly recommend signing up for the API Crash Course course offered by Tyron Pretorious on The Workflow Pro blog. This course will equip you with the knowledge and skills to leverage the Marketo API for various automation and integration tasks.

Our Step-By-Step Guide

The script we provide leverages the Marketo API to fetch form fields and then formats this data into a neatly organized Excel file, with each form’s fields documented in a separate tab.


  • Marketo API access with client_id and client_secret.
  • Python installed on your system.
  • marketorestpython and pandas Python packages installed. You can install these via pip:
pip install marketorestpython pandas openpyxl


The Script (Python):

from marketorestpython.client import MarketoClient
import pandas as pd

# Marketo Credentials
munchkin_id = ""  # fill in Munchkin ID
client_id = ""  # enter Client ID
client_secret = ""  # enter Client Secret
api_limit = None
max_retry_time = None
requests_timeout = (3.0, 10.0)

# Initialize Marketo Client
mc = MarketoClient(munchkin_id, client_id, client_secret, api_limit, max_retry_time, requests_timeout=requests_timeout)

# List of form IDs to process
form_ids = [1000, 1001, 1002]  # Add form IDs here as integers

# Initialize Excel writer
excel_filename = 'marketo_form_fields.xlsx'
writer = pd.ExcelWriter(excel_filename, engine='openpyxl')

for form_id in form_ids:
    # Retrieve fields for the current form
    fields = mc.execute(method='get_form_fields', id=form_id, status=None)

    # Create a DataFrame from the fields
    if fields:
        data = []
        for field in fields:
            if 'fieldMetaData' in field and 'values' in field['fieldMetaData']:
                picklist_options = "; ".join([f"{opt['label']} ({opt['value']})" for opt in field['fieldMetaData']['values']])
                picklist_options = ''
                'ID': field.get('id', ''),
                'Label': field.get('label', ''),
                'Data Type': field.get('dataType', ''),
                'Validation Message': field.get('validationMessage', ''),
                'Required': field.get('required', False),
                'Form Prefill': field.get('formPrefill', False),
                'Visibility Rules': field.get('visibilityRules', {}).get('ruleType', ''),
                'Hint Text': field.get('hintText', ''),
                'Max Length': field.get('maxLength', ''),
                'Picklist Options': picklist_options,
        df = pd.DataFrame(data)

        # Use form ID as sheet name for now
        sheet_name = str(form_id)
        df.to_excel(writer, index=False, sheet_name=sheet_name[:31])  # Excel sheet name has a max of 31 characters

# Save the Excel workbook
print(f"Excel file '{excel_filename}' has been created successfully.")

How to Use the Script:

1) Fill in Your Credentials: Replace the placeholder values for munchkin_id, client_id, and client_secret with your actual Marketo API credentials.

# Marketo Credentials
munchkin_id = ""  # fill in Munchkin ID
client_id = ""  # enter Client ID
client_secret = ""  # enter Client Secret


2) Specify Form IDs: In the form_ids list, replace the example IDs with the IDs of the forms you want to document.

# List of form IDs to process
form_ids = [1000, 1001, 1002]  # Add form IDs here as integers


3) Run the Script: Execute the script in your Python environment. The script will communicate with the Marketo API, retrieve the specified forms’ fields, and output the information into an Excel file named marketo_form_fields.xlsx. Here’s what that file should look like:

4) Review Your Documentation: Open the generated Excel file to review your forms’ documentation. Each tab within the workbook corresponds to a different form, named using the form’s ID.

pink line

By automating the documentation of Marketo forms, you can significantly reduce the time and effort required for audits and inventories. This not only improves accuracy but also allows you to allocate your valuable time to more strategic tasks.

If you encounter any challenges or have questions about customizing the script for your specific needs, don’t hesitate to reach out for professional assistance. As mentioned earlier, you can book a free consultation with one of our experts here.