Validation
Validate an API payload
Start with syntax validation, then check shape, required fields, types, casing, and business rules.
Goal: Find whether an API payload is malformed, missing fields, or shaped differently than expected.
Workflow steps
Step 1
Validate syntax
A payload must parse before shape or business validation can be meaningful.
Step 2
Format for inspection
Pretty print the payload so missing fields, null values, and nested arrays are easier to see.
Step 3
Compare with the expected example
Use a known-good payload and compare paths, not just visual formatting.
Step 4
Separate syntax from business rules
Valid JSON can still fail API validation because required fields, types, or allowed values are wrong.
Real examples
Syntax-valid but invalid for API
{"email":"ada@example.com"}Possible missing field
The API may require role, userId, or accountId even when JSON syntax is valid.Common pitfalls
Assuming valid JSON means valid API input.
Ignoring field casing differences.
Returning vague validation errors to users.