502 error from my cloudflare website

Cloudflare in most cases is not a host, but instead a content delivery network sitting in front of your real (origin) web server, providing cache and other functionality. In this case specifically, Cloudflare cannot host PHP, so you will need to reach out to your real host about this issue.
There is a community tip here for resolving 502 errors as well:

If you do not know who your real host is, you can head to the DNS Tab of Cloudflare, find the DNS Record for the API subdomain (shown as just API), and perform a lookup on that IP, using a service like https://who.is/.