AnthropicClaude Certified Architect – Foundations2026-104.3 Enforce structured output using tool use and JSON schemas
Make missing and uncertain evidence representable
Completed by the knowledge check
Learning objective
Design schemas for absent and ambiguous evidence using nullable fields, unclear, and extensible other plus detail values.
Core idea
A schema should permit the facts your document can support, including the fact that it does not support a value. If every invoice must produce a non-null purchase-order number, a document without one cannot be represented faithfully: the required non-null field pressures Claude to supply a value even when the source lacks one. Strict mode guarantees its permitted type, not that the value appears in the document.
Design separate representations for three cases: a value is absent, a category is ambiguous, or a category is clear but missing from your enum. Nullable fields handle absent values. An unclear enum member handles unresolved classification. An other member with a detail field preserves a known category outside the named list.
These are application-defined meanings, not built-in Anthropic category values. You define them in the schema and explain them in the prompt and field descriptions. The API enforces the supported shape; your consumer decides what each state permits downstream.
How it works
Distinguish presence from a nullable value
JSON Schema’s required array controls whether a property must exist. A property’s type controls its permitted value types. Those are independent decisions, as introduced in 0.3.
For an extraction record, po_number with type: ["string", "null"] and a place in required must exist but can carry null; omitting it from required independently permits the key to be absent. See 0.3 for the full presence-versus-value mechanics.
For a fixed extraction record, a required nullable field is often clearer for consumers: every record has the same keys, while null represents missing source evidence. That is a contract choice rather than a universal requirement of strict mode. Anthropic supports optional properties as well as null types.
Do not use the string "null" or a placeholder purchase-order number for the missing state. A schema permitting JSON null makes the absence explicit without requiring the consumer to recognize a special string. State the intended meaning: “Use null when the source does not state a purchase-order number; do not substitute the invoice or shipment reference.”
Give categories two different escape values
A closed enum such as goods, services, and freight is convenient for reporting, but not every document fits it. Add other when the document clearly identifies something outside that list, and a category_detail string to retain what it identifies.
For example, an invoice explicitly labelled “customs duty” can produce category: "other" and category_detail: "customs duty". The detail lets a consumer preserve that evidence without immediately changing its main category enum. Adding a dedicated category later changes the contract; preserving the detail lets you defer that decision without losing the source category.
Use unclear when the source does not support a confident category. “Q3 support pack” without an explanation might not distinguish a physical goods bundle from a service. That is different from recognizing customs duty and finding no matching enum member. Do not use other as a catch-all for both known unlisted categories and unresolved interpretation.
Describe when to choose each value in the field’s description. Keep the categories explicit rather than relying on ordinary English meanings to establish your pipeline’s handling policy. Anthropic documents an enum-capitalization exception for strict tool use and JSON outputs: compare values case-insensitively and avoid enum members whose only distinction is capitalization.
Define the record and the consumer rules
The following input_schema fragment makes each of those states representable:
{
"type": "object",
"properties": {
"po_number": {
"type": ["string", "null"],
"description": "Purchase-order number stated in the source; null if absent."
},
"category": {
"type": "string",
"enum": ["goods", "services", "freight", "other", "unclear"],
"description": "Use other for a clear unlisted category and unclear for unresolved evidence."
},
"category_detail": {
"type": ["string", "null"],
"description": "Name the evidenced category for other; otherwise use null."
}
},
"required": ["po_number", "category", "category_detail"],
"additionalProperties": false
}Use this fragment inside a strict extraction tool, or as the schema in output_config.format for native JSON outputs. It uses the documented supported basic types, enum, required properties, and closed object shape.
The fragment makes a non-null detail possible; it does not enforce the relationship between category and category_detail. In the consumer, require an evidence-backed, nonempty detail when category is other. If category is unclear, hold the record for the application’s review path rather than allowing category-dependent automation. If po_number is null, do not issue an order-match operation that requires a stated number. These checks implement the meanings you assigned; they are not API behavior associated with the words other or unclear.
A legal missing value also does not prove faithful extraction. Claude can still omit evidence by selecting null despite a number on the page, or select a specific category when the document is ambiguous. Sample against source evidence and apply the semantic checks owned by 4.3.5.
Key distinctions and trade-offs
Use the following states to keep downstream decisions separate:
| Source evidence | Representation | Consumer interpretation |
|---|---|---|
| Purchase-order number is absent | po_number: null | Do not manufacture an order-match input |
| Category is supported by evidence and listed | Named enum member | Apply that category’s accepted handling |
| Category is clear but unlisted | other plus detail | Preserve the recognized category for review or mapping |
| Category is unresolved | unclear | Hold category-dependent decisions |
Optional keys can fit sparse records, while required nullable keys make absence uniform for consumers. Neither choice prevents invention by itself. Descriptions and prompts must make missing evidence a legitimate answer, and validation must check that the result follows those semantics.
Nullable fields also consume schema complexity. Anthropic’s structured-output limits allow 16 union-type parameters across the combined strict tool schemas and JSON output schemas in a request; type arrays such as ["string", "null"] count. The optional-parameter limit is 24 across that same combined scope. Keep the extraction record focused or split stages when those boundaries matter. Do not remove needed null states merely to make a large schema compile.
Architecture / decision scenario
A service receives three supplier documents. The first has no purchase-order number but clearly describes freight. The second names customs duty. The third only says “Q3 support pack.” All three must return a stable record shape without inventing classification evidence.
For the first, required nullable po_number carries null, while category carries freight and category_detail carries null. The order-match dispatcher checks po_number and does not attempt to search using a fabricated reference.
For the second, the extractor returns other with category_detail: "customs duty". The consumer checks that the detail is nonempty and supported by the document, then preserves it for category mapping. It does not reinterpret the unlisted category as uncertainty.
For the third, the extractor returns unclear. The consumer sends the record to the review path and blocks category-dependent automation. Tightening the enum to only three named categories would remove the faithful representation of this ambiguity. Retrying with the same insufficient evidence would not establish which category is correct.
The deciding design is the combination of legal missing states and explicit consumer branches. Strict mode makes these records structurally usable; evidence checks determine whether the chosen states are justified.
Common exam traps
- Treating optional and nullable as synonyms.
- Making every extracted value a required non-null string.
- Using
"null"instead of JSON null. - Treating
otherandunclearas the same condition. - Adding
otherwithout a detail field or checking its meaning. - Assuming a required detail key guarantees a nonempty explanation.
- Assuming nullable fields eliminate hallucination or prove absence.
Where the exam guide differs
The guide says to design fields as “optional (nullable)” when evidence may be absent. JSON Schema distinguishes an optional property from a nullable value. Anthropic supports both: omission is controlled by required, while null is permitted by the property’s type. Read the guide’s phrase as a request to represent missing evidence, then choose the exact presence and value contract the consumer needs.
What to remember
Make missing evidence legal without collapsing its meaning. Null represents an absent field value, unclear represents unresolved classification, and other plus detail preserves a recognized unlisted category. Required keys and nullable values are independent; consumer checks turn those states into permitted next actions.
Knowledge check
About a third of supplier invoices carry no purchase-order number. The strict extraction schema declares po_number as a required string, and the payment system now holds purchase-order numbers that appear on no document. Which change fixes the cause?
po_number as a value Claude must never invent"null" when no number is statedpo_number nullable and instruct Claude to use null when absent"null" is a placeholder every consumer must special-case, and retrying cannot find evidence the document lacks.A strict schema declares category with the enum goods, services, freight, other, and unclear, plus a nullable category_detail. An invoice is explicitly labelled “customs duty”. Which record represents it faithfully?
category: "unclear" and category_detail: nullcategory: "other" and category_detail: "customs duty"category: "freight" and category_detail: "customs duty"category: "other" and category_detail: nullother plus a detail preserves. unclear is for evidence that does not support a confident category, mapping to the nearest listed member misstates the evidence, and other without a detail discards the category the document named.An invoice describes only a “Q3 support pack”, which could be a goods bundle or a service, and the extractor returns category: "unclear". Downstream, the category decides which ledger and approval route the invoice takes. What should the consumer do?
other and send it to category mappingunclear from the enum and run the extraction againunclear records that the evidence does not settle the category, so the consumer holds category-dependent decisions and routes the record to review. Retrying with the same insufficient evidence cannot establish a category, treating it as other confuses an unresolved category with a recognized unlisted one, and removing unclear only forces a guess.A consumer requires every extracted record to contain the same keys, with JSON null marking a value the source does not state. How should po_number be declared?
required , with the type ["string", "null"]required , with the type "string"required , with the type "string"required , with the type ["string", "null"]required controls whether the key must exist, and the type controls which values it may carry, so “same keys, null when absent” needs both: the key is present because it is required, and null is legal because the type allows it. Omitting the key from required makes it optional, which permits a missing key rather than a null value.References
- Anthropic, Structured outputs
- Anthropic, Define tools
- JSON Schema, object
- JSON Schema, type
- Anthropic, Claude Certified Architect – Foundations Exam Guide