Migrating > 2k white label domains to Matomo

hi community,

i want to track > 2k domains from a whitelabel system with matomo.
The question is, how can i setup a tracking for this domains without having to add every domain manually in the matomo admin interface?

All domains are hosted on the same serve / ip and i can link the tracking codes for each domain via database to the frontend.

Should i look into the database structure and write a script or is there a better way?

Thanks for your hints

Maybe i posted this question under the wrong topic?