{"info":{"_postman_id":"934b10eb-66bc-4750-92fe-cc2787ac5e89","name":"Magento2 - Newsletter Endpoint","description":"<html><head></head><body><p>This is documentation of Magento2 extension, which adds 4 endpoints to handle newsletter subscription management.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"4376907","collectionId":"934b10eb-66bc-4750-92fe-cc2787ac5e89","publishedId":"TVsxCSUj","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2020-12-27T22:14:36.000Z"},"item":[{"name":"Subcribers List","event":[{"listen":"prerequest","script":{"id":"508c8e6d-c241-4556-8429-b1017385e5e8","exec":["var stores = [0,1,5,8];","var productIds = [20,23,26,29,32,35,38,41,44,47,50,53];","var products = [];","for(var a=1;a<2000;a++){","    let newProduct = { ","            \"product_id\": productIds[Math.floor(Math.random() * productIds.length)],","            \"store_id\": stores[Math.floor(Math.random() * stores.length)],","            \"attributes\": ","            [","                {  ","                    \"attribute_code\" : \"price\",","                    \"value\" : Math.floor(Math.random() * (100 - 5)) + 5","                }","            ]","    }","","    products.push(newProduct);","}","","let requestBody = {   ","    \"products\": products","}","","pm.variables.set(\"requestBody\", JSON.stringify(requestBody));"],"type":"text/javascript"}},{"listen":"test","script":{"id":"98a2959c-6afe-4180-a73f-d0b5c37084de","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","var template = `","    <table bgcolor=\"#FFFFFF\">","        <tr>","            <th>Name</th>","            <th>Email</th>","        </tr>","","        {{#each response}}","            <tr>","                <td>{{name}}</td>","                <td>{{email}}</td>","            </tr>","        {{/each}}","    </table>","`;"],"type":"text/javascript"}}],"id":"db87cf5c-dc56-41fb-8f82-78dd2b0346fc","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{token}}"}]},"isInherited":false},"method":"GET","header":[{"key":"Content-Type","name":"Content-Type","type":"text","value":"application/json"}],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscribers?searchCriteria","description":"<p>Lists subscribers saved in Magento with optional usage of Magento SearchCriteria to filter needed subscribers and apply pagination.</p>\n","urlObject":{"protocol":"http","path":["rest","all","V1","subscribers"],"host":["{{host}}"],"query":[{"key":"searchCriteria","value":null}],"variable":[]}},"response":[{"id":"279b45b1-efb7-4ea7-90b4-30e526dd21e0","name":"Get  subscribed subscribers","originalRequest":{"method":"GET","header":[{"key":"Content-Type","name":"Content-Type","type":"text","value":"application/json"}],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":{"raw":"http://{{host}}/rest/all/V1/subscribers?searchCriteria[filterGroups][0][filters][0][field]=subscriber_status&searchCriteria[filterGroups][0][filters][0][value]=1&searchCriteria[pageSize]=100&searchCriteria[currentPage]=1","protocol":"http","host":["{{host}}"],"path":["rest","all","V1","subscribers"],"query":[{"key":"searchCriteria[filterGroups][0][filters][0][field]","value":"subscriber_status","description":"Field to filter"},{"key":"searchCriteria[filterGroups][0][filters][0][value]","value":"1","description":"Field's value to fliter"},{"key":"searchCriteria[pageSize]","value":"100","description":"Page size"},{"key":"searchCriteria[currentPage]","value":"1","description":"Current page"}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Server","value":"nginx"},{"key":"Date","value":"Sun, 27 Dec 2020 21:10:55 GMT"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Transfer-Encoding","value":"chunked"},{"key":"Connection","value":"keep-alive"},{"key":"Vary","value":"Accept-Encoding"},{"key":"Expires","value":"Thu, 19 Nov 1981 08:52:00 GMT"},{"key":"Cache-Control","value":"no-store, no-cache, must-revalidate"},{"key":"Pragma","value":"no-cache"},{"key":"X-Frame-Options","value":"SAMEORIGIN"},{"key":"Content-Encoding","value":"gzip"}],"cookie":[],"responseTime":null,"body":"{\n    \"items\": [\n        {\n            \"subscriber_id\": \"4\",\n            \"store_id\": \"1\",\n            \"subscriber_email\": \"subscriber_1@example.com\",\n            \"change_status_at\": \"2020-09-23 10:05:56\",\n            \"subscriber_status\": 1,\n            \"subscriber_confirm_code\": \"0yvgpjl7ef7qc9ucnlbxpync0s3av3ac\"\n        },\n        {\n            \"subscriber_id\": \"5\",\n            \"store_id\": \"5\",\n            \"subscriber_email\": \"subscriber_2@example.com\",\n            \"change_status_at\": \"2020-09-23 10:15:22\",\n            \"subscriber_status\": 1,\n            \"subscriber_confirm_code\": \"vsjmmts2ota8azprsztq5cfubukwdpju\"\n        },\n        {\n            \"subscriber_id\": \"13\",\n            \"store_id\": \"0\",\n            \"subscriber_email\": \"subscriber_21@example.com\",\n            \"change_status_at\": \"2020-12-27 19:55:18\",\n            \"subscriber_status\": 1,\n            \"subscriber_confirm_code\": \"tyfg9sa2ewr9e1ctf861plbizgtqm3xz\"\n        }\n    ]\n}"}],"_postman_id":"db87cf5c-dc56-41fb-8f82-78dd2b0346fc"},{"name":"Subscriber Subscribe","event":[{"listen":"test","script":{"id":"7b685b59-756b-481e-9790-cbca224720a7","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Response contains subscribers email\", function () {","    const responseJson = pm.response.json();","    pm.expect(responseJson.subscriber_email).to.eql(pm.environment.get(\"email\"));","","    pm.environment.set(\"confirmation_code\", responseJson.subscriber_confirm_code);","    pm.environment.set(\"subscriber_id\", responseJson.subscriber_id);","});","","","","","var template = `","    <table bgcolor=\"#FFFFFF\">","        <tr>","            <th>Name</th>","            <th>Email</th>","        </tr>","","        {{#each response}}","            <tr>","                <td>{{name}}</td>","                <td>{{email}}</td>","            </tr>","        {{/each}}","    </table>","`;"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"97c07e4e-bf1b-4b9d-9da1-52eb98e91543","exec":["var stores = [0,1,5,8];","var productIds = [20,23,26,29,32,35,38,41,44,47,50,53];","var products = [];","for(var a=1;a<2000;a++){","    let newProduct = { ","            \"product_id\": productIds[Math.floor(Math.random() * productIds.length)],","            \"store_id\": stores[Math.floor(Math.random() * stores.length)],","            \"attributes\": ","            [","                {  ","                    \"attribute_code\" : \"price\",","                    \"value\" : Math.floor(Math.random() * (100 - 5)) + 5","                }","            ]","    }","","    products.push(newProduct);","}","","let requestBody = {   ","    \"products\": products","}","","pm.variables.set(\"requestBody\", JSON.stringify(requestBody));"],"type":"text/javascript"}}],"id":"8d1e42b0-ad5c-4c8a-9bd0-0515084388da","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{token}}"}]},"isInherited":false},"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"subscriber\": {\n        \"subscriber_email\" : \"{{email}}\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscriber","description":"<p>This requests subscribes e-mail address in Magento newsletter. Depending on settings you have in store (for example concerning double opt-in) - it will process it exactly as Magento Newsletter module would do.</p>\n<ul>\n<li>In case e-mail confirmation is required - it will send confirmation e-mail and set subscriber's status to <code>Not confrmed</code>.</li>\n<li>In case e-mail confirmation is not required - it will send welcome e-mail (if enabled) and set subscriber's status to <code>Confirmed</code></li>\n</ul>\n<p>⚠️ All events and triggers will be dispatched - so your third party integrations should work.</p>\n","urlObject":{"protocol":"http","path":["rest","all","V1","subscriber"],"host":["{{host}}"],"query":[],"variable":[]}},"response":[{"id":"1177ca00-301a-4420-a0d2-6c8ea9e2e1ab","name":"Subcribe new subscriber","originalRequest":{"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"subscriber\": {\n        \"subscriber_email\" : \"john.doe@example.com\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscriber"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Server","value":"nginx"},{"key":"Date","value":"Sun, 27 Dec 2020 19:53:27 GMT"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Transfer-Encoding","value":"chunked"},{"key":"Connection","value":"keep-alive"},{"key":"Vary","value":"Accept-Encoding"},{"key":"Expires","value":"Thu, 19 Nov 1981 08:52:00 GMT"},{"key":"Cache-Control","value":"no-store, no-cache, must-revalidate"},{"key":"Pragma","value":"no-cache"},{"key":"Set-Cookie","value":"PHPSESSID=90f5b6d273f824fab59484199d281ca7; expires=Sun, 27-Dec-2020 20:53:00 GMT; Max-Age=3600; path=/; domain=magesuite.me; HttpOnly"},{"key":"X-Frame-Options","value":"SAMEORIGIN"},{"key":"Content-Encoding","value":"gzip"}],"cookie":[],"responseTime":null,"body":"{\n    \"subscriber_id\": \"13\",\n    \"store_id\": \"0\",\n    \"subscriber_email\": \"john.doe@example.com\",\n    \"change_status_at\": \"2020-12-27 19:53:01\",\n    \"subscriber_status\": 2,\n    \"subscriber_confirm_code\": \"tyfg9sa2ewr9e1ctf861plbizgtqm3xz\"\n}"}],"_postman_id":"8d1e42b0-ad5c-4c8a-9bd0-0515084388da"},{"name":"Subscriber Confirm","event":[{"listen":"prerequest","script":{"id":"8dec7fc6-23bd-4de4-91dd-65082b10e423","exec":["var stores = [0,1,5,8];","var productIds = [20,23,26,29,32,35,38,41,44,47,50,53];","var products = [];","for(var a=1;a<2000;a++){","    let newProduct = { ","            \"product_id\": productIds[Math.floor(Math.random() * productIds.length)],","            \"store_id\": stores[Math.floor(Math.random() * stores.length)],","            \"attributes\": ","            [","                {  ","                    \"attribute_code\" : \"price\",","                    \"value\" : Math.floor(Math.random() * (100 - 5)) + 5","                }","            ]","    }","","    products.push(newProduct);","}","","let requestBody = {   ","    \"products\": products","}","","pm.variables.set(\"requestBody\", JSON.stringify(requestBody));"],"type":"text/javascript"}},{"listen":"test","script":{"id":"94833d50-ae3d-49a7-b514-ef466335003c","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","","});","","pm.test(\"Response contains subscribers email\", function () {","   const responseJson = pm.response.json();","   pm.expect(responseJson.subscriber_email).to.eql(pm.environment.get(\"email\"));;","","   pm.environment.set(\"confirmation_code\", responseJson.subscriber_confirm_code);","});","","","var template = `","    <table bgcolor=\"#FFFFFF\">","        <tr>","            <th>Name</th>","            <th>Email</th>","        </tr>","","        {{#each response}}","            <tr>","                <td>{{name}}</td>","                <td>{{email}}</td>","            </tr>","        {{/each}}","    </table>","`;"],"type":"text/javascript"}}],"id":"8b5ea3c6-89f5-4da8-bf9c-929b63a1b003","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{token}}"}]},"isInherited":false},"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","type":"text","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"confirmation_code\": \"{{confirmation_code}}\"\n}","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscriber/{{subscriber_id}}/confirm","description":"<p>This requests <em>confirms</em> subscriber in Magento newsletter (changes status from <code>Not confirmed</code> to <code>Confirmed</code>).</p>\n<p>It's equivalent of executing <code>Magento\\Newsletter\\Controller\\Subscriber\\Confirm</code> controller.</p>\n<p>⚠️ All events and triggers will be dispatched - so your third party integrations should work.</p>\n","urlObject":{"protocol":"http","path":["rest","all","V1","subscriber","{{subscriber_id}}","confirm"],"host":["{{host}}"],"query":[],"variable":[]}},"response":[{"id":"3243528f-c6aa-44fd-b99d-86edc3b7254e","name":"Confirms subscriber","originalRequest":{"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","type":"text","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"confirmation_code\": \"tyfg9sa2ewr9e****************\"\n}","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscriber/13/confirm"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Server","value":"nginx"},{"key":"Date","value":"Sun, 27 Dec 2020 19:55:48 GMT"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Transfer-Encoding","value":"chunked"},{"key":"Connection","value":"keep-alive"},{"key":"Vary","value":"Accept-Encoding"},{"key":"Expires","value":"Thu, 19 Nov 1981 08:52:00 GMT"},{"key":"Cache-Control","value":"no-store, no-cache, must-revalidate"},{"key":"Pragma","value":"no-cache"},{"key":"Set-Cookie","value":"PHPSESSID=90f5b6d273f824fab59484199d281ca7; expires=Sun, 27-Dec-2020 20:55:17 GMT; Max-Age=3600; path=/; domain=magesuite.me; HttpOnly"},{"key":"X-Frame-Options","value":"SAMEORIGIN"},{"key":"Content-Encoding","value":"gzip"}],"cookie":[],"responseTime":null,"body":"{\n    \"subscriber_id\": \"13\",\n    \"store_id\": \"0\",\n    \"subscriber_email\": \"john.doe@example.com\",\n    \"change_status_at\": \"2020-12-27 19:55:18\",\n    \"subscriber_status\": 1,\n    \"subscriber_confirm_code\": \"tyfg9sa2ewr9e****************\"\n}"}],"_postman_id":"8b5ea3c6-89f5-4da8-bf9c-929b63a1b003"},{"name":"Subscriber Unsubscribe","event":[{"listen":"test","script":{"id":"f21f50fc-666b-4a1a-8e7a-37c47ff8a4f8","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Response contains subscribers email\", function () {","   const responseJson = pm.response.json();","   pm.expect(responseJson.subscriber_email).to.eql(pm.environment.get(\"email\"));;","});","","pm.test(\"Unsubscribed email has status unsubscribed\", function () {","    const responseJson = pm.response.json();","    pm.expect(responseJson.subscriber_status).to.eql(3);","});"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"b8d7cbda-34d4-46da-9a8f-aa0fdf218577","exec":["var stores = [0,1,5,8];","var productIds = [20,23,26,29,32,35,38,41,44,47,50,53];","var products = [];","for(var a=1;a<2000;a++){","    let newProduct = { ","            \"product_id\": productIds[Math.floor(Math.random() * productIds.length)],","            \"store_id\": stores[Math.floor(Math.random() * stores.length)],","            \"attributes\": ","            [","                {  ","                    \"attribute_code\" : \"price\",","                    \"value\" : Math.floor(Math.random() * (100 - 5)) + 5","                }","            ]","    }","","    products.push(newProduct);","}","","let requestBody = {   ","    \"products\": products","}","","pm.variables.set(\"requestBody\", JSON.stringify(requestBody));"],"type":"text/javascript"}}],"id":"7e7fdaa8-dc67-4796-b5f6-1ae5b08d69f4","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{token}}"}]},"isInherited":false},"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","type":"text","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"confirmation_code\": \"{{confirmation_code}}\"\n}","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscriber/{{subscriber_id}}/unsubscribe","description":"<p>Performs subscriber's unsubsubscription process - status will change to <code>Unsubscribed (3)</code>.</p>\n<p>Will send e-mail if configured in Magento.</p>\n<p>⚠️ All events and triggers will be dispatched - so your third party integrations should work.</p>\n","urlObject":{"protocol":"http","path":["rest","all","V1","subscriber","{{subscriber_id}}","unsubscribe"],"host":["{{host}}"],"query":[],"variable":[]}},"response":[{"id":"08ea5375-74df-4e1a-9aa5-a520f8585e9d","name":"Unsubscribe subscriber","originalRequest":{"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","type":"text","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"confirmation_code\": \"test\"\n}","options":{"raw":{"language":"json"}}},"url":"http://{{host}}/rest/all/V1/subscriber/8/unsubscribe"},"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null}],"_postman_id":"7e7fdaa8-dc67-4796-b5f6-1ae5b08d69f4"}],"event":[{"listen":"prerequest","script":{"id":"5bbe6ac7-5edf-47cc-b004-be5d86a1e478","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"77db4875-e4b7-40af-b6cf-9f2ea2547f79","type":"text/javascript","exec":[""]}}]}