{"_id":"58112e72ded0340f0085d03c","project":"551e85be610f400d00837db7","parentDoc":null,"category":{"_id":"58112e72ded0340f0085d032","project":"551e85be610f400d00837db7","__v":0,"version":"58112e71ded0340f0085d02a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-08-17T19:28:09.961Z","from_sync":false,"order":7,"slug":"merchant-api-methods","title":"Merchant API Methods"},"__v":0,"user":"55f2fd49b5b25021002b7dfd","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-25T19:16:47.421Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"You can view or modify inventory levels for a given ecommerce product instance. Relevant resources are [Product Instances](doc:product-instances) and [Inventory](doc:inventory) resources.\n\n# List inventory levels or instances across all product instances\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/inventory/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n   https://api.cratejoy.com/v1/product_instances/\\n  </span>\\n</div>\"\n}\n[/block]\n# List or modify inventory levels for a given product instance\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n   https://api.cratejoy.com/v1/product_instances/{product_instance_id}/inventory/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n   https://api.cratejoy.com/v1/product_instances/{product_instance_id}/inventory/\\n  </span>\\n</div>\"\n}\n[/block]\n# Get inventory levels across all ecommerce products\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/inventory/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/inventory/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"List Inventory\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 1, \\n  \\\"next\\\": null, \\n  \\\"prev\\\": null, \\n  \\\"results\\\": [\\n    {\\n      \\\"confidence\\\": 10, \\n      \\\"id\\\": 75572205, \\n      \\\"product_id\\\": 75572202, \\n      \\\"product_instance_id\\\": 75572203, \\n      \\\"quantity_on_hand\\\": 0, \\n      \\\"url\\\": \\\"/v1/product_instances/75572203/inventory/\\\"\\n    }, \\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# List all product instances\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n   https://api.cratejoy.com/v1/product_instances/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/product_instances/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"List Product Instances\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"count\\\": 1,\\n    \\\"next\\\": null,\\n    \\\"prev\\\": null,\\n    \\\"results\\\": [\\n        {\\n            \\\"id\\\": 882431002,\\n            \\\"price\\\": 2500,\\n            \\\"product_id\\\": 882430998,\\n            \\\"sku\\\": \\\"SQ4324678\\\",\\n            \\\"type\\\": \\\"product_instance\\\",\\n            \\\"url\\\": \\\"/v1/product_instances/882431002/\\\"\\n        },\\n      ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Get inventory level for a product instance\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/product_instances/{instance_id}/inventory\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/product_instances/75572213/inventory/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"confidence\\\": 10, \\n  \\\"id\\\": 75572214, \\n  \\\"instance\\\": [], // Product Instance resource\\t\\n  \\\"out_of_stock_purchases\\\": true, \\n  \\\"product_id\\\": 75572211, \\n  \\\"product_instance_id\\\": 75572213, \\n  \\\"quantity_on_hand\\\": 221, \\n  \\\"track_inventory\\\": true, \\n  \\\"type\\\": \\\"product_inventory\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response: 200 OK\"\n    }\n  ]\n}\n[/block]\n# Modify inventory level for a product instance\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/product_instances/{instance_id}/inventory\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/product_instances/75572213/inventory/',\\n    method: 'PUT',\\n  \\tdata: { \\n      quantity_on_hand: 300\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"confidence\\\": 10,\\n    \\\"id\\\": 882431006,\\n   \\t\\\"instance\\\": [], // Product instance information\\n    \\\"out_of_stock_purchases\\\": true,\\n    \\\"product_id\\\": 882430998,\\n    \\\"product_instance_id\\\": 882431002,\\n    \\\"quantity_on_hand\\\": 300,\\n    \\\"track_inventory\\\": true,\\n    \\\"type\\\": \\\"product_inventory\\\",\\n    \\\"url\\\": \\\"/v1/product_instances/882431006/\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"200 OK\"\n    },\n    {\n      \"code\": \"// Confidence must be between 1-10.\\n{\\n    \\\"errors\\\": [\\n        \\\"Product Inventory Update Exception: confidence must be between 1-10.\\\"\\n    ]\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"400 BAD REQUEST\"\n    }\n  ]\n}\n[/block]","excerpt":"Inventory data object specification for the Cratejoy Merchant API","slug":"inventory-methods","type":"basic","title":"Instance & Inventory Methods"}

Instance & Inventory Methods

Inventory data object specification for the Cratejoy Merchant API

You can view or modify inventory levels for a given ecommerce product instance. Relevant resources are [Product Instances](doc:product-instances) and [Inventory](doc:inventory) resources. # List inventory levels or instances across all product instances [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/inventory/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/product_instances/\n </span>\n</div>" } [/block] # List or modify inventory levels for a given product instance [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/product_instances/{product_instance_id}/inventory/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/product_instances/{product_instance_id}/inventory/\n </span>\n</div>" } [/block] # Get inventory levels across all ecommerce products [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/inventory/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/inventory/',\n method: 'GET'\n});", "language": "javascript", "name": "List Inventory" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 1, \n \"next\": null, \n \"prev\": null, \n \"results\": [\n {\n \"confidence\": 10, \n \"id\": 75572205, \n \"product_id\": 75572202, \n \"product_instance_id\": 75572203, \n \"quantity_on_hand\": 0, \n \"url\": \"/v1/product_instances/75572203/inventory/\"\n }, \n ]\n}", "language": "json", "name": "200 OK" } ] } [/block] # List all product instances [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/product_instances/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/product_instances/',\n method: 'GET'\n});", "language": "javascript", "name": "List Product Instances" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 1,\n \"next\": null,\n \"prev\": null,\n \"results\": [\n {\n \"id\": 882431002,\n \"price\": 2500,\n \"product_id\": 882430998,\n \"sku\": \"SQ4324678\",\n \"type\": \"product_instance\",\n \"url\": \"/v1/product_instances/882431002/\"\n },\n ]\n}", "language": "json", "name": "200 OK" } ] } [/block] # Get inventory level for a product instance [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/product_instances/{instance_id}/inventory\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/product_instances/75572213/inventory/',\n method: 'GET'\n});", "language": "javascript", "name": null } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"confidence\": 10, \n \"id\": 75572214, \n \"instance\": [], // Product Instance resource\t\n \"out_of_stock_purchases\": true, \n \"product_id\": 75572211, \n \"product_instance_id\": 75572213, \n \"quantity_on_hand\": 221, \n \"track_inventory\": true, \n \"type\": \"product_inventory\"\n}", "language": "json", "name": "Response: 200 OK" } ] } [/block] # Modify inventory level for a product instance [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/product_instances/{instance_id}/inventory\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/product_instances/75572213/inventory/',\n method: 'PUT',\n \tdata: { \n quantity_on_hand: 300\n});", "language": "javascript", "name": null } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"confidence\": 10,\n \"id\": 882431006,\n \t\"instance\": [], // Product instance information\n \"out_of_stock_purchases\": true,\n \"product_id\": 882430998,\n \"product_instance_id\": 882431002,\n \"quantity_on_hand\": 300,\n \"track_inventory\": true,\n \"type\": \"product_inventory\",\n \"url\": \"/v1/product_instances/882431006/\"\n}", "language": "json", "name": "200 OK" }, { "code": "// Confidence must be between 1-10.\n{\n \"errors\": [\n \"Product Inventory Update Exception: confidence must be between 1-10.\"\n ]\n}", "language": "javascript", "name": "400 BAD REQUEST" } ] } [/block]