How to create Custom Endpoints with an API?

Hi

I've created custom endpoints for my ECE cluster via the Cloud UI using the guidance here:

However in future I'd like to use an API call, or some other programmatic method (writing config files directly?). Can someone advise me or point me in the direction of documentation about how to set up custom endpoints programmatically rather than via the Cloud UI? There doesn't seem to be any mention of this way of doing things via the link above.

Many thanks

RIchard