A website up or down api answers one simple question: does this site respond right now? A good one also tells you where time is spent, so you can tell a slow server from a DNS or certificate problem. This guide shows how to use one from an AI agent or a script, and what to do with the answer.
The same check is useful for a person, a monitoring job or an agent that needs to confirm a page is reachable before it reads it.
Why "is it down?" is a security question too
Most outages are ordinary: a server restart, a full disk, a bad deploy. But some have a security side, and the first sign is often a site that stops answering.
- An expired certificate makes browsers and tools refuse the connection, even though the server is running.
- A changed DNS record can send visitors to the wrong server. That can be a mistake, or a sign someone has taken over the domain account.
- A lapsed domain registration takes the site and its e-mail down together.
- A flood of traffic can make a site slow or unreachable.
- A defaced or hacked site may still answer, but with the wrong status code or a redirect you did not set.
A check that shows each step of the connection helps you tell these apart.
What a website up or down check should return
A plain yes or no is not enough. Look for a check that reports:
- Status code. 200 means the page loaded. Codes in the 300s are redirects, 400s point to a missing page or a block, and 500s point to a server error.
- DNS time. How long it took to find the server's address. A failure here points to DNS, not the server.
- TCP time. How long it took to open a connection to the server.
- TLS time. How long the secure handshake took. A failure here often points to the certificate.
- Time to first byte (TTFB). How long the server took to start replying. A slow reply usually points to the application or database.
With these, an agent can say more than "down". It can say "DNS lookup failed" or "the server answered with an error".
Calling the check from an agent or script
An agent or script can run the same kind of check you would run in a browser, and then parse the timings. You do not need a special account to fetch a page over HTTPS and record the status code and how long each step took.
A simple pattern is to run a small up-or-down check first. It tells you if the site answers at all, and it should return the DNS, TCP, TLS and TTFB timings described above. If the site is up but something looks odd, such as a new redirect, follow up with a closer look at the page, the certificate and the security headers.
Give the script a place to save each result with a timestamp. Compare a new failure with the last good run before you raise an alarm.
Reading the result and acting on it
Give your agent or script a few simple rules, so a result turns into an action.
- DNS step fails. Check the domain's DNS records and registration. Confirm nobody changed them without telling you.
- TLS step fails. Check the certificate's expiry date and the names it covers.
- Server answers with a 500 error. Check the application logs and any recent deploy.
- Unexpected redirect or status. Open the page by hand. If it shows content you did not publish, treat it as a possible break-in.
- Slow time to first byte. Look at server load and the database before you blame the network.
Check from more than one place before you raise an alarm. A single failed call can be a passing network fault. Two or three failed calls a minute apart are a stronger signal.
Related checks when an outage has a cause
An up or down check reports what it sees at the moment it runs. It does not prove a site is free of problems.
If outages keep pointing at certificates or headers, read Security Headers Explained and Is My Website Safe?. The guide Free Website Security Check shows a short manual pass.