{"_id":"58112e72ded0340f0085d03a","__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-25T18:29:51.493Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","examples":{"codes":[]},"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":11,"body":"Methods for [Subscription data objects](doc:subscription) \n\n# [List all subscriptions, or get/modify a subscription](http://docs.cratejoy.com/docs/subscription-methods#section-list-subscriptions) \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/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    https://api.cratejoy.com/v1/subscriptions/{sub_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    https://api.cratejoy.com/v1/subscriptions/{sub_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n# [Cancel, reactivate, skip, or renew a subscription](http://docs.cratejoy.com/docs/subscription-methods#section-cancel-a-subscription) \n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/subscriptions/{sub_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   https://api.cratejoy.com/v1/subscriptions/{sub_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    \\nhttps://api.cratejoy.com/v1/subscriptions/{sub_id}/skip/\\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    \\nhttps://api.cratejoy.com/v1/subscriptions/{sub_id}/renew/\\n  </span>\\n</div>\"\n}\n[/block]\n# [Listing, applying, or removing coupons from subscriptions](http://docs.cratejoy.com/docs/subscription-methods#listing-adding-and-removing-subscription-coupons) \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/subscriptions/{sub_id}/coupons/\\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/subscriptions/{sub_id}/coupons/\\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/subscriptions/{sub_id}/coupon/{coupon_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n# Create, get, or delete subscription metadata\n\nThese endpoints operate on the [subscription metadata](doc:subscription-metadata-3) 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/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   https://api.cratejoy.com/v1/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   https://api.cratejoy.com/v1/subscriptions/{sub_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n# List subscriptions\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/subscriptions/\\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/subscriptions/',\\n    method: 'GET'\\n});\",\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:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 22, \\n  \\\"next\\\": \\\"?page=1\\\", \\n  \\\"prev\\\": null, \\n  \\\"results\\\": [{\\n    \\\"autorenew\\\": true, \\n    \\\"billing\\\": {...}, // Billing relation property\\n   \\t\\\"billing_name\\\": \\\"Monthly\\\",\\n    \\\"credit\\\": null, \\n    \\\"customer\\\": {...}, // Customer relation property \\n    \\\"end_date\\\": \\\"2015-10-15T20:00:24Z\\\", \\n    \\\"id\\\": 75562148, \\n    \\\"is_test\\\": true, \\n    \\\"note\\\": null, \\n    \\\"product_billing_id\\\": 55065955, \\n    \\\"skipped_date\\\": null, \\n    \\\"start_date\\\": \\\"2015-09-15T20:00:24Z\\\", \\n    \\\"status\\\": \\\"active\\\", \\n    \\\"store_id\\\": 4848355, \\n    \\\"term\\\": {...}, // Term relation property \\n    \\\"type\\\": \\\"subscription\\\",\\n    \\\"url\\\": \\\"/v1/subscriptions/75562148\\\"\\n  }]\\n}             \",\n      \"language\": \"json\",\n      \"name\": \"Response: 200 OK\"\n    }\n  ]\n}\n[/block]\n# Get subscription\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/subscriptions/{sub_id}\\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/subscriptions/75562148/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n# Update subscription\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/subscriptions/{sub_id}/\\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/subscriptions/75562148/',\\n    method: 'PUT',\\n    data: {\\n      note: \\\"A new note\\\"\\n    }\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n# Cancel a subscription\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/subscriptions/{sub_id}/cancel\\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/subscriptions/75562148/cancel/',\\n    method: 'PUT',\\n    data: {\\n      \\\"log_note\\\": \\\"A new note\\\"\\n    }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n# Reactivate a subscription\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/subscriptions/{sub_id}/reactivate/\\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/subscriptions/75562148/reactivate/',\\n    method: 'PUT',\\n    data: {\\n      log_note: \\\"A new note\\\"\\n    }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n# Skip a subscription's next renewal\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/subscriptions/{sub_id}/skip/\\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/subscriptions/75562148/skip/',\\n    method: 'PUT',\\n    data: {\\n      skip: \\\"true\\\"\\n    }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## Unskip a subscription\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/subscriptions/75562148/skip/',\\n    method: 'PUT',\\n    data: {\\n      unskip: \\\"true\\\"\\n    }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n# Renew a subscription\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    https://api.cratejoy.com/v1/subscriptions/{sub_id}/renew/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"\",\n  \"body\": \"Only works with past due subscriptions that failed to renew in the past 30 days.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/subscriptions/75562148/renew/',\\n    method: 'PUT',\\n    data: {\\n      log_note: \\\"A new note\\\"\\n    }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Listing, adding, and removing subscription coupons\"\n}\n[/block]\nSubscription coupons are coupons that apply on a subscription's next renewal or a cancelled or expired subscription's reactivation. They can be added or even removed from a subscription, because *they haven't yet been applied to an order.* This makes them helpful for running reactivation campaigns. For more on subscription coupons, please refer to the [Subscription Coupons](doc:subscription-coupons) subresource.\n\n# List coupons on a subscription\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/subscriptions/{sub_id}/coupons/\\n  </span>\\n</div>\"\n}\n[/block]\nThis will only list coupons that apply on the subscription's next renewal (i.e., can be modified). \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 1,\\n  \\\"next\\\": null,\\n  \\\"prev\\\": null,\\n  \\\"results\\\": [\\n    {\\n      \\\"code_used\\\": \\\"1234COUPON\\\",\\n      \\\"coupon_id\\\": 713852368,\\n      \\\"enabled\\\": true,\\n      \\\"id\\\": 723378616,\\n      \\\"num_renewals\\\": 0, \\n      \\\"type\\\": \\\"subscription_coupon\\\",\\n      \\\"url\\\": \\\"/v1/subscriptions/723378616/\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"Response 200 OK\"\n    }\n  ]\n}\n[/block]\n# Add a coupon to a subscription\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/subscriptions/{sub_id}/coupons/\\n  </span>\\n</div>\"\n}\n[/block]\nHere, you can apply a subscription coupon to a subscription that will apply on the next renewal. The only required parameter is `coupon_id`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/subscriptions/75562148/coupons/',\\n    method: 'POST',\\n    data: {\\n      coupon_id: 34526674\\n    }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"code_used\\\": \\\"1234COUPON\\\",\\n  \\\"coupon_id\\\": 756026933,\\n  \\\"enabled\\\": true,\\n  \\\"id\\\": 756027331,\\n  \\\"num_renewals\\\": 0,\\n  \\\"type\\\": \\\"subscription_coupon\\\",\\n  \\\"url\\\": \\\"/v1/subscriptions/756027331/\\\"\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"Response: 200 OK\"\n    },\n    {\n      \"code\": \"// If the subscription already has the coupon applied\\n\\n{\\n  \\\"errors\\\": [\\n    \\\"Subscription already has the coupon.\\\"\\n  ]\\n}\\n\\n// If the coupon is unable to be applied to the subscription. Could be because the coupon isn't enabled, or doesn't apply to the subscription product.\\n\\n{\\n  \\\"errors\\\": [\\n    \\\"Unable to add coupon.\\\"\\n  ]\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"Response: 400 BAD REQUEST\"\n    },\n    {\n      \"code\": \"// If the coupon ID doesn't match a coupon in your store\\n{\\n  \\\"errors\\\": [\\n    \\\"Coupon not found\\\"\\n  ]\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"Response: 404 NOT FOUND\"\n    }\n  ]\n}\n[/block]\n# Delete a coupon from a subscription\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/subscriptions/{sub_id}/coupon/{coupon_id}/\\n  </span>\\n</div>\"\n}\n[/block]","excerpt":"","slug":"subscription-methods","type":"basic","title":"Subscription Methods"}

Subscription Methods


Methods for [Subscription data objects](doc:subscription) # [List all subscriptions, or get/modify a subscription](http://docs.cratejoy.com/docs/subscription-methods#section-list-subscriptions) [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/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 https://api.cratejoy.com/v1/subscriptions/{sub_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 https://api.cratejoy.com/v1/subscriptions/{sub_id}/\n </span>\n</div>" } [/block] # [Cancel, reactivate, skip, or renew a subscription](http://docs.cratejoy.com/docs/subscription-methods#section-cancel-a-subscription) [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_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 https://api.cratejoy.com/v1/subscriptions/{sub_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 \nhttps://api.cratejoy.com/v1/subscriptions/{sub_id}/skip/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n \nhttps://api.cratejoy.com/v1/subscriptions/{sub_id}/renew/\n </span>\n</div>" } [/block] # [Listing, applying, or removing coupons from subscriptions](http://docs.cratejoy.com/docs/subscription-methods#listing-adding-and-removing-subscription-coupons) [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/coupons/\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/subscriptions/{sub_id}/coupons/\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/subscriptions/{sub_id}/coupon/{coupon_id}/\n </span>\n</div>" } [/block] # Create, get, or delete subscription metadata These endpoints operate on the [subscription metadata](doc:subscription-metadata-3) 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/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 https://api.cratejoy.com/v1/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 https://api.cratejoy.com/v1/subscriptions/{sub_id}/metadata/\n </span>\n</div>" } [/block] # List subscriptions [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/',\n method: 'GET'\n});", "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:code] { "codes": [ { "code": "{\n \"count\": 22, \n \"next\": \"?page=1\", \n \"prev\": null, \n \"results\": [{\n \"autorenew\": true, \n \"billing\": {...}, // Billing relation property\n \t\"billing_name\": \"Monthly\",\n \"credit\": null, \n \"customer\": {...}, // Customer relation property \n \"end_date\": \"2015-10-15T20:00:24Z\", \n \"id\": 75562148, \n \"is_test\": true, \n \"note\": null, \n \"product_billing_id\": 55065955, \n \"skipped_date\": null, \n \"start_date\": \"2015-09-15T20:00:24Z\", \n \"status\": \"active\", \n \"store_id\": 4848355, \n \"term\": {...}, // Term relation property \n \"type\": \"subscription\",\n \"url\": \"/v1/subscriptions/75562148\"\n }]\n} ", "language": "json", "name": "Response: 200 OK" } ] } [/block] # Get subscription [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/',\n method: 'GET'\n});", "language": "javascript", "name": null } ] } [/block] # Update subscription [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/',\n method: 'PUT',\n data: {\n note: \"A new note\"\n }\n});", "language": "javascript", "name": null } ] } [/block] # Cancel a subscription [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/cancel\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/cancel/',\n method: 'PUT',\n data: {\n \"log_note\": \"A new note\"\n }\n});", "language": "javascript" } ] } [/block] # Reactivate a subscription [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/reactivate/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/reactivate/',\n method: 'PUT',\n data: {\n log_note: \"A new note\"\n }\n});", "language": "javascript" } ] } [/block] # Skip a subscription's next renewal [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/skip/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/skip/',\n method: 'PUT',\n data: {\n skip: \"true\"\n }\n});", "language": "javascript" } ] } [/block] ## Unskip a subscription [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/skip/',\n method: 'PUT',\n data: {\n unskip: \"true\"\n }\n});", "language": "javascript" } ] } [/block] # Renew a subscription [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/renew/\n </span>\n</div>" } [/block] [block:callout] { "type": "info", "title": "", "body": "Only works with past due subscriptions that failed to renew in the past 30 days." } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/renew/',\n method: 'PUT',\n data: {\n log_note: \"A new note\"\n }\n});", "language": "javascript" } ] } [/block] [block:api-header] { "title": "Listing, adding, and removing subscription coupons" } [/block] Subscription coupons are coupons that apply on a subscription's next renewal or a cancelled or expired subscription's reactivation. They can be added or even removed from a subscription, because *they haven't yet been applied to an order.* This makes them helpful for running reactivation campaigns. For more on subscription coupons, please refer to the [Subscription Coupons](doc:subscription-coupons) subresource. # List coupons on a subscription [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/coupons/\n </span>\n</div>" } [/block] This will only list coupons that apply on the subscription's next renewal (i.e., can be modified). [block:code] { "codes": [ { "code": "{\n \"count\": 1,\n \"next\": null,\n \"prev\": null,\n \"results\": [\n {\n \"code_used\": \"1234COUPON\",\n \"coupon_id\": 713852368,\n \"enabled\": true,\n \"id\": 723378616,\n \"num_renewals\": 0, \n \"type\": \"subscription_coupon\",\n \"url\": \"/v1/subscriptions/723378616/\"\n }\n ]\n}", "language": "javascript", "name": "Response 200 OK" } ] } [/block] # Add a coupon to a subscription [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/coupons/\n </span>\n</div>" } [/block] Here, you can apply a subscription coupon to a subscription that will apply on the next renewal. The only required parameter is `coupon_id`. [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/subscriptions/75562148/coupons/',\n method: 'POST',\n data: {\n coupon_id: 34526674\n }\n});", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"code_used\": \"1234COUPON\",\n \"coupon_id\": 756026933,\n \"enabled\": true,\n \"id\": 756027331,\n \"num_renewals\": 0,\n \"type\": \"subscription_coupon\",\n \"url\": \"/v1/subscriptions/756027331/\"\n}", "language": "javascript", "name": "Response: 200 OK" }, { "code": "// If the subscription already has the coupon applied\n\n{\n \"errors\": [\n \"Subscription already has the coupon.\"\n ]\n}\n\n// If the coupon is unable to be applied to the subscription. Could be because the coupon isn't enabled, or doesn't apply to the subscription product.\n\n{\n \"errors\": [\n \"Unable to add coupon.\"\n ]\n}", "language": "javascript", "name": "Response: 400 BAD REQUEST" }, { "code": "// If the coupon ID doesn't match a coupon in your store\n{\n \"errors\": [\n \"Coupon not found\"\n ]\n}", "language": "javascript", "name": "Response: 404 NOT FOUND" } ] } [/block] # Delete a coupon from a subscription [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method delete\">DELETE</span>\n <span class=\"uri\">\n https://api.cratejoy.com/v1/subscriptions/{sub_id}/coupon/{coupon_id}/\n </span>\n</div>" } [/block]