{"_id":"58112e73ded0340f0085d074","project":"551e85be610f400d00837db7","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"},"__v":0,"user":"55f2fd49b5b25021002b7dfd","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"},"parentDoc":null,"updates":["5673dbd24b2a680d00524e7c","569b46bc2556330d005ff977"],"next":{"pages":[],"description":""},"createdAt":"2015-09-25T20:53:11.745Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"_Methods for getting / modifying a [Subscription](doc:subscription) from the Store API._\n\n# List all subscriptions, or get a subscription\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    \\t\\thttp://yoursite.com/v1/store/api/subscriptions/\\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   http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n# Cancel, reactivate, or skip a subscription\n_Cancel an active subscription, reactivate an inactive subscription, or skip/unskip the next renewal_.\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n   http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/cancel/\\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   http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/reactivate/\\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   http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/skip/\\n  </span>\\n</div>\"\n}\n[/block]\n# Create, update, or delete subscription metadata\n_See documentation for [Subscription Metadata](doc:subscription-metadata-3) for more details._\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    \\t\\thttp://yoursite.com/v1/store/api/subscriptions/{sub_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    http://yoursite.com/v1/store/api/subscriptions/{sub_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    http://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n# Get a subscription\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.get('/v1/store/api/subscriptions/75562148/');\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"autorenew\\\": true, \\n    \\\"billing\\\": {\\n      \\\"id\\\": 55065955, \\n      \\\"rebill_day\\\": 1, \\n      \\\"rebill_months\\\": 1, \\n      \\\"rebill_weeks\\\": null, \\n      \\\"rebill_window\\\": 10, \\n      \\\"store_id\\\": 4848355, \\n      \\\"type\\\": \\\"product_billing\\\"\\n    }, \\n    \\\"credit\\\": null, \\n    \\\"customer\\\": {\\n      \\\"country\\\": \\\"US\\\", \\n      \\\"email\\\": \\\"joey+2:::at:::cratejoy.com\\\", \\n      \\\"first_name\\\": \\\"Joey\\\", \\n      \\\"id\\\": 75561862, \\n      \\\"last_name\\\": \\\"Tallieu\\\", \\n      \\\"location\\\": \\\"TX, US\\\", \\n      \\\"name\\\": \\\"Joey Tallieu\\\", \\n      \\\"num_orders\\\": 21, \\n      \\\"num_subscriptions\\\": 21, \\n      \\\"store_settings\\\": null, \\n      \\\"subscription_status\\\": \\\"active\\\", \\n      \\\"total_revenue\\\": 26388, \\n      \\\"type\\\": \\\"customer\\\"\\n    }, \\n    \\\"end_date\\\": \\\"2015-09-15T20:00:24Z\\\", \\n    \\\"id\\\": 75562148, \\n    \\\"is_test\\\": true, \\n    \\\"note\\\": null, \\n    \\\"product_billing_id\\\": 55065955, \\n    \\\"revenue\\\": 1200, \\n    \\\"skipped_date\\\": null, \\n    \\\"start_date\\\": \\\"2015-09-15T20:00:24Z\\\", \\n    \\\"status\\\": \\\"active\\\", \\n    \\\"store_id\\\": 4848355, \\n    \\\"term\\\": {\\n      \\\"description\\\": \\\"Charged every month\\\", \\n      \\\"enabled\\\": true, \\n      \\\"id\\\": 55065958, \\n      \\\"name\\\": \\\"Month to Month\\\", \\n      \\\"num_cycles\\\": 1, \\n      \\\"type\\\": \\\"subscription_type_term\\\"\\n    }, \\n    \\\"type\\\": \\\"subscription\\\"\\n  }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n# Reactivate a subscription\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/subscriptions/75562148/reactivate/',\\n    contentType: 'application/json',\\n    type: 'PUT',\\n    data: JSON.stringify({log_note: \\\"Subscription reactivated using the Store API\\\"}),\\n    success: function(data) {\\n        console.log(data);\\n    }\\n});\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n# Cancel a subscription\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/subscriptions/75562148/cancel/',\\n    contentType: 'application/json',\\n    type: 'PUT',\\n    data: JSON.stringify({\\n \\tlog_note: \\\"Subscription canceled using the API\\\",\\n  cancel_reason: 5\\n}),\\n    success: function(data) {\\n        console.log(data);\\n    }\\n});\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n## Cancel Reasons\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Financial Reasons\",\n    \"0-1\": \"1\",\n    \"h-0\": \"Reason\",\n    \"h-1\": \"Value\",\n    \"1-0\": \"Just wanted to test it out\",\n    \"1-1\": \"2\",\n    \"2-0\": \"Accidentally ordered more than once\",\n    \"2-1\": \"3\",\n    \"3-0\": \"Planning on re-subscribing later\",\n    \"3-1\": \"4\",\n    \"4-0\": \"Shipping issues\",\n    \"4-1\": \"5\",\n    \"5-0\": \"Not worth the price\",\n    \"5-1\": \"6\",\n    \"6-0\": \"Did not like the product\",\n    \"6-1\": \"7\",\n    \"7-0\": \"Other service issues\",\n    \"7-1\": \"8\",\n    \"8-0\": \"Trying another service\",\n    \"8-1\": \"9\",\n    \"11-0\": \"I never wanted it to renew\",\n    \"11-1\": \"12\",\n    \"12-0\": \"You billed me twice before I received anything\",\n    \"12-1\": \"13\",\n    \"9-0\": \"Other\",\n    \"9-1\": \"10\",\n    \"10-0\": \"Canceled by merchant\",\n    \"10-1\": \"11\"\n  },\n  \"cols\": 2,\n  \"rows\": 13\n}\n[/block]\n# Skip a subscription\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/subscriptions/75562148/skip/',\\n    contentType: 'application/json',\\n    type: 'PUT',\\n    data: JSON.stringify({ skip: true }),\\n    success: function(data) {\\n        console.log(data);\\n    }\\n});\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n# Unskip a subscription\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/subscriptions/75562148/skip/',\\n    contentType: 'application/json',\\n    type: 'PUT',\\n    data: JSON.stringify({ unskip: true }),\\n    success: function(data) {\\n        console.log(data);\\n    }\\n});\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n# Get subscription metadata\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    \\t\\thttp://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.get('/v1/store/api/subscriptions/623645/metadata/');\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    },\n    {\n      \"code\": \"$.get('https://api.cratejoy.com/v1/customers/',{\\n  \\\"address.city\\\": \\\"Austin\\\",\\n  \\\"_md.shoe.size__gt\\\": 10\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Filter\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"GET requests to the `/subscriptions/{subscription_id}/metadata/` endpoint return 404 when the subscription 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  subscription_id: 623645,\\n  id: 75572794,\\n  data: {\\n    \\\"grate\\\": \\\"coarse\\\",\\n    \\\"flavor\\\": \\\"orange\\\"\\n  }\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Create or set subscription metadata\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method post\\\">POST</span>\\n  <span class=\\\"uri\\\">\\n    http://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/subscriptions/623645/metadata/',\\n    contentType: 'application/json',\\n    type: 'POST',\\n    data: JSON.stringify({\\\"grate\\\": \\\"coarse\\\", \\\"flavor\\\": \\\"orange\\\"}),\\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\": \"Subscription records can only have one metadata record. POSTing to the subscription metadata endpoint 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  subscription_id: 623645,\\n  id: 75572794,\\n  data: {\\n    \\\"grate\\\": \\\"coarse\\\",\\n    \\\"flavor\\\": \\\"orange\\\"\\n  }\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Delete subscription metadata\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method delete\\\">DELETE</span>\\n  <span class=\\\"uri\\\">\\n    http://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: '/v1/store/api/subscriptions/623645/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\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\\"No Content\\\"\",\n      \"language\": \"text\",\n      \"name\": \"204 No Content\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Filtering by Status\"\n}\n[/block]\nIf you want to filter by status, you have to use the integer value. For example: https://api.cratejoy.com/v1/subscriptions/?status__eq=2 rather than https://api.cratejoy.com/v1/subscriptions/?status__eq=active\n\nThe numeric values for each possible status are listed below.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"id\",\n    \"h-1\": \"name\",\n    \"0-0\": \"1\",\n    \"0-1\": \"unpaid\",\n    \"1-0\": \"2\",\n    \"1-1\": \"active\",\n    \"2-0\": \"3\",\n    \"2-1\": \"cancelled\",\n    \"3-0\": \"4\",\n    \"3-1\": \"suspended\",\n    \"4-0\": \"5\",\n    \"4-1\": \"expired\",\n    \"5-0\": \"6\",\n    \"5-1\": \"past_due\",\n    \"6-0\": \"7\",\n    \"6-1\": \"pending_renewal\",\n    \"7-0\": \"8\",\n    \"7-1\": \"renewing\",\n    \"8-0\": \"9\",\n    \"8-1\": \"unpaid_order_failed\"\n  },\n  \"cols\": 2,\n  \"rows\": 9\n}\n[/block]","excerpt":"","slug":"subscription-metadata-methods","type":"basic","title":"Subscription Methods"}

Subscription Methods


_Methods for getting / modifying a [Subscription](doc:subscription) from the Store API._ # List all subscriptions, or get a subscription [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n \t\thttp://yoursite.com/v1/store/api/subscriptions/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/\n </span>\n</div>" } [/block] # Cancel, reactivate, or skip a subscription _Cancel an active subscription, reactivate an inactive subscription, or skip/unskip the next renewal_. [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/cancel/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/reactivate/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n http://yoursite.com/v1/store/api/subscriptions/{subscription_id}/skip/\n </span>\n</div>" } [/block] # Create, update, or delete subscription metadata _See documentation for [Subscription Metadata](doc:subscription-metadata-3) for more details._ [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n \t\thttp://yoursite.com/v1/store/api/subscriptions/{sub_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 http://yoursite.com/v1/store/api/subscriptions/{sub_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 http://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\n </span>\n</div>" } [/block] # Get a subscription [block:code] { "codes": [ { "code": "$.get('/v1/store/api/subscriptions/75562148/');", "language": "text" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"autorenew\": true, \n \"billing\": {\n \"id\": 55065955, \n \"rebill_day\": 1, \n \"rebill_months\": 1, \n \"rebill_weeks\": null, \n \"rebill_window\": 10, \n \"store_id\": 4848355, \n \"type\": \"product_billing\"\n }, \n \"credit\": null, \n \"customer\": {\n \"country\": \"US\", \n \"email\": \"joey+2@cratejoy.com\", \n \"first_name\": \"Joey\", \n \"id\": 75561862, \n \"last_name\": \"Tallieu\", \n \"location\": \"TX, US\", \n \"name\": \"Joey Tallieu\", \n \"num_orders\": 21, \n \"num_subscriptions\": 21, \n \"store_settings\": null, \n \"subscription_status\": \"active\", \n \"total_revenue\": 26388, \n \"type\": \"customer\"\n }, \n \"end_date\": \"2015-09-15T20:00:24Z\", \n \"id\": 75562148, \n \"is_test\": true, \n \"note\": null, \n \"product_billing_id\": 55065955, \n \"revenue\": 1200, \n \"skipped_date\": null, \n \"start_date\": \"2015-09-15T20:00:24Z\", \n \"status\": \"active\", \n \"store_id\": 4848355, \n \"term\": {\n \"description\": \"Charged every month\", \n \"enabled\": true, \n \"id\": 55065958, \n \"name\": \"Month to Month\", \n \"num_cycles\": 1, \n \"type\": \"subscription_type_term\"\n }, \n \"type\": \"subscription\"\n }", "language": "json" } ] } [/block] # Reactivate a subscription [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/subscriptions/75562148/reactivate/',\n contentType: 'application/json',\n type: 'PUT',\n data: JSON.stringify({log_note: \"Subscription reactivated using the Store API\"}),\n success: function(data) {\n console.log(data);\n }\n});", "language": "text" } ] } [/block] # Cancel a subscription [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/subscriptions/75562148/cancel/',\n contentType: 'application/json',\n type: 'PUT',\n data: JSON.stringify({\n \tlog_note: \"Subscription canceled using the API\",\n cancel_reason: 5\n}),\n success: function(data) {\n console.log(data);\n }\n});", "language": "text" } ] } [/block] ## Cancel Reasons [block:parameters] { "data": { "0-0": "Financial Reasons", "0-1": "1", "h-0": "Reason", "h-1": "Value", "1-0": "Just wanted to test it out", "1-1": "2", "2-0": "Accidentally ordered more than once", "2-1": "3", "3-0": "Planning on re-subscribing later", "3-1": "4", "4-0": "Shipping issues", "4-1": "5", "5-0": "Not worth the price", "5-1": "6", "6-0": "Did not like the product", "6-1": "7", "7-0": "Other service issues", "7-1": "8", "8-0": "Trying another service", "8-1": "9", "11-0": "I never wanted it to renew", "11-1": "12", "12-0": "You billed me twice before I received anything", "12-1": "13", "9-0": "Other", "9-1": "10", "10-0": "Canceled by merchant", "10-1": "11" }, "cols": 2, "rows": 13 } [/block] # Skip a subscription [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/subscriptions/75562148/skip/',\n contentType: 'application/json',\n type: 'PUT',\n data: JSON.stringify({ skip: true }),\n success: function(data) {\n console.log(data);\n }\n});", "language": "text" } ] } [/block] # Unskip a subscription [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/subscriptions/75562148/skip/',\n contentType: 'application/json',\n type: 'PUT',\n data: JSON.stringify({ unskip: true }),\n success: function(data) {\n console.log(data);\n }\n});", "language": "text" } ] } [/block] # Get subscription metadata [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n \t\thttp://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.get('/v1/store/api/subscriptions/623645/metadata/');", "language": "javascript", "name": "List" }, { "code": "$.get('https://api.cratejoy.com/v1/customers/',{\n \"address.city\": \"Austin\",\n \"_md.shoe.size__gt\": 10\n});", "language": "javascript", "name": "Filter" } ] } [/block] [block:callout] { "type": "warning", "body": "GET requests to the `/subscriptions/{subscription_id}/metadata/` endpoint return 404 when the subscription 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 subscription_id: 623645,\n id: 75572794,\n data: {\n \"grate\": \"coarse\",\n \"flavor\": \"orange\"\n }\n}", "language": "javascript", "name": "200 OK" } ] } [/block] # Create or set subscription metadata [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n http://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/subscriptions/623645/metadata/',\n contentType: 'application/json',\n type: 'POST',\n data: JSON.stringify({\"grate\": \"coarse\", \"flavor\": \"orange\"}),\n success: function(data) {\n console.log(data);\n }\n});", "language": "javascript", "name": null } ] } [/block] [block:callout] { "type": "warning", "body": "Subscription records can only have one metadata record. POSTing to the subscription metadata endpoint 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 subscription_id: 623645,\n id: 75572794,\n data: {\n \"grate\": \"coarse\",\n \"flavor\": \"orange\"\n }\n}", "language": "javascript", "name": "200 OK" } ] } [/block] # Delete subscription metadata [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method delete\">DELETE</span>\n <span class=\"uri\">\n http://yoursite.com/v1/store/api/subscriptions/{sub_id}/metadata/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: '/v1/store/api/subscriptions/623645/metadata/',\n contentType: 'application/json',\n type: 'DELETE',\n success: function(data) {\n console.log(data);\n }\n});", "language": "javascript", "name": null } ] } [/block] [block:code] { "codes": [ { "code": "\"No Content\"", "language": "text", "name": "204 No Content" } ] } [/block] [block:api-header] { "type": "basic", "title": "Filtering by Status" } [/block] If you want to filter by status, you have to use the integer value. For example: https://api.cratejoy.com/v1/subscriptions/?status__eq=2 rather than https://api.cratejoy.com/v1/subscriptions/?status__eq=active The numeric values for each possible status are listed below. [block:parameters] { "data": { "h-0": "id", "h-1": "name", "0-0": "1", "0-1": "unpaid", "1-0": "2", "1-1": "active", "2-0": "3", "2-1": "cancelled", "3-0": "4", "3-1": "suspended", "4-0": "5", "4-1": "expired", "5-0": "6", "5-1": "past_due", "6-0": "7", "6-1": "pending_renewal", "7-0": "8", "7-1": "renewing", "8-0": "9", "8-1": "unpaid_order_failed" }, "cols": 2, "rows": 9 } [/block]