Is it ok to specify post/patch requests with meta information?

Please, clarify for me:
The spec declare that:

document MUST contain at least one of the following top-level members:

  • data : the document’s “primary data”
  • errors : an array of [error objects]
  • meta : a [meta object] that contains non-standard meta-information.

I don’t found any mentions that it is only for responses.

Creating Resources
The request MUST include a single [resource object] as primary data. The [resource object] MUST contain at least a type member.

These lines don’t say that request must contain only a single resource object

So is it will be ok to allow send some meta for post/patch requests?

POST /photos HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "photos",
    "attributes": {
      "title": "Ember Hamster",
      "src": "http://example.com/images/productivity.png"
    },
    "meta": {
       "transform": false,
       "makeThumb: true
    }
  }
}

The example meta structure you present is part of the resource object, not a top-level meta object.

I haven’t seen anything in the specification that prevents a PATCH or POST request from including either a top-level or resource-level meta portion.

-Fred

1 Like