Skip to content

MessageCreateParams.Body serializes messages before system — does field order matter for the API? #322

@saings

Description

@saings

Description

When serializing MessageCreateParams.Body to JSON (e.g. for logging or debugging), the resulting body has messages appearing before system:

{
"max_tokens": 16000,
"messages": [
{ "role": "user", "content": "..." }
],
"model": "claude-sonnet-4-6",
"system": "You are a ...",
"temperature": 0.5,
"tools": [...],
"tool_choice": {...}
}

This is caused by the alphabetical order of @JsonProperty-annotated getter methods in Body — messages (m) comes before system (s).

Question

Does the Anthropic Messages API treat JSON field order as significant? Specifically — is there any requirement or recommendation that system should appear before messages in the request body?

Both prompt engineers and AI engineers on our team insist that for Claude models the field order matters semantically — specifically that system must precede messages in the request body for the model to process the system prompt correctly. We have not been able to find any mention of this requirement in the official documentation. RFC 7159 defines JSON objects as unordered, so we assume the API parses fields by name regardless of position. We would appreciate an official clarification on this point.

Or document explicitly that field order is irrelevant, so integrators can stop worrying about it.

Thank u!

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions