{"id":10982,"date":"2019-08-13T14:44:16","date_gmt":"2019-08-13T14:44:16","guid":{"rendered":"https:\/\/www.mageworx.com\/blog\/?p=10982"},"modified":"2022-05-16T11:57:19","modified_gmt":"2022-05-16T11:57:19","slug":"api-requests-for-mageworx-reward-points-extension","status":"publish","type":"post","link":"https:\/\/www.mageworx.com\/blog\/api-requests-for-mageworx-reward-points-extension","title":{"rendered":"API Requests for Mageworx Reward Points Extension"},"content":{"rendered":"\n<!-- SEO Ultimate (http:\/\/www.seodesignsolutions.com\/wordpress-seo\/) - Code Inserter module -->\n<!-- Google Tag Manager (noscript) -->\r\n<noscript><iframe src=\"https:\/\/www.googletagmanager.com\/ns.html?id=GTM-5DTCW7B8\"\r\nheight=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"><\/iframe><\/noscript>\r\n<!-- End Google Tag Manager (noscript) -->\n<!-- \/SEO Ultimate -->\n\n<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p>Within one of the recent <a href=\"https:\/\/www.mageworx.com\/magento-2-reward-points.html\">Reward Points extension <\/a>updates, support of REST API requests has been added. REST API requests allow dealing with internal customer credits in 3rd-party systems on the fly. Additionally, with their help, you get to easily integrate Magento 2 with other systems and 3rd-party front-ends, such as mobile apps, for example.<br><\/p>\n\n\n\n<p>In this article, we will guide you through the available REST API requests and explain how they can come in handy. All requests can be divided into two groups. The first group helps interact with the Reward Points extension in the shopping cart. The second group of requests w ill help us either find out or <a href=\"https:\/\/www.mageworx.com\/magento2-order-editor-extension.html\" data-type=\"URL\" data-id=\"https:\/\/www.mageworx.com\/magento2-order-editor-extension.html\">edit<\/a> customer reward points balances.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Available REST API Requests<\/strong><br><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Shopping Cart-Related Requests<\/strong><br><\/h3>\n\n\n\n<p>Let me repeat myself, the first group of requests includes those that allow adding reward points to the shopping cart. PUT request will be of help here. It allows adding reward points to cart by specifying cart_id (quote_id) in the endpoint, as well as the quantity of used reward points.<br><\/p>\n\n\n\n<p>You can also include \u2018all\u2019 (instead of a fixed number of applied reward points) in the endpoint. Thus, all available points will get applied to the shopping cart. Here\u2019s how such requests will look like:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>PUT <code>V1\/mw-rewardpoints\/carts\/74\/points\/3<\/code> -&gt; Add Reward Points to the Shopping Cart (Add the certain number of the Reward Points to the shopping cart. Use admin Token. Specify cart_id and amount of Reward Points in the endpoint.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1164\" height=\"378\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10986\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1.png 1164w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1-600x195.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1-768x249.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1-250x81.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1-696x226.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/1-1068x347.png 1068w\" sizes=\"auto, (max-width: 1164px) 100vw, 1164px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>PUT <code>\/V1\/mw-rewardpoints\/carts\/74\/points\/all<\/code> -&gt; Add all Reward Points to the Shopping Cart (Add all Reward Points to the shopping cart. Use admin Token and specify cart_id in the endpoint).<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1164\" height=\"394\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10987\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1.png 1164w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1-600x203.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1-768x260.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1-250x85.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1-696x236.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/3-1-1068x362.png 1068w\" sizes=\"auto, (max-width: 1164px) 100vw, 1164px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>PUT <code>\/V1\/mw-rewardpoints\/mine\/points\/3<\/code> -&gt; Add Reward Points to the Customer Shopping Cart (Add the certain number of the Reward Points to the shopping cart. Use Customer Token. Specify amount of Reward Points in the endpoint.)<\/li><li> PUT <code>\/V1\/mw-rewardpoints\/mine\/points\/all<\/code> -&gt; Add all Reward Points to the Customer Shopping Cart (Add all Reward Points to the shopping cart. Use Customer Token.)<\/li><\/ul>\n\n\n\n<p>You might have noticed that the last two requests differ from the preceding ones. In them, a bind to \u2018Customer Shopping Cart\u2019 instead of cart_id is used. Also, the \u2018mine\u2019 value is used in the endpoint.<\/p>\n\n\n\n<p>Additionally, DELETE requests naturally help delete the applied reward points from the shopping cart. That said, you can include either cart_id or \u2018mine\u2019 in the endpoint. Such requests look as follows:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>DELETE <code>\/V1\/mw-rewardpoints\/carts\/74\/points<\/code> -&gt; Delete Reward Points from the shopping cart (Remove the Reward Points from the shopping cart. Use admin Token and specify cart_id in the endpoint.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1164\" height=\"394\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10988\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1.png 1164w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1-600x203.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1-768x260.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1-250x85.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1-696x236.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/5-1-1068x362.png 1068w\" sizes=\"auto, (max-width: 1164px) 100vw, 1164px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>DELETE <code>\/V1\/mw-rewardpoints\/mine\/points<\/code> -&gt; Delete Reward Points from the customer shopping cart (Remove the Reward Points from the shopping cart. Use Customer Token.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1162\" height=\"386\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10989\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1.png 1162w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1-600x199.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1-768x255.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1-250x83.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1-696x231.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/6-1-1068x355.png 1068w\" sizes=\"auto, (max-width: 1162px) 100vw, 1162px\" \/><\/figure>\n\n\n\n<p>GET requests will be the last ones in this group. They can help you find out the number of reward points that have been applied in the shopping cart.<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>GET <code>\/V1\/mw-rewardpoints\/carts\/74\/points<\/code> -&gt; Receive applied Reward Points to the cart (Receive the Reward Points which were applied in the shopping cart. Use admin Token and specify cart_id in the endpoint.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1391\" height=\"449\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10990\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1.png 1391w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-600x194.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-1200x387.png 1200w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-768x248.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-250x81.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-696x225.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-1068x345.png 1068w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/7-1-1301x420.png 1301w\" sizes=\"auto, (max-width: 1391px) 100vw, 1391px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>GET <code>\/V1\/mw-rewardpoints\/mine\/points<\/code> -&gt; Receive applied Reward Points to the shopping cart (Receive the Reward Points which were applied in the shopping cart. Use Customer Token.)<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Requests Related to Reward Points Editing<\/strong><br><\/h3>\n\n\n\n<p>Let\u2019s proceed to the second group of requests. It includes such requests as POST and GET. With their help, we can find out the current reward points balance of a specific customer in a particular Magento 2 store, as well as edit this balance. Let\u2019s get into details.<br><\/p>\n\n\n\n<p>With the help of the GET request \u2015 after specifying customer_id and website_id in the endpoint \u2015 you can find out reward points balance for a particular shopper.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>GET <code>\/V1\/mw-rewardpoints\/balance\/customer\/1\/website\/1<\/code> -&gt; Receive customer balance for Reward Points (Receive customer balance for Reward Points considering website ID and customer ID in the endpoint.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1326\" height=\"478\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10991\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1.png 1326w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-600x216.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-1200x433.png 1200w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-768x277.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-250x90.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-696x251.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-1068x385.png 1068w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/8-1-1165x420.png 1165w\" sizes=\"auto, (max-width: 1326px) 100vw, 1326px\" \/><\/figure>\n\n\n\n<p>POST request allows changing a customer reward points balance. For that, you\u2019ll need to include \u2018customer_id\u2019, \u2018website_id\u2019 and \u2018points\u2019 quantity in the request body.<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>POST <code>\/V1\/mw-rewardpoints\/balance<\/code> -&gt; Change Customer Balance (Change customer balance for Reward Points considering website ID and customer ID in the BODY request.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1323\" height=\"555\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10992\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1.png 1323w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-600x252.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-1200x503.png 1200w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-768x322.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-250x105.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-696x292.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-1068x448.png 1068w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/9-1-1001x420.png 1001w\" sizes=\"auto, (max-width: 1323px) 100vw, 1323px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1549\" height=\"451\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10994\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1.png 1549w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-600x175.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-1200x349.png 1200w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-768x224.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-250x73.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-696x203.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-1068x311.png 1068w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/10-1-1443x420.png 1443w\" sizes=\"auto, (max-width: 1549px) 100vw, 1549px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1543\" height=\"566\" src=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1.png\" alt=\"API Requests for MageWorx Reward Points Extension | MageWorx Magento Blog\" class=\"wp-image-10995\" srcset=\"https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1.png 1543w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-600x220.png 600w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-1200x440.png 1200w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-768x282.png 768w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-250x92.png 250w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-696x255.png 696w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-1068x392.png 1068w, https:\/\/www.mageworx.com\/blog\/wp-content\/uploads\/2019\/08\/11-1-1145x420.png 1145w\" sizes=\"auto, (max-width: 1543px) 100vw, 1543px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>Within one of the recent Reward Points extension updates, support of REST API requests has been added. REST API requests allow dealing with internal customer credits in 3rd-party systems on the fly. Additionally, with their help, you get to easily integrate Magento 2 with other systems and 3rd-party front-ends, such as mobile apps, for example. [&hellip;]<\/p>\n","protected":false},"author":38,"featured_media":10983,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[255,426],"tags":[197],"class_list":{"0":"post-10982","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-magento-2","8":"category-extensions-tips-and-tricks","9":"tag-customer-loyalty"},"_links":{"self":[{"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/posts\/10982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/comments?post=10982"}],"version-history":[{"count":8,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/posts\/10982\/revisions"}],"predecessor-version":[{"id":15999,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/posts\/10982\/revisions\/15999"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/media\/10983"}],"wp:attachment":[{"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/media?parent=10982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/categories?post=10982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mageworx.com\/blog\/wp-json\/wp\/v2\/tags?post=10982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}