# Where to put included for single resources?

**URL:** <https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363>\
**Category:** Uncategorized\
**Created:** [February 26, 2016, 2:03pm UTC](https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363 "2016-02-26T14:03:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![drig23](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/drig23/32/223_2.png) [@drig23](https://discuss.jsonapi.org/u/drig23)\
**Post date:** [February 26, 2016, 2:03pm UTC](https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363/1 "2016-02-26T14:03:04Z")

</div>

I have a REST api where doing a GET on /sku/17 gives you a stockkeeping unit record. It’s for a point of sale app I’m making. I have this looking like this:

{  
“type”: “sku”,  
“id”: 17,  
“attributes”: {  
…  
},  
“links”: {  
…  
},  
“relationships”: {  
…  
}

My question: where do I put the included objects? If I put it at the top-level, it looks like it’s part of the resource object itself.

When I get all skus, the list of skus is nested within a data record. So, it’s easy to put the included records outside of data. like so

{  
“data”: [{  
…  
}],  
“included”: {  
…  
}  
}

Thank you!!!  
Dave

---

<div class="post-metadata">

**Author:** ![brainwipe](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/brainwipe/32/209_2.png) [@brainwipe](https://discuss.jsonapi.org/u/brainwipe)\
**Post date:** [February 29, 2016, 3:22pm UTC](https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363/2 "2016-02-29T15:22:23Z")

</div>

In your top example, you’re missing `data`. The `data` property is always there. It should be:

```
{
   "data" :
    {
      "type": "sku",
      "id": 17,
      "attributes":{},
      "links": {},
      "relationships":{},
    },
    "included" :
    {
      // other identifiable resources
    }
}
```

---

<div class="post-metadata">

**Author:** ![drig23](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/drig23/32/223_2.png) [@drig23](https://discuss.jsonapi.org/u/drig23)\
**Post date:** [February 29, 2016, 5:35pm UTC](https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363/3 "2016-02-29T17:35:41Z")

</div>

Thank you, brainwipe. I’ll implement it that way.

There’s a bug in the specification. [http://jsonapi.org/format/](http://jsonapi.org/format/) - in the “Resource Object” section, you can see it has the single resource like in my top example. It’s repeated in Resource Linkage and Resource Links.

---

<div class="post-metadata">

**Author:** ![brainwipe](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/brainwipe/32/209_2.png) [@brainwipe](https://discuss.jsonapi.org/u/brainwipe)\
**Post date:** [February 29, 2016, 10:29pm UTC](https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363/4 "2016-02-29T22:29:07Z")

</div>

Ah, I see what you mean. There is a `//...` at the top. This because a resource object can be a child of `data` or `includes`. You do not return a resource object, you return a compound document, which can contain many resources. A document must have one of data, meta or links as it’s descendants.

I hope that clears it up.

---

<div class="post-metadata">

**Author:** ![drig23](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/drig23/32/223_2.png) [@drig23](https://discuss.jsonapi.org/u/drig23)\
**Post date:** [February 29, 2016, 10:43pm UTC](https://discuss.jsonapi.org/t/where-to-put-included-for-single-resources/363/5 "2016-02-29T22:43:22Z")

</div>

Ah, I see. Yes, it does clear it up for me. Thank you for the excellent answer.
