Skip to content

.tip

· one of the small things

Wrap list responses in an object, not a bare array

GET /items answering [{ "id": "itm_8f2a" }] works until the day you need to send a cursor, a total or a deprecation warning alongside the list. There's nowhere to put it, so the fix becomes a second version of the endpoint.

{ "items": [{ "id": "itm_8f2a" }], "next_cursor": "MjAyNi0wOS0yMg" }

An object has room to grow, and a client that ignores unknown keys keeps working when you add one. The nesting costs one line in the client today, and saves you the version bump later.

api-designhttp