I've made an endpoint for creating events: POST /events/new

The request should have JSON data on the body. This is the JSON structure that is required for creating a new event:

    "label": "my first event",
    "description": "lorem ipsum dolor sit amet",
    "meta": {
        "status": "draft",
        "isOnline": true,
        "visibility": "visible",
        "customID": "my-first-event",
        "tags": ["foo", "bar"],
        "categories": ["concert", "sports"]

My problem being: I don't think I've ever seen services requiring nested properties (like in meta.status). Is it a bad practice?

I'm doing it like that because it's more organized.

  • I don't think I've ever seen services requiring nested properties. How many services have you seen in your career? Services developer by others than you I mean.
    – Laiv
    Oct 26, 2022 at 14:06
  • @Laiv I work with consuming APIs a lot, actually. They always require flat objects. Oct 26, 2022 at 14:08
  • 3
    The answer to the question is a big no, it's not bad practice. You can not measure the correctness of your decisions comparing yourself with others. Your project, your needs. Or the other way around: you don't know if they are wrong or why they "all" made response flat maps. Right? In any case, if we are speaking about REST, remeber that you are giving "representations" of real assets. If assets have "meta-data" and you need to share that information, then do it. The complexity of the representation is a technical decision.
    – Laiv
    Oct 26, 2022 at 14:17
  • @Laiv this seems to me the start of a good answer… why not go the extra mile ;-)
    – Christophe
    Oct 26, 2022 at 17:07
  • That’s not nested.
    – gnasher729
    Oct 26, 2022 at 18:36

1 Answer 1


No, I think this is fine.

The object is still flat, it just has namespaces.

Where it might be "bad" though is if you have a collection of child objects

   "name": "A",
   "children" : [
     { "name":"B"},....

Now if you are posting this to a "resource" style endpoint you have an open question about whether you can update/change the child objects without sending the entire object.

Not a massive issue, but perhaps something to be avoided if you don't have to go that route.

  • You made a good point. However, the update/change/create input is not forced to match 1:1 the GET representation. When you add a new comment in someone else' Facebook you add text only, but when you retrieve comments by API you get many more data. Most is meta-data.
    – Laiv
    Oct 27, 2022 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.