title: REST API Design: Subcollection inheriting an editable variation of a resource
body: <p>Bear with me, as I'm new to API Design and stackoverflow.</p>
  
  <p>For my API design I have three main components:</p>
  
  <ul>
  <li>key/value pairs (a singleton resource)</li>
  <li>group (a collection of KVPs)</li>
  <li>subgroup (a variation of the corresponding group)</li>
  </ul>
  
  <p>In my API the user should be able to: </p>
  
  <ol>
  <li>create, retrieve, update, and delete KVPs (basic CRUD actions)</li>
  <li>organize KVPs into groups and access a listing of those groups</li>
  <li>create subgroup variations of the groups that automatically inherit the parent groups' KVPs, and in those subgroups they can edit each KVPs data independently</li>
  </ol>
  
  <p>For example, my Create a New Group request in my documentation looks like this:</p>
  
  <pre><code>    {
          "group": "age",
          "kvps" : [
              {
                  "key": "height",
                  "value": 5.2
              }, {
                  "key": "weight",
                  "value": 150
              }
          ],   
          "subgroups": [
              "adult",
              "teen",
              "baby"
          ]
      }
  </code></pre>
  
  <p>Using this as an example, I would like the subgroups "adult", "teen", and "baby" to have their own versions of the KVPs "height" and "weight" each with a different value (e.g. adult with a height of 6 and weight of 200, teen with a height of 5.2 and weight 140, etc.) that can be edited independently from each other.</p>
  
  <p>My question: How should I structure my api so that a user could either:</p>
  
  <ol>
  <li>have just editable kvps</li>
  <li>have any number of editable kvps organized into any number of groups
  or</li>
  <li>have any number of editable kvps organized into groups and then further into subgroups</li>
  </ol>
  
  <p>WITHOUT duplicating any of the data?</p>
  
  <p>So far I have a uri structure like this:</p>
  
  <pre><code>/settings/kvps/{kvp_id} (CRUD on one single KVP)
  /settings/groups/{group_id} (CRUD on one single group)
  /settings/groups/{group_id}/kvps/{kvp_id}
  /settings/groups/{group_id}/subgroups/{subgroup_id}
  /settings/groups/{group_id}/subgroups/{subgroup_id}/kvps/{kvp_id}
  </code></pre>
  
  <p>So the kvps have 3 possible URIs, which seems messy to me, and from what I know editing the value of a kvp at </p>
  
  <pre><code>/settings/groups/1/subgroups/1/kvps/1
  </code></pre>
  
  <p>would also change its value at</p>
  
  <pre><code>/settings/groups/1/subgroups/2/kvps/1
  /settings/groups/1/subgroups/3/kvps/1
  /settings/groups/1/kvps/1
  /settings/kvps/1
  </code></pre>
  
  <p>and so on, which is the opposite of what I want.</p>
  
  <p>Any ideas?</p>
  
  <p>Once again, I apologize if this is a very simple question that I am way off of, this is my first time designing an API.</p>