Setting values for multi-select property using Notion API with notion-py

I’m building a Discord bot that creates entries in Notion using the notion-py library. Everything works fine except for one issue - I can’t figure out how to properly populate a multi-select column.

Here’s my current setup:

def create_notion_entry():
    view = client.get_collection_view(database_url[current_type])
    new_row = view.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 called "Labels"
            set_multiselect_option("Labels", single_tag)

I found a helper function online but it throws an error:

def set_multiselect_option(property_name, option_value):
    schema = view.collection.get(["schema"])
    property_config = next(
        (v for k, v in schema.items() if v["name"] == property_name), None
    )
    
    if property_config["type"] != "multi_select":
        raise ValueError(f"Property {property_name} is not multi-select")
    
    property_config["options"].append({
        "id": str(uuid1()),
        "value": option_value,
        "color": "default"
    })
    
    collection.set("schema", schema)  # This line fails

The error message says “Not allowed to edit column: schema”. How can I properly assign values to a multi-select column in Notion using the notion-py library?

You’re overcomplicating this. With notion-py, just assign values directly to the multi-select property - don’t mess with the schema. Your set_multiselect_option function is causing the error because the API doesn’t let you modify schemas. Just do: new_row.labels_field = tag_list where tag_list is your string array. Here’s the catch though - every value you’re assigning must already exist as an option in your Notion database’s multi-select field. I learned this the hard way building automated workflows. You need to either add all possible tag values to your Labels field in Notion first, or add error handling to catch missing tags and skip them.

you don’t need to modify the schema! just assign values directly to the multi-select field: new_row.labels_field = tag_list where tag_list is your string array. notion-py handles everything automatically if the options already exist in your database.

You’re trying to create new options in the schema instead of assigning existing values. The notion-py library doesn’t let you modify schemas through the API - that’s why you’re getting the error. Make sure all your multi-select options already exist in your Notion database first, then just assign them: new_row.labels_field = tag_list. If some options don’t exist, add them manually in the Notion interface before your bot tries to use them. I hit this exact problem building my content management system - wasted hours trying to add options programmatically before realizing I just needed to pre-populate them in Notion.