{"_id":"58dc363bd82dc30f00571c6d","__v":3,"githubsync":"","parentDoc":null,"project":"551e85be610f400d00837db7","user":"58a36246b2c9e91b00e551cb","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"},"category":{"_id":"58112e72ded0340f0085d031","__v":0,"project":"551e85be610f400d00837db7","version":"58112e71ded0340f0085d02a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-24T22:11:45.789Z","from_sync":false,"order":5,"slug":"merchant-api","title":"Merchant API"},"updates":["5aa939a22a1896004ba78ba2","5aa93c6fecfafe004a6cf92d","5aa949332a1896004ba78db6"],"next":{"pages":[],"description":""},"createdAt":"2017-03-29T22:33:31.475Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Merchant API calls are made using the following location pattern https://api.cratejoy.com/v1/{endpoint} with Basic Access Authentication.\n\nYou'll need to put an encoded version of your API credentials (Client ID and Client Secret Key)  in the headers, as you can see in the examples below.\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"Admin users can generate API keys from within the merchant dashboard.\\n\\nNon-admin users, like Customer Support or Developers, cannot access this panel. If you need access then please contact your primary store admin to generate an API key for you.\\n\\nAPI generation is done on the \\\"API\\\" page which is found under \\\"Settings\\\" on the main navigation in the merchant dashboard (Warning: Only Admin users on the account can see & access the API page):\",\n  \"title\": \"Need API credentials for your store?\"\n}\n[/block]\nNeed help encoding your Client ID and Client Secret Key?\n* You can use the below Python code to encode the Client ID and Client Secret Key in the form of my_user_name:my_password, and use the value it outputs, or code directly in JavaScript if that's what you're using.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Python\\nimport base64\\n\\nusername = 'my_user_name'\\npassword = 'my_password'\\n\\nprint \\\"Basic {}\\\".format(base64.b64encode('{}:{}'.format(username, password))\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var client_id = 'AzureDiamond';\\nvar client_secret = 'hunter2';\\nvar auth_string = 'Basic ' + new Buffer(client_id + ':' + client_secret).toString('base64');\\n$.ajax({\\n    url: 'https://api.cratejoy.com/v1/shipments/62619521654545/',\\n    headers: {\\n        'Authorization': auth,\\n    },\\n    method: 'PUT',\\n    data: {\\n        shipped_at: \\\"2015-09-01T12:30:00Z\\\",\\n        adjusted_ordered_at: \\\"2015-08-25 00:00:00Z\\\",\\n        tracking_number: \\\"1Z9999999999999999\\\",\\n        status: \\\"shipped\\\"\\n    },\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nAuthorization should be included in all Merchant API requests. For brevity, we've removed it from sample API requests in this documentation, but know that it should be included!","excerpt":"","slug":"authorization","type":"basic","title":"Authorization"}
Merchant API calls are made using the following location pattern https://api.cratejoy.com/v1/{endpoint} with Basic Access Authentication. You'll need to put an encoded version of your API credentials (Client ID and Client Secret Key) in the headers, as you can see in the examples below. [block:callout] { "type": "success", "body": "Admin users can generate API keys from within the merchant dashboard.\n\nNon-admin users, like Customer Support or Developers, cannot access this panel. If you need access then please contact your primary store admin to generate an API key for you.\n\nAPI generation is done on the \"API\" page which is found under \"Settings\" on the main navigation in the merchant dashboard (Warning: Only Admin users on the account can see & access the API page):", "title": "Need API credentials for your store?" } [/block] Need help encoding your Client ID and Client Secret Key? * You can use the below Python code to encode the Client ID and Client Secret Key in the form of my_user_name:my_password, and use the value it outputs, or code directly in JavaScript if that's what you're using. [block:code] { "codes": [ { "code": "Python\nimport base64\n\nusername = 'my_user_name'\npassword = 'my_password'\n\nprint \"Basic {}\".format(base64.b64encode('{}:{}'.format(username, password))", "language": "python" } ] } [/block] [block:code] { "codes": [ { "code": "var client_id = 'AzureDiamond';\nvar client_secret = 'hunter2';\nvar auth_string = 'Basic ' + new Buffer(client_id + ':' + client_secret).toString('base64');\n$.ajax({\n url: 'https://api.cratejoy.com/v1/shipments/62619521654545/',\n headers: {\n 'Authorization': auth,\n },\n method: 'PUT',\n data: {\n shipped_at: \"2015-09-01T12:30:00Z\",\n adjusted_ordered_at: \"2015-08-25 00:00:00Z\",\n tracking_number: \"1Z9999999999999999\",\n status: \"shipped\"\n },\n});", "language": "javascript" } ] } [/block] Authorization should be included in all Merchant API requests. For brevity, we've removed it from sample API requests in this documentation, but know that it should be included!