How to use curl to check if service is down?

Anthony Ettinger <[email protected]> Sat, 25 Jun 2022 01:40:01 -0700
Newsgroups gmane.comp.monitoring.monit.general
Message-ID <CAD56wZNBM8QM7Kxbi6Ym5-M=gR86HjZRkd7Q4W+G81iWrcEx3g@mail.gmail.com>
 want to use monit and curl so that curl would hit and api and check if its
up, if it gets a 502 or similar error then restart the systemd service.

How would I do this?