So I was having a discussion with some co-workers, imagine I'm designing an API. The API takes in a list of IDs, and returns a list of corresponding objects for each ID, each ID corresponds to exactly 1 object, and if any ID is not found the entire call fails. The objects returned do not have the ID used to query for them, but are returned in the same order as the elements passed to the API.
ie 1,3,5 -> obj-1,obj-3,obj-5
So my question is, if this is well documented in the API, that the caller knows which item corresponds to each ID because they are passed in the same order. It seems like inherently bad design to have the only thing that ties the input back to the result is the order, but a co-worker insists this is a common practice in APIs that take in lists of inputs.
Is there anything inherently bad about designing an API like this?
id
as a field in the returned object, if that doesn't cause significant problems. That way you have redundancy, plus, if a few IDs fail you could still return a partial list.