{"_id":"58dc363bd82dc30f00571c6d","__v":0,"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":[],"next":{"pages":[],"description":""},"createdAt":"2017-03-29T22:33:31.475Z","link_external":false,"link_url":"","githubsync":"","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\nAfter you receive a username and password to the API from the Cratejoy support team, you'll need to put an encoded version of it in the headers, as we do below.\n\nNeed help encoding your username and password?\n* You can use [Base64Encode.org.](http://base64encode.org) Simply encode the username and password you got from Cratejoy support in the form of my_user_name:my_password, and use the value it outputs.\n* You can use Python, like below, to encode the username and password you got from Cratejoy support.\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]\nOnce you have the encoded version of your API username and password, you're ready to send it as an authorization key in the headers.\n\nBelow is what that might look like. You'll want to replace 'Basic c3Vtb2plcmt5X3BldGVyOnN1bW9qZXJreV9wZXRlcg==' with your base64 encoded username and password.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/shipments/62619521654545/',\\n    headers: {\\n        'Authorization': 'Basic c3Vtb2plcmt5X3BldGVyOnN1bW9qZXJreV9wZXRlcg==',\\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. After you receive a username and password to the API from the Cratejoy support team, you'll need to put an encoded version of it in the headers, as we do below. Need help encoding your username and password? * You can use [Base64Encode.org.](http://base64encode.org) Simply encode the username and password you got from Cratejoy support in the form of my_user_name:my_password, and use the value it outputs. * You can use Python, like below, to encode the username and password you got from Cratejoy support. [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] Once you have the encoded version of your API username and password, you're ready to send it as an authorization key in the headers. Below is what that might look like. You'll want to replace 'Basic c3Vtb2plcmt5X3BldGVyOnN1bW9qZXJreV9wZXRlcg==' with your base64 encoded username and password. [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/shipments/62619521654545/',\n headers: {\n 'Authorization': 'Basic c3Vtb2plcmt5X3BldGVyOnN1bW9qZXJreV9wZXRlcg==',\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!