{"_id":"58112e72ded0340f0085d036","__v":0,"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"},"parentDoc":null,"project":"551e85be610f400d00837db7","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-25T14:11:34.665Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"The following methods operate on the [Customer data model](doc:customer-1).  \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/customers/\\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\\t\\thttps://api.cratejoy.com/v1/customers/{customer_id}/\\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\\t\\thttps://api.cratejoy.com/v1/customers/{customer_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n# Customer Addresses\n\nCustomer address subresource methods operate on the [Address data model](doc:customeraddress) and provide operations within the context of a [Customer](doc:customer-1)\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/customers/{customer_id}/addresses/\\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://api.cratejoy.com/v1/customers/{customer_id}/addresses/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Additional methods for [Address](doc:customeraddress) objects can be found at the [Address Methods page](doc:customer-address-methods).\"\n}\n[/block]\n# List customers\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/customers/\\n  </span>\\n</div>\\n\\n\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n  url: 'https://api.cratejoy.com/v1/customers/',\\n  method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 1, \\n  \\\"next\\\": \\\"?page=1\\\", \\n  \\\"prev\\\": null, \\n  \\\"results\\\": [\\n    {\\n      \\\"country\\\": \\\"US\\\", \\n      \\\"email\\\": \\\"user:::at:::cratejoy.com\\\", \\n      \\\"first_name\\\": \\\"John\\\", \\n      \\\"id\\\": 75561862, \\n      \\\"last_name\\\": \\\"Smith\\\", \\n      \\\"location\\\": \\\"TX, US\\\", \\n      \\\"name\\\": \\\"John Smith\\\", \\n      \\\"num_orders\\\": 20, \\n      \\\"num_subscriptions\\\": 20, \\n      \\\"subscription_status\\\": \\\"active\\\", \\n      \\\"total_revenue\\\": 25188, \\n      \\\"type\\\": \\\"customer\\\", \\n      \\\"url\\\": \\\"/v1/customers/75561862/\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response: 200 OK\"\n    }\n  ]\n}\n[/block]\n_See [Customer](doc:customer-1) documentation for a complete list of filters and relationships._\n\n# Get customer\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n\\t\\thttps://api.cratejoy.com/v1/customers/{customer_id}/\\n  </span>\\n</div>\\n\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n  url: 'https://api.cratejoy.com/v1/customers/75561862/',\\n  method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n# Update customer\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n\\t\\thttps://api.cratejoy.com/v1/customers/{customer_id}/\\n  </span>\\n</div>\\n\"\n}\n[/block]\nUpdates a customer with a given ID.  For a complete list of settable properties see the [Customer](doc:customer-1) documentation. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/customers/75561862/',\\n    method: 'PUT',\\n    data: {\\n\\t\\t\\tfirst_name: \\\"Jane\\\",\\n\\t\\t\\tlast_name: \\\"Smith\\\",\\n\\t\\t\\temail: \\\"janesmith@cratejoy.com\\\"\\n\\t\\t}\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n# List customer's addresses\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/customers/{customer_id}/addresses/\\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/customers/755342234/addresses/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    },\n    {\n      \"code\": \"$.get('https://api.cratejoy.com/v1/customers/75562245/addresses/',{\\n  \\\"zip_code__like\\\": \\\"787%\\\"\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Filter\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 1, \\n  \\\"next\\\": null, \\n  \\\"prev\\\": \\\"?page=1\\\", \\n  \\\"results\\\": [\\n    {\\n      \\\"city\\\": \\\"Austin\\\", \\n      \\\"company\\\": \\\"\\\", \\n      \\\"country\\\": \\\"US\\\", \\n      \\\"icon\\\": \\\"United-States.png\\\", \\n      \\\"id\\\": 75562247, \\n      \\\"phone_number\\\": \\\"\\\", \\n      \\\"state\\\": \\\"TX\\\", \\n      \\\"status\\\": 0, \\n      \\\"status_message\\\": null, \\n      \\\"street\\\": \\\"101 Main St\\\", \\n      \\\"to\\\": \\\"James Taylor\\\", \\n      \\\"type\\\": \\\"address\\\", \\n      \\\"unit\\\": \\\"\\\", \\n      \\\"url\\\": \\\"/v1/addresses/75562247\\\", \\n      \\\"zip_code\\\": \\\"78701\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"200 OK Response\"\n    }\n  ]\n}\n[/block]\n# Create new customer address\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method post\\\">POST</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/customers/{ID}/addresses/\\n  </span>\\n</div>\"\n}\n[/block]\nCreate an address for a customer.  Provide any of the non-readonly properties to create a new address.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/customers/755342234/addresses/',\\n    method: 'POST',\\n    data: {\\n        to: \\\"John Smith\\\",\\n      \\tstreet: \\\"2012 Northridge Dr\\\",\\n        city: \\\"Austin\\\",\\n        state: \\\"TX\\\",\\n        zip_code: \\\"78723\\\",\\n      \\tcountry: \\\"US\\\"\\n    },\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"city\\\": \\\"Austin\\\", \\n  \\\"company\\\": \\\"\\\", \\n  \\\"country\\\": \\\"US\\\", \\n  \\\"icon\\\": \\\"\\\",\\n  \\\"id\\\": 755622499, \\n  \\\"phone_number\\\": \\\"\\\", \\n  \\\"state\\\": \\\"TX\\\", \\n  \\\"status\\\": 0, \\n  \\\"status_message\\\": null, \\n  \\\"street\\\": \\\"2012 Northridge Dr\\\", \\n  \\\"to\\\": \\\"Clayton Nash\\\", \\n  \\\"type\\\": \\\"address\\\", \\n  \\\"unit\\\": \\\"\\\", \\n  \\\"zip_code\\\": \\\"78723\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response: 201 CREATED\"\n    }\n  ]\n}\n[/block]\n# Customer Metadata\n\nThese endpoints operate on the [Customer Metadata](doc:customer-metadata) subresource.\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/customers/{customer_id}/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://api.cratejoy.com/v1/customers/{customer_id}/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://api.cratejoy.com/v1/customers/{customer_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]","excerpt":"","slug":"methods-customer","type":"basic","title":"Customer Methods"}
The following methods operate on the [Customer data model](doc:customer-1). [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/customers/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n\t\thttps://api.cratejoy.com/v1/customers/{customer_id}/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n\t\thttps://api.cratejoy.com/v1/customers/{customer_id}/\n </span>\n</div>" } [/block] # Customer Addresses Customer address subresource methods operate on the [Address data model](doc:customeraddress) and provide operations within the context of a [Customer](doc:customer-1) [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/customers/{customer_id}/addresses/\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://api.cratejoy.com/v1/customers/{customer_id}/addresses/\n </span>\n</div>" } [/block] [block:callout] { "type": "info", "body": "Additional methods for [Address](doc:customeraddress) objects can be found at the [Address Methods page](doc:customer-address-methods)." } [/block] # List customers [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/customers/\n </span>\n</div>\n\n" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/customers/',\n method: 'GET'\n});", "language": "javascript", "name": "List" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 1, \n \"next\": \"?page=1\", \n \"prev\": null, \n \"results\": [\n {\n \"country\": \"US\", \n \"email\": \"user@cratejoy.com\", \n \"first_name\": \"John\", \n \"id\": 75561862, \n \"last_name\": \"Smith\", \n \"location\": \"TX, US\", \n \"name\": \"John Smith\", \n \"num_orders\": 20, \n \"num_subscriptions\": 20, \n \"subscription_status\": \"active\", \n \"total_revenue\": 25188, \n \"type\": \"customer\", \n \"url\": \"/v1/customers/75561862/\"\n }\n ]\n}", "language": "json", "name": "Response: 200 OK" } ] } [/block] _See [Customer](doc:customer-1) documentation for a complete list of filters and relationships._ # Get customer [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n\t\thttps://api.cratejoy.com/v1/customers/{customer_id}/\n </span>\n</div>\n" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/customers/75561862/',\n method: 'GET'\n});", "language": "javascript", "name": "Example" } ] } [/block] # Update customer [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n\t\thttps://api.cratejoy.com/v1/customers/{customer_id}/\n </span>\n</div>\n" } [/block] Updates a customer with a given ID. For a complete list of settable properties see the [Customer](doc:customer-1) documentation. [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/customers/75561862/',\n method: 'PUT',\n data: {\n\t\t\tfirst_name: \"Jane\",\n\t\t\tlast_name: \"Smith\",\n\t\t\temail: \"janesmith@cratejoy.com\"\n\t\t}\n});", "language": "javascript", "name": "Example" } ] } [/block] # List customer's addresses [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/customers/{customer_id}/addresses/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/customers/755342234/addresses/',\n method: 'GET'\n});", "language": "javascript", "name": "List" }, { "code": "$.get('https://api.cratejoy.com/v1/customers/75562245/addresses/',{\n \"zip_code__like\": \"787%\"\n});", "language": "javascript", "name": "Filter" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 1, \n \"next\": null, \n \"prev\": \"?page=1\", \n \"results\": [\n {\n \"city\": \"Austin\", \n \"company\": \"\", \n \"country\": \"US\", \n \"icon\": \"United-States.png\", \n \"id\": 75562247, \n \"phone_number\": \"\", \n \"state\": \"TX\", \n \"status\": 0, \n \"status_message\": null, \n \"street\": \"101 Main St\", \n \"to\": \"James Taylor\", \n \"type\": \"address\", \n \"unit\": \"\", \n \"url\": \"/v1/addresses/75562247\", \n \"zip_code\": \"78701\"\n }\n ]\n}", "language": "json", "name": "200 OK Response" } ] } [/block] # Create new customer address [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/customers/{ID}/addresses/\n </span>\n</div>" } [/block] Create an address for a customer. Provide any of the non-readonly properties to create a new address. [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/customers/755342234/addresses/',\n method: 'POST',\n data: {\n to: \"John Smith\",\n \tstreet: \"2012 Northridge Dr\",\n city: \"Austin\",\n state: \"TX\",\n zip_code: \"78723\",\n \tcountry: \"US\"\n },\n});", "language": "javascript", "name": "Example" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"city\": \"Austin\", \n \"company\": \"\", \n \"country\": \"US\", \n \"icon\": \"\",\n \"id\": 755622499, \n \"phone_number\": \"\", \n \"state\": \"TX\", \n \"status\": 0, \n \"status_message\": null, \n \"street\": \"2012 Northridge Dr\", \n \"to\": \"Clayton Nash\", \n \"type\": \"address\", \n \"unit\": \"\", \n \"zip_code\": \"78723\"\n}", "language": "json", "name": "Response: 201 CREATED" } ] } [/block] # Customer Metadata These endpoints operate on the [Customer Metadata](doc:customer-metadata) subresource. [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/customers/{customer_id}/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://api.cratejoy.com/v1/customers/{customer_id}/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://api.cratejoy.com/v1/customers/{customer_id}/metadata/\n </span>\n</div>" } [/block]