79699945

Date: 2025-07-13 12:19:45
Score: 0.5
Natty:
Report link

It depends on your business need and use case.
If elements are known and should be created on container creation, then it's better to include elements creation at the same API request. You can also pass it as an empty array if no elements to be created for some containers so that you make your API dynamic for both cases. Of course in this case you will also need an element creation API if there is a possibility that elements will not be all added at the time of container creation.

However, if always elements will be added later then create create 2 separate APIs without including elements in the container creation API.

And for the elements creation API it's best practice to always make it an array, and in case you will add only one element, then the array will contain only one item.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Karmelina Michael