JSON API Monitoring With Assertions: Validate Response Data, Not Just Status Codes
Monitorion Team
Engineering Team
Your API returns HTTP 200. Everything is fine, right? Not necessarily. The response body could contain an empty array instead of data. A critical field could be null. The pagination could be broken. An upstream dependency could be failing silently while your API dutifully returns a 200 status with an error message buried in the JSON body. Status code monitoring misses all of this. JSON API monitoring with assertions catches it.
What Are JSON Assertions?
Assertions are rules that validate the actual content of your API response. Instead of just checking "did I get a 200?", assertions let you verify:
- Field existence —
$.dataexists and is not null - Field value —
$.statusequals"active" - Array length —
$.itemshas at least 1 element - Numeric range —
$.priceis greater than 0 - String content —
$.versioncontains"v2"
Setting Up JSON API Monitoring
Go to Monitors → New Monitor → JSON API:
- URL — your API endpoint
- Method — GET, POST, PUT, PATCH, DELETE
- Headers — add Authorization headers, Content-Type, or custom headers
- Request Body — for POST/PUT/PATCH requests
- Assertions — one or more JSONPath assertions to validate the response
Assertion Examples
Health check endpoint:
URL: https://api.example.com/health
Assertion: $.status equals "ok"
Assertion: $.database equals "connected"
User listing API:
URL: https://api.example.com/users?limit=10
Assertion: $.data exists
Assertion: $.data.length > 0
Assertion: $.meta.total > 0
Payment processing:
URL: https://api.example.com/payment/status
Assertion: $.gateway equals "online"
Assertion: $.processingTime < 5000
Why This Matters
Consider an e-commerce API that returns products. One day, a database migration breaks the query. The API still returns 200 OK — but with an empty products array. Your store shows zero products. Regular HTTP monitoring says "all good." A JSON API monitor with the assertion $.products.length > 0 catches it instantly.
Or imagine your authentication service. It returns 200 for every request, but when the token database is down, the response body contains {"error": "service unavailable"} instead of a valid token. An assertion checking $.token exists catches this immediately.
JSON API monitoring is available on Pro plans. Start validating your API responses — because 200 OK is not enough.
Enjoyed this post?
Get monitoring tips and product updates delivered to your inbox.