{"_id":"58112e73ded0340f0085d05b","__v":0,"project":"551e85be610f400d00837db7","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"},"parentDoc":null,"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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-18T21:10:15.930Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"The information presented in the **Cratejoy API** section applies to both the *merchant* and *store* API's\"\n}\n[/block]\n## Cratejoy Store API\nCratejoy offers a Store API, which allows JavaScript to read (and sometimes write) data on behalf of logged-in customers. Theme developers and Merchants looking to customize their subscription workflow or customer account pages should see the [Store API Introduction](doc:introduction) \n\n## Cratejoy Merchant API\nThe [Cratejoy Merchant API](doc:introduction-1) provides an interface into most of the data and functionality of interest to merchants and developers.  It  is useful to merchants and developers looking to write custom scripts or back-end extensions. \n\nThere are some example scripts provided for reference purposes at <a href=\"https://github.com/cratejoy/api_examples\">https://github.com/cratejoy/api_examples</a>\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Resources\"\n}\n[/block]\nResource representations are JSON throughout the API, by default. Agents should still send an ```Accept``` header with ```application/json``` for requests, and a ```Content-Type``` header with ```application/json``` for ```POST``` and ```PUT``` requests with a JSON body. In the future, the API may add support for other representations of data.\n\nAll data is encoded with UTF-8, and agents should send data encoded in UTF-8 to avoid problems. Queries and filters are URL parameters. All ```POST``` and ```PUT``` requests use a JSON body. No endpoints use Forms or URL parameters for updates.\n\n### URI Patterns\n* Major versions will be prefixed to all routes: ```/v1/{objects}/```\n* **Collection** Resource URIs follow the pattern ```/{objects}/``` (plural).\n* **Element** Resource URIs follow the pattern ```/{objects}/{id}```.\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Response Codes\"\n}\n[/block]\n## 2xx Successful Requests\n* ```200 OK``` Will be returned for successful GET, PUT, and PATCH requests.\n* ```201 Created``` Will be returned for successful POST requests.\n* ```204 No Content``` Will be returned for successful DELETE requests\n\n## 4xx Client Errors\n* ```400 Bad Request``` for generic client errors.\n* ```403 Forbidden``` when requesting a Resource which is not accessible by the client.\n* ```404 Not Found``` when requesting a Resource which does not exist.\n* ```405 Method Not Allowed``` when using an inappropriate HTTP method for a Resource.\n* ```429 Too Many Requests``` when a client has issued too many requests.\n\n## 5xx Server Errors\n* ```500 Internal Server Error``` if we are having unspecified problems.\n* ```503 Service Unavailable``` during expected downtime\n\n## Headers\n* ```Retry-After``` In the event of a ```429 Too Many Requests```, a ```Retry-After``` header will be included in the response. Agents can observe this value to retry at a later time. Time is returned in seconds until retry.","excerpt":"","slug":"introduction2","type":"basic","title":"Introduction"}
[block:callout] { "type": "warning", "body": "The information presented in the **Cratejoy API** section applies to both the *merchant* and *store* API's" } [/block] ## Cratejoy Store API Cratejoy offers a Store API, which allows JavaScript to read (and sometimes write) data on behalf of logged-in customers. Theme developers and Merchants looking to customize their subscription workflow or customer account pages should see the [Store API Introduction](doc:introduction) ## Cratejoy Merchant API The [Cratejoy Merchant API](doc:introduction-1) provides an interface into most of the data and functionality of interest to merchants and developers. It is useful to merchants and developers looking to write custom scripts or back-end extensions. There are some example scripts provided for reference purposes at <a href="https://github.com/cratejoy/api_examples">https://github.com/cratejoy/api_examples</a> [block:api-header] { "type": "basic", "title": "Resources" } [/block] Resource representations are JSON throughout the API, by default. Agents should still send an ```Accept``` header with ```application/json``` for requests, and a ```Content-Type``` header with ```application/json``` for ```POST``` and ```PUT``` requests with a JSON body. In the future, the API may add support for other representations of data. All data is encoded with UTF-8, and agents should send data encoded in UTF-8 to avoid problems. Queries and filters are URL parameters. All ```POST``` and ```PUT``` requests use a JSON body. No endpoints use Forms or URL parameters for updates. ### URI Patterns * Major versions will be prefixed to all routes: ```/v1/{objects}/``` * **Collection** Resource URIs follow the pattern ```/{objects}/``` (plural). * **Element** Resource URIs follow the pattern ```/{objects}/{id}```. [block:api-header] { "type": "basic", "title": "Response Codes" } [/block] ## 2xx Successful Requests * ```200 OK``` Will be returned for successful GET, PUT, and PATCH requests. * ```201 Created``` Will be returned for successful POST requests. * ```204 No Content``` Will be returned for successful DELETE requests ## 4xx Client Errors * ```400 Bad Request``` for generic client errors. * ```403 Forbidden``` when requesting a Resource which is not accessible by the client. * ```404 Not Found``` when requesting a Resource which does not exist. * ```405 Method Not Allowed``` when using an inappropriate HTTP method for a Resource. * ```429 Too Many Requests``` when a client has issued too many requests. ## 5xx Server Errors * ```500 Internal Server Error``` if we are having unspecified problems. * ```503 Service Unavailable``` during expected downtime ## Headers * ```Retry-After``` In the event of a ```429 Too Many Requests```, a ```Retry-After``` header will be included in the response. Agents can observe this value to retry at a later time. Time is returned in seconds until retry.