Script for basic elastic healthchecks

hello, i have a mission of creating a script for automating elastic healthchecks, can anyone who has already worked on the same topic help me please.

I guess that's what Elasticsearch monitoring does out of the box.

What is your question exactly?

I need to get the elastic stack monitoring automated is there any API's or scripts I can use for this purpose

I'd start from here: Monitor a cluster | Elasticsearch Guide [7.12] | Elastic