Setting values for multi-select property using notion-py library

I’m working on a Discord bot that saves data to Notion using the notion-py library and discord.py. I’ve successfully connected to my Notion workspace using token_v2 and can create new rows, but I’m having trouble with multi-select columns.

def create_notion_entry():
    page_collection = client.get_collection_view(database_urls[current_type])
    new_row = page_collection.collection.add_row()
    new_row.url_field = stored_url
    new_row.title_field = stored_title
    
    if current_type == 1:
        new_row.category_field = stored_category
        tag_list = stored_tags.split(',')
        for single_tag in tag_list:
            # Need to populate multi-select field here
            populate_multi_select_field("Labels", single_tag)
    else:
        new_row.type_field = stored_category

I found a function online for handling multi-select fields:

available_styles = ['blue_tag', 'green_tag']

def populate_multi_select_field(column_name, tag_value, color=None):
    if color is None:
        color = choice(available_styles)
    
    schema_data = page_collection.collection.get(["schema"])
    column_schema = next(
        (val for key, val in schema_data.items() if val["name"] == column_name), None
    )
    
    if not column_schema:
        raise ValueError(f'Column "{column_name}" not found!')
    
    if column_schema["type"] != "multi_select":
        raise ValueError(f'"{column_name}" is not multi-select!')
    
    existing_option = next(
        (opt for opt in column_schema["options"] if opt["value"] == tag_value), None
    )
    
    if existing_option:
        raise ValueError(f'Tag "{tag_value}" already exists!')
    
    column_schema["options"].append(
        {"id": str(uuid1()), "value": tag_value, "color": color}
    )
    
    collection.set("schema", schema_data)

But this gives me an error: “Not allowed to edit column: schema”. How can I properly set multi-select values in notion-py?

You’re getting that schema error because you’re trying to modify the database structure instead of just setting values on existing options. Don’t create new options dynamically - work with the multi-select options that already exist in your Notion database. Here’s how I handle multi-select fields in my notion-py projects:

# First, get existing multi-select options from your database
schema = page_collection.collection.get_schema_properties()
labels_property = schema['Labels']
available_options = [opt['value'] for opt in labels_property['options']]

# Then set the multi-select field directly
tag_list = stored_tags.split(',')
valid_tags = [tag.strip() for tag in tag_list if tag.strip() in available_options]
new_row.Labels = valid_tags

The key difference: you’re assigning a list of strings that match existing option values, not trying to create new schema options. Make sure your tag values exactly match the option names in your Notion database - case sensitivity matters.

Schema modification won’t work with notion-py - it’s blocked by permission restrictions. Don’t try creating new multi-select options programmatically. Instead, just add all your multi-select options in Notion first, then reference them by exact values.

I hit this same problem building a content management system. The fix is way simpler than that complex function you found. Just assign multi-select values directly:

def create_notion_entry():
    page_collection = client.get_collection_view(database_urls[current_type])
    new_row = page_collection.collection.add_row()
    new_row.url_field = stored_url
    new_row.title_field = stored_title
    
    if current_type == 1:
        new_row.category_field = stored_category
        tag_list = [tag.strip() for tag in stored_tags.split(',')]
        new_row.Labels = tag_list  # Direct assignment

Make sure your tag_list values exactly match the option names you manually created in Notion. The notion-py library handles everything else without schema manipulation.

Yeah, notion-py can’t modify schema permissions - super common issue. Don’t bother with the populate function, just set values on existing options. I create all my multi-select tags in Notion first, then reference them like new_row.label_field = ["tag1", "tag2"]. Way less headache than dealing with schema restrictions.