Input for API Securitys
API input and output handling is the discipline of treating every request field as untrusted and every response field as a decision. It includes schema validation, defences against injection and mass assignment, and returning only the data a caller needs, which prevents excessive data exposure.
Stage: Protecting Data · Part of the API Security roadmap · Last reviewed 19 November 2026
What to learn in Input
- Validate request bodies against a strict schema and reject unknown fields
- Prevent SQL and NoSQL injection using parameterised queries
- Stop mass assignment by allow-listing the properties a client may set
- Return explicit response DTOs rather than raw database objects
- Handle file upload and size limits safely
Input interview questions
What is mass assignment in an API?
Mass assignment occurs when a framework binds all incoming JSON fields onto an internal object, so a client can set properties they should not, such as role or isAdmin. Prevent it by binding to a limited input model or allow-listing accepted fields for each endpoint.
What is excessive data exposure?
It is when an API returns more fields than the client needs, relying on the front end to hide them, so internal flags, emails or hashed passwords can be read from the raw response. Fix it by shaping responses on the server with explicit output models.
Where Input fits in the API Security roadmap
Input belongs to the Protecting Data stage (advanced level), which takes about 11 hours. Inputs and outputs.
Other units in this stage
Back to the full API Security roadmap