I used the same controller that handles the normal localization request with URL (/api/:entity/:id/localizations) to create my localization from code. You can access it with the strapi.controller function like this:
await strapi.controller(`api::${entity}.${entity}`).createLocalization(ctx)
This is how I added the data for new localization and :id from URL, which is the entry in main locale:
ctx.params.id = mainLocale.id;
ctx.request.body = newEntity;
newEntity is just an object with translated (or not) data, but make sure to add ‘locale’ entry to it before creating the localization.