{"_id":"58112e73ded0340f0085d073","category":{"_id":"58112e72ded0340f0085d030","version":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-25T20:14:44.667Z","from_sync":false,"order":4,"slug":"store-api-methods","title":"Store API Methods"},"__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"},"user":"55f2fd49b5b25021002b7dfd","project":"551e85be610f400d00837db7","parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-21T18:45:12.966Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"## Customer metadata sub-resources\n_See [Customer Metadata](doc:customer-metadata)._\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    https://yoursite.com/v1/store/api/customer/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method post\\\">POST</span>\\n  <span class=\\\"uri\\\">\\n    https://yoursite.com/v1/store/api/customer/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method delete\\\">DELETE</span>\\n  <span class=\\\"uri\\\">\\n    https://yoursite.com/v1/store/api/customer/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n# Get the customer's metadata\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    https://yoursite.com/v1/store/api/customer/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.get('/v1/store/api/customer/metadata/');\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"GET requests to the `/customer/metadata/` endpoint return 404 when the customer does not already have a metadata record. POSTing data to the same route will create one.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  created_at: '2015-08-15T17:06:18Z',\\n  updated_at: '2015-08-15T17:06:18Z',\\n  customer_id: 359835,\\n  store_id: 46981,\\n  data: {\\n    \\\"eye color\\\": \\\"green\\\",\\n    \\\"height\\\": \\\"6ft\\\",\\n    \\\"shirt size\\\": \\\"Large\\\"\\n  }\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Create or set the customer's metadata\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method post\\\">POST</span>\\n  <span class=\\\"uri\\\">\\n    https://yoursite.com/v1/store/api/customer/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/customer/metadata/',\\n    contentType: 'application/json',\\n    type: 'POST',\\n    data: JSON.stringify({'eye color': 'green'}),\\n    success: function(data) {\\n        console.log(data);\\n    }\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"POST requests to the metadata endpoints will overwrite any existing records.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  created_at: '2015-08-15T17:06:18Z',\\n  updated_at: '2015-08-15T17:06:18Z',\\n  customer_id: 359835,\\n  store_id: 46981,\\n  data: {\\n    \\\"eye color\\\": \\\"green\\\",\\n    \\\"height\\\": \\\"6ft\\\",\\n    \\\"shirt size\\\": \\\"Large\\\"\\n  }\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Delete customer metadata\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method delete\\\">Delete</span>\\n  <span class=\\\"uri\\\">\\n    https://yoursite.com/v1/store/api/customer/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/customer/metadata/',\\n    contentType: 'application/json',\\n    type: 'DELETE',\\n    success: function(data) {\\n        console.log(data);\\n    }\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n### Response\n`204 No Content`","excerpt":"","slug":"customer-metadata-3","type":"basic","title":"Customer Methods"}
## Customer metadata sub-resources _See [Customer Metadata](doc:customer-metadata)._ [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://yoursite.com/v1/store/api/customer/metadata/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n https://yoursite.com/v1/store/api/customer/metadata/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method delete\">DELETE</span>\n <span class=\"uri\">\n https://yoursite.com/v1/store/api/customer/metadata/\n </span>\n</div>" } [/block] # Get the customer's metadata [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://yoursite.com/v1/store/api/customer/metadata/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.get('/v1/store/api/customer/metadata/');", "language": "javascript", "name": "List" } ] } [/block] [block:callout] { "type": "warning", "body": "GET requests to the `/customer/metadata/` endpoint return 404 when the customer does not already have a metadata record. POSTing data to the same route will create one." } [/block] [block:code] { "codes": [ { "code": "{\n created_at: '2015-08-15T17:06:18Z',\n updated_at: '2015-08-15T17:06:18Z',\n customer_id: 359835,\n store_id: 46981,\n data: {\n \"eye color\": \"green\",\n \"height\": \"6ft\",\n \"shirt size\": \"Large\"\n }\n}", "language": "javascript", "name": "200 OK" } ] } [/block] # Create or set the customer's metadata [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n https://yoursite.com/v1/store/api/customer/metadata/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/customer/metadata/',\n contentType: 'application/json',\n type: 'POST',\n data: JSON.stringify({'eye color': 'green'}),\n success: function(data) {\n console.log(data);\n }\n});", "language": "javascript", "name": null } ] } [/block] [block:callout] { "type": "warning", "body": "POST requests to the metadata endpoints will overwrite any existing records." } [/block] [block:code] { "codes": [ { "code": "{\n created_at: '2015-08-15T17:06:18Z',\n updated_at: '2015-08-15T17:06:18Z',\n customer_id: 359835,\n store_id: 46981,\n data: {\n \"eye color\": \"green\",\n \"height\": \"6ft\",\n \"shirt size\": \"Large\"\n }\n}", "language": "javascript", "name": "200 OK" } ] } [/block] # Delete customer metadata [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method delete\">Delete</span>\n <span class=\"uri\">\n https://yoursite.com/v1/store/api/customer/metadata/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/customer/metadata/',\n contentType: 'application/json',\n type: 'DELETE',\n success: function(data) {\n console.log(data);\n }\n});", "language": "javascript", "name": null } ] } [/block] ### Response `204 No Content`