← Blog
Developer Guide 10 min read

How to Monitor Your API Endpoints

Pinging a URL and checking for a 200 is a start. But real API monitoring means validating the right HTTP method, asserting specific status codes, setting response time thresholds, and checking that the response body contains what you expect.

Most developers start API monitoring the same way: add a health check endpoint (GET /health), point a monitoring tool at it, and call it done. That catches the obvious case — the server is completely unreachable — but misses a large class of real-world failures.

A proper API monitoring setup checks more than availability. This guide covers the full picture: HTTP methods, status code assertions, response time thresholds, content validation, and how to configure each in PingBase.


1. Use the right HTTP method

Most monitoring tools default to GET. GET is correct for most health check endpoints, but if you're monitoring a specific API endpoint, use the method that endpoint actually responds to.

Common cases:

In PingBase, you set the HTTP method when creating a monitor. The default is GET, but you can choose GET, HEAD, POST, PUT, PATCH, or DELETE depending on what your endpoint expects.

Example: monitoring a POST endpoint

Method: POST
URL: https://api.yourapp.com/v1/ping
Headers: Content-Type: application/json
Body: {"source": "monitoring"}

When monitoring POST endpoints, send a minimal, safe payload. Ideally have a dedicated monitoring path in your API that accepts the check without creating real data — a /health/ping that accepts POST but just returns 200 without side effects.


2. Assert the right status code

The default monitoring behavior is: 2xx = up, anything else = down. This is wrong for a lot of APIs.

Status code behavior you should actually configure:

PingBase lets you specify the exact expected status code when creating a monitor. You can also configure whether redirects should be followed before the check.


3. Set response time thresholds

An API that takes 10 seconds to respond is broken, even if it returns 200. Response time monitoring is how you catch performance degradation before it causes timeouts and failures in production.

Recommended thresholds by endpoint type:

Endpoint type Warning threshold Critical threshold
Health check endpoint200ms500ms
Read API (GET list/detail)500ms1500ms
Write API (POST/PUT)800ms2000ms
Search / complex query1000ms3000ms
File upload / processing3000ms10000ms
Authentication (login)500ms1500ms

These are starting points — calibrate against your own baselines. If your search endpoint typically responds in 200ms, a 1000ms warning threshold won't catch meaningful degradation. Set thresholds relative to your actual p95 response times, not arbitrary round numbers.

In PingBase, you configure a response time threshold per monitor. When the response time exceeds the threshold, the monitor enters a "slow" state and triggers alerts — the same alert channels as a down alert, but with a different message so you can distinguish performance issues from outages.


4. Validate response content

A 200 response with an error body is still a failure. This happens more often than you'd think: a server returns 200 with a JSON body of {"error": "database connection failed"}, a CDN serves a cached 200 response for a page that's actually broken, a load balancer returns its own 200 health page when your app is down behind it.

Content validation checks that the response body contains what you expect. The two most common approaches:

String match

Assert that the response body contains a specific string. For a JSON health endpoint, you might check for "status":"ok". For an HTML page, check for a string that only appears when the page is rendering correctly — a product name, a specific heading, or content from the database.

Example health response

{"status": "ok", "db": "connected", "version": "1.4.2"}

Assert body contains: "status": "ok"

Negative match

Assert that the response body does not contain a specific string. Useful for catching error states: ensure the response doesn't contain "error", "exception", or "Internal Server Error".

PingBase supports keyword assertions on monitor checks — you can specify a string that the response body must contain for the check to pass. Configure this in the monitor settings alongside the HTTP method and status code assertion.


5. Use custom headers for authenticated endpoints

Many API endpoints require authentication headers. You have two approaches:

Dedicated monitoring API key. The better approach: create a read-only API key specifically for monitoring. This key has minimal permissions, only enough to hit the health check endpoint. If it's exposed, the blast radius is small.

Monitor a public endpoint. If your API has any public endpoint (a status endpoint, a public list, a /ping route), monitor that instead of authenticated routes. Less configuration, no secrets in your monitoring settings.

In PingBase, you can add custom headers to any monitor — useful for Authorization: Bearer <token> or API key headers like X-API-Key: <key>. Header values are stored encrypted and not exposed in the UI after saving.


6. Monitor the endpoints that matter most

Not all API endpoints are equally critical. Prioritize monitors based on business impact:


Putting it together: a complete API monitoring setup

Here's what a well-monitored API looks like in practice. For a typical SaaS API you'd set up something like this:

Monitor name Method Expected status Content check Slow threshold
API HealthGET200"status":"ok"500ms
Login endpointPOST4011000ms
User data APIGET200"data":800ms
Webhook deliveryPOST2002000ms
Nightly jobHeartbeat

This covers the important cases: the server is running, the auth system is responding (even if it rejects the unauthenticated check), the data API is returning real data, webhooks are being accepted, and background jobs are completing on schedule.

With PingBase you'd set up all five of these monitors, connect them to a public status page, and configure alert channels (email on free tier, Slack/Discord/webhook on Pro). The whole setup takes about 15 minutes.

Start monitoring your API

PingBase supports HTTP method selection, status code assertions, response time thresholds, and content validation. Free for up to 5 monitors.

Get started free →

Related