Using API to limit who can create branches from protected branch


I’m working on automating a repository creation process. I want to have a main branch, along with a set of branches created automatically from it. I’m using python-gitlab but ofc I can use HTTP requests if needed.

My issue is that I do not want developers to be able to branch from main (i.e. they should only work on the unprotected branches, or other branches created from these). Is there a way to enforce this?

Code for clarity, not really required to understand:

    p_branch = project.protectedbranches.create({
         'name': 'main',
         'merge_access_level': gitlab.MAINTAINER_ACCESS,
         'push_access_level': gitlab.MAINTAINER_ACCESS
    for branch_name in branch_names:
         branch = project.branches.create({'branch': branch_name, 'ref': 'main'})

It would also mean this option would be disabled when trying to edit a file on the protected branch (not automatically creating this ugly branch name):