Object schemas let an API describe both familiar fields and the boundaries around them. The key design decision is whether a payload should welcome future fields, reject them, or permit a controlled family of dynamically named fields.

Start with named fields

A JSON object uses string labels to associate names with values. In a schema, properties assigns a validation rule to each explicitly named member.

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "enabled": { "type": "boolean" }
  }
}

This example describes the types of name and enabled when those members appear. Declaring a field under properties does not, by itself, make that field mandatory.

Without a requirement rule, a declared member can be absent, including in an otherwise empty object.

Continue reading: Missing, Null, and Empty: Defining an Update Contract.

Choose a policy for unknown keys

Named-field rules and extra-key rules solve different problems. An object schema normally permits keys that are not named in properties. That default is useful when a payload needs room to evolve, but it also means unrecognized input can pass this part of validation.

Flexible payloads

A permissive object retains validation for named members while leaving unmatched members allowed.

Closed payloads

For a fixed contract, set additionalProperties to false. This rejects members that are not covered by properties or patternProperties.

{
  "type": "object",
  "properties": {
    "name": { "type": "string" }
  },
  "additionalProperties": false
}

A middle option is to make additionalProperties a schema, so every otherwise-unmatched member must satisfy a common constraint such as a string value.

Validate families of dynamic names

Use patternProperties when the keys themselves follow a predictable convention. Its entries map regular-expression patterns to schemas that apply to keys selected by those patterns.

{
  "type": "object",
  "patternProperties": {
    "^metric_": { "type": "number" }
  },
  "additionalProperties": false
}

Write anchors deliberately: a pattern is not automatically treated as matching the complete property name.

Apply the design in API workflows

Keep general JSON Schema behavior separate from claims about a particular API product. The supplied API documentation page is a navigation-oriented resource that points to areas such as models, structured output, prompting, tools, agents, reference material, and production guidance; it is not, on its own, a feature-by-feature account of object-keyword support.

Before using an object schema in a structured-output or API integration, identify the target endpoint, the JSON Schema draft, and the validator or product feature in use. Confirm that the implementation supports each keyword you rely on, especially additionalProperties and patternProperties.

Continue reading: Separating OpenAPI Operations From JSON Schema Validation.

Practical selection guide

  • Permissive object: Leave unmatched keys allowed while applying schemas to named properties.
  • Closed object: Set additionalProperties to false when keys outside properties and patternProperties must be rejected.
  • Patterned keys: Use patternProperties to associate regex-selected names with schemas.
  • Combined rules: Use properties for fixed names, patternProperties for matching names, and additionalProperties for all other names.

Limits and verification notes

The available material does not identify the JSON Schema draft that governs an intended implementation. It also does not establish that any particular structured-output feature accepts every object-schema capability described here.