Agent Wranglers

API-6Recommended

Use JSON with one naming style

Send and accept JSON with Content-Type: application/json, and name every field in one style across the whole API.

How to do it

Pick camelCase or snake_case once and write it down in the API guide. Use whole words, not abbreviations. Answer 415 to a body in a type you don't accept. Encode JSON as UTF-8, as RFC 8259 requires. Inside the code, keep typed objects and convert to JSON only at the edge.

How to check

A linter such as Spectral, with a casing rule, passes on the OpenAPI file. A request with Content-Type: text/plain gets 415.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/requests-and-responses/json-conventions">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.