Add custom field to a nextgen project via the API

When using the UI it is possible to pick an existing custom field or create a new one and add it to an issue type screen.
Is it also possible to do it via the API?

I’ve managed to do the equivalent for a classic project but when trying for a nextgen project I receive an error saying that it can’t find the projectId.

For the classic project I was able to use
to achieve this.

Is there a workaround for nextgen projects?