{"_id":"58112e73ded0340f0085d05c","parentDoc":null,"project":"551e85be610f400d00837db7","user":"55f2fd49b5b25021002b7dfd","category":{"_id":"58112e72ded0340f0085d02e","__v":0,"project":"551e85be610f400d00837db7","version":"58112e71ded0340f0085d02a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-18T20:49:57.839Z","from_sync":false,"order":0,"slug":"cratejoy-api","title":"Cratejoy APIs"},"githubsync":"","__v":0,"version":{"_id":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":4,"createdAt":"2016-10-26T22:30:09.862Z","releaseDate":"2016-10-26T22:30:09.862Z","categories":["58112e72ded0340f0085d02b","58112e72ded0340f0085d02c","58112e72ded0340f0085d02d","58112e72ded0340f0085d02e","58112e72ded0340f0085d02f","58112e72ded0340f0085d030","58112e72ded0340f0085d031","58112e72ded0340f0085d032","58112e72ded0340f0085d033","58112e72ded0340f0085d034","581137cc604d3c230048b7e4","58dc367221742d0f00a73f98","590768e54669da0f00db5c0b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"new designer","version_clean":"2.0.0","version":"2.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-18T21:24:20.761Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"## Collection Requests\n\nAll of Cratejoy's \"collection\" endpoints accept the following arguments:\n\n- **limit**: Max number of results to return per query\n- **page**: Page page number. So with limit=10 and page=3, you'll get items 31-40.\n\n## Collection pagination\n\nCratejoy's collection endpoints always return paginated results with data for multiple objects at a time. Collection endpoints always return data with the following attributes:\n\n- **count**: The total number of results matched by the query\n- **next**: The argument to attach to the url to retrieve the next page\n- **prev**: The argument to attach to the url to retrieve the previous page\n- **results**: An array of the current page's results\n\n\n## Element Responses\n**Related objects**\n\n_Related objects_ will be returned with the \"summary\" attributes. This set of data is exactly the same as the summary in a Collection response.  Some relationships are loaded by default, others can be requested using the `with` query parameter.  See [Working with Object Relationships](doc:working-with-object-relationships) for more details.\n\nElements will not be sent with an envelope.\n\n## Element Requests\n\nRequests for Elements follow REST principles.\n\n``` POST ```\n\n* Will create an object with JSON data in the request ```body```.\n* Will return the complete representation of the created Element.\n* Will return some 400 status on failure\n\n``` PUT ``` \n* Will update a resource given an ```id``` with JSON data in the request body. \n* Will return the complete representation of the Element on success. \n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Only pass properties that you want updated in a POST or PUT\",\n  \"body\": \"**Unknown** or **read-only** properties passed in the ``` POST ``` or ``` PUT ``` will generate an error.  \\n\\nIt may be tempting to ```GET``` an Item, update a property or two in the response, and then pass that entire response back in a ```PUT```.  Don't do that!\"\n}\n[/block]\n``` DELETE ``` \n* Will delete an Element given an ```id```. \n* Returns nothing on success.\n\n## Errors\nWhen possible, the server will return a description of the error in a JSON ```body```.\n\n``` JSON\n{\n   \"errors\": [ \n       \"Unknown property 'badprop'\",\n       \"Invalid query parameter\"\n    ]\n}\n```\n\n## Field Conventions\n\n**Currency data**\n\nCurrency is represented throughout as an integer, with the decimal portion inferred. E.g., \"$4.50\" is represented as ```450```.\n\n**Date and Times**\n\nDates and times as an _ISO 8601_ _combined data and time in UTC_ string ```2015-09-12T23:06:19Z```\nAll dates are UTC unless otherwise specified in the date string.\n\n**Status and other Enum values**\nCertain fields are stored in our database as integers and when filtering you have to use the enum value. For example, shipment status is returned or posted as as \"unshipped\", \"shipped\", or \"cancelled\", but when filtering a collection, you would filter on \"status__eq=1\", \"status__eq=2\", or \"status__eq=3\" respectively.","excerpt":"","slug":"collections2","type":"basic","title":"Collections"}
## Collection Requests All of Cratejoy's "collection" endpoints accept the following arguments: - **limit**: Max number of results to return per query - **page**: Page page number. So with limit=10 and page=3, you'll get items 31-40. ## Collection pagination Cratejoy's collection endpoints always return paginated results with data for multiple objects at a time. Collection endpoints always return data with the following attributes: - **count**: The total number of results matched by the query - **next**: The argument to attach to the url to retrieve the next page - **prev**: The argument to attach to the url to retrieve the previous page - **results**: An array of the current page's results ## Element Responses **Related objects** _Related objects_ will be returned with the "summary" attributes. This set of data is exactly the same as the summary in a Collection response. Some relationships are loaded by default, others can be requested using the `with` query parameter. See [Working with Object Relationships](doc:working-with-object-relationships) for more details. Elements will not be sent with an envelope. ## Element Requests Requests for Elements follow REST principles. ``` POST ``` * Will create an object with JSON data in the request ```body```. * Will return the complete representation of the created Element. * Will return some 400 status on failure ``` PUT ``` * Will update a resource given an ```id``` with JSON data in the request body. * Will return the complete representation of the Element on success. [block:callout] { "type": "warning", "title": "Only pass properties that you want updated in a POST or PUT", "body": "**Unknown** or **read-only** properties passed in the ``` POST ``` or ``` PUT ``` will generate an error. \n\nIt may be tempting to ```GET``` an Item, update a property or two in the response, and then pass that entire response back in a ```PUT```. Don't do that!" } [/block] ``` DELETE ``` * Will delete an Element given an ```id```. * Returns nothing on success. ## Errors When possible, the server will return a description of the error in a JSON ```body```. ``` JSON { "errors": [ "Unknown property 'badprop'", "Invalid query parameter" ] } ``` ## Field Conventions **Currency data** Currency is represented throughout as an integer, with the decimal portion inferred. E.g., "$4.50" is represented as ```450```. **Date and Times** Dates and times as an _ISO 8601_ _combined data and time in UTC_ string ```2015-09-12T23:06:19Z``` All dates are UTC unless otherwise specified in the date string. **Status and other Enum values** Certain fields are stored in our database as integers and when filtering you have to use the enum value. For example, shipment status is returned or posted as as "unshipped", "shipped", or "cancelled", but when filtering a collection, you would filter on "status__eq=1", "status__eq=2", or "status__eq=3" respectively.