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:
- GET /health — Health check endpoint. GET is correct.
- POST /api/v1/events — Event ingestion endpoint. If you monitor this with GET, you'll get a 404 or 405. Monitor it with POST and a sample payload.
- HEAD / — For monitoring that you want to be as lightweight as possible. HEAD requests return headers without a body, so they're faster and use less bandwidth than GET.
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:
- Expect 200, not just "2xx". A 204 (No Content) might indicate a problem in an endpoint that should always return data. A 201 (Created) from a GET endpoint is unusual. If you know the endpoint always returns 200 when healthy, assert specifically for 200.
- Authentication endpoints may legitimately return 401. If you're monitoring a login endpoint without credentials, a 401 is the correct response — the endpoint is working. Don't mark it as down just because it rejected unauthenticated monitoring requests.
- Redirect handling. If your endpoint redirects (301/302) to HTTPS or to a canonical URL, configure your monitor to follow redirects and assert 200 on the final URL rather than flagging the redirect itself as a failure.
- Maintenance mode. Some applications return 503 during planned maintenance with a specific response body. Consider whether you want monitoring to alert on 503, or treat it as a known state when you've enabled maintenance mode.
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 endpoint | 200ms | 500ms |
| Read API (GET list/detail) | 500ms | 1500ms |
| Write API (POST/PUT) | 800ms | 2000ms |
| Search / complex query | 1000ms | 3000ms |
| File upload / processing | 3000ms | 10000ms |
| Authentication (login) | 500ms | 1500ms |
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:
- Authentication flow: If login is broken, no user can access your service. High priority.
- Core API actions: Whatever your users do most — creating records, submitting forms, querying data. If these fail, users can't use your product.
- Payment and billing endpoints: A broken checkout is immediate revenue loss. Monitor with short check intervals.
- Webhooks and integrations: If you send data to customer systems via webhooks, monitor that the endpoint is responding correctly.
- Background job health: Use PingBase heartbeat monitors to verify that cron jobs and background workers are running on schedule.
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 Health | GET | 200 | "status":"ok" | 500ms |
| Login endpoint | POST | 401 | — | 1000ms |
| User data API | GET | 200 | "data": | 800ms |
| Webhook delivery | POST | 200 | — | 2000ms |
| Nightly job | Heartbeat | — | — | — |
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 →