How/When Private Tenants are created?

Hi Guys,

Can anyone explain me how and when private tenants are created? For example, I create a Internal User. The private Tenant for this user only are created on first login into kibana. I’ve tried to understand the code but I only found some headers validations, and not the creation.

My goal is pre-index the user private tenant, like, index patterns, visualizations and dashboads.