See https://developers.cloudflare.com/ssl/ssl-for-saas/hostname-specific/custom-metadata/ for reference.
Here is a cURL example:
$ curl -sXPATCH "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames/{hostname_id}"\
-H "X-Auth-Email: {email}" -H "X-Auth-Key: {key}"\
-H "Content-Type: application/json"\
-d '{"ssl":{"method":"http","type":"dv"},"custom_metadata":{"customer_id":"12345","redirect_to_https": true}}'
Note that the API documentation doesn't actually show that parameter: https://api.cloudflare.com/#custom-hostname-for-a-zone-create-custom-hostname