SEO + AEO on AutopilotFrom the team at Stackmatix
The Growth Library

Define Missing, Null, Empty and Default Values in an API Reference

Specify field presence, null, empty values, and application defaults with input-to-state fixtures instead of ambiguous API examples.

An API reference should tell an implementer what happens when a field is omitted, explicitly null, empty, or populated. Those inputs are not interchangeable. A valid JSON value can still be invalid for a particular operation, and a schema-valid request may have application behavior that requires separate explanation.

Start with one field and one operation. An update can interpret omission differently from creation. Do not turn a create example's default into a universal update rule or infer that null means delete from the JSON syntax alone.

The migration acceptance guide compares contracts across versions. This worksheet resolves the current version's input-to-state behavior before the caller implements it.

Separate the schema from business behavior

The JSON Schema null reference explicitly distinguishes null from an absent property. The object reference explains that properties are not required merely because they appear in the properties definition; required is a separate constraint.

Those facts establish representation and validation boundaries. They do not decide whether your application retains an old value, clears it, applies a default, rejects the request, or computes a new value. Obtain that behavior from the actual operation contract and its owner.

Record property name, type, presence requirement, null permission, empty-value permission, normalization, and resulting state. Include any condition that changes the behavior. A field marked optional is incomplete documentation if the reader cannot determine what omission does.

Keep an example value distinct from a default. Showing a field in a sample request does not establish that the server inserts that value when a caller leaves it out.

Work a fictional update field

Imagine a fictional task service with an optional display label on an update operation. Its approved contract says omission preserves the current label, null clears it, an empty string is rejected, and a nonempty string replaces it. These are invented rules, not behavior implied by JSON or every API.

Hypothetical display-label update contract
InputStarting labelExpected state
Property omittedQuarterly reviewQuarterly review remains
Explicit nullQuarterly reviewLabel cleared
Empty stringQuarterly reviewRejected; old label unchanged
Monthly reviewQuarterly reviewMonthly review replaces it

The reference should show these as different cases. A client library that removes null properties before sending would change the caller's intended clear operation into an omitted-property operation under this contract.

Do not repair that discrepancy by changing the expected state after seeing the result. Verify the serialization path and the approved operation behavior separately.

Add create and nested-object cases only when relevant

If creation uses a default label, document its source and conditions separately from the update table. An existing resource's value is not the same as a creation default. A reader should know whether the server, client library, or tutorial code supplies a value.

For nested objects, establish whether the operation merges individual fields or replaces the object. Omitting a nested property during replacement can have a different consequence from omitting it during a partial update. Do not infer the behavior from the word update.

Arrays need the same specificity. An empty array might mean a valid empty collection, a request to remove all associations, or an invalid input. Name the real behavior and any authorization needed for the resulting action.

Keep the worksheet focused on the operation being documented. A universal presence table covering every imaginable type becomes less useful than a complete, verified set of cases for the field the caller actually needs.

Follow values through the client boundary

Inspect the actual serialized request produced by the supported client path in an authorized test. The learner's in-memory value can be transformed before it reaches the service. Record whether missing, null, empty, false, and zero survive as distinct representations where they are permitted.

Do not rely on a truthiness condition to establish presence. A legitimate false or zero can disappear if sample code treats every false-like value as missing. Add those fixtures when the field type supports them.

Use synthetic values and permitted test resources. The credential example review helps keep request captures and response evidence suitable for publication. A field contract does not justify retaining private payloads.

After a rejected case, verify the actual state that the contract promises. A validation error message alone does not prove that no part of the operation changed. Use the provider's documented operation boundary rather than assuming atomicity.

Make examples and generated references agree

Check the schema description, human prose, SDK sample, generated reference, and any downloadable request collection. If one says null clears the label while another says it is ignored, resolve the contradiction before release.

The acceptance brief should identify who approves the application semantics and who verifies the examples. A schema validator cannot settle a disagreement about the intended business state.

Include an intentional mismatch in a local fixture or review exercise. For example, make the fictional client omit null and verify that the expected clear operation no longer passes. This checks a meaningful failure, not merely whether the JSON parser accepts the text.

Keep the operation version and the starting state attached to each result. Without them, a later reviewer can mistake a valid create behavior for an update regression.

Release a field contract the caller can implement

Publish the smallest complete set of presence cases with clear resulting states and limitations. Link to deeper reference material where necessary, but keep consequential distinctions close to the field description.

Recheck when schemas, client serializers, normalization, or update semantics change. Preserve earlier behavior in the version record rather than silently making historical examples appear to have always used the new rule.

The finish line is a caller who can choose omission, clearing, an empty value, or replacement deliberately. “Optional string” may be a type description, but it is not the complete operating contract a developer needs.

Sources

Matt Pru

Co-founder and CEO of Stackmatix. Writing about growth, customer acquisition, and the decisions behind useful marketing. Connect on LinkedIn.

Developed with AI assistance under Matt's editorial direction. Our Editorial Approach