{"info":{"_postman_id":"806c6289-b529-4c47-aeea-2f2ffba7b285","name":"Foxy hAPI","description":"<html><head></head><body><p>Example requests for interacting with the <a href=\"https://api.foxycart.com\">Foxy Hypermedia API</a>, including viewing/filtering transactions and creating/update/deleting coupons.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"3967924","collectionId":"806c6289-b529-4c47-aeea-2f2ffba7b285","publishedId":"RW1hhvWk","public":true,"customColor":null,"publishDate":"2018-05-09T08:59:26.000Z"},"item":[{"name":"OAuth","item":[{"name":"Refresh Access Token","event":[{"listen":"prerequest","script":{"type":"text/javascript","exec":["pm.environment.set(\"basic_auth\", btoa(pm.environment.get(\"client_id\")+\":\"+pm.environment.get(\"client_secret\")));"]}},{"listen":"test","script":{"type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (data.hasOwnProperty(\"access_token\")) {","    // Save the access token","    pm.environment.set(\"access_token\", data.access_token);","}"]}}],"id":"85ba3ad2-b278-4e0f-a35c-1c6e10633612","request":{"method":"POST","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Basic {{basic_auth}}"}],"body":{"mode":"formdata","formdata":[{"key":"grant_type","value":"refresh_token","type":"text"},{"key":"refresh_token","value":"{{refresh_token}}","type":"text"}]},"url":"https://api.foxycart.com/token","description":"<p>As Access Tokens only last for 2 hours, you will need to create new ones using the Refresh Token. This call passes the necessary information to the token endpoint to generate a new Access Token, saving it into the environment variable.</p>\n","urlObject":{"protocol":"https","path":["token"],"host":["api","foxycart","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"85ba3ad2-b278-4e0f-a35c-1c6e10633612"}],"id":"8d4f5a4c-1e9f-43fb-aabe-f8970dd0cfc7","_postman_id":"8d4f5a4c-1e9f-43fb-aabe-f8970dd0cfc7","description":""},{"name":"Home","item":[{"name":"API Home","event":[{"listen":"test","script":{"type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (data.hasOwnProperty(\"_links\") && data[\"_links\"].hasOwnProperty(\"fx:store\")) {","    // Bookmark the store URI","    pm.environment.set(\"store_uri\", data[\"_links\"][\"fx:store\"][\"href\"]);","}"]}}],"id":"fe72d0b5-b3a5-41a2-b1e3-b39663fd3ab7","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"https://api.foxycart.com","description":"<p>Fetches the API Homepage - the base for accessing all areas available via the scope of the Access Token</p>\n","urlObject":{"protocol":"https","host":["api","foxycart","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"fe72d0b5-b3a5-41a2-b1e3-b39663fd3ab7"},{"name":"Store Home","event":[{"listen":"test","script":{"id":"13f84bd2-404a-4de9-9289-ea9476b8c0f6","type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (data.hasOwnProperty(\"_links\")) {","    // Bookmark the relevant URI's","    pm.environment.set(\"transactions_uri\", data[\"_links\"][\"fx:transactions\"][\"href\"]);","    pm.environment.set(\"subscriptions_uri\", data[\"_links\"][\"fx:subscriptions\"][\"href\"]);","    pm.environment.set(\"coupons_uri\", data[\"_links\"][\"fx:coupons\"][\"href\"]);","    pm.environment.set(\"categories_uri\", data[\"_links\"][\"fx:item_categories\"][\"href\"]);","    pm.environment.set(\"error_entries_uri\", data[\"_links\"][\"fx:error_entries\"][\"href\"]);","}"]}}],"id":"bd2fc826-53bc-48bf-bcd5-c5af88f32271","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{store_uri}}","description":"<p>The store resource, providing access to all areas of a single store.</p>\n","urlObject":{"host":["{{store_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"bd2fc826-53bc-48bf-bcd5-c5af88f32271"}],"id":"c890b04a-e8fc-457a-abbb-cd93e36b8d5b","_postman_id":"c890b04a-e8fc-457a-abbb-cd93e36b8d5b","description":""},{"name":"Transactions","item":[{"name":"All Transactions","event":[{"listen":"test","script":{"type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (data.returned_items > 0) {","    // Bookmark the relevant URI's","    pm.environment.set(\"transaction_uri\", data[\"_embedded\"][\"fx:transactions\"][0][\"_links\"][\"self\"][\"href\"]);","    pm.environment.set(\"transaction_attributes_uri\", data[\"_embedded\"][\"fx:transactions\"][0][\"_links\"][\"fx:attributes\"][\"href\"]);","}"]}}],"id":"1d76ea56-41b5-4f75-8adb-a225f16dfd3a","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{transactions_uri}}","urlObject":{"host":["{{transactions_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"1d76ea56-41b5-4f75-8adb-a225f16dfd3a"},{"name":"Transactions Filtered By Order Total","id":"5e329086-b992-4e24-9a64-2b91cc4ac199","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{transactions_uri}}?order_total=10..50&zoom=items","urlObject":{"host":["{{transactions_uri}}"],"query":[{"key":"order_total","value":"10..50"},{"key":"zoom","value":"items"}],"variable":[]}},"response":[],"_postman_id":"5e329086-b992-4e24-9a64-2b91cc4ac199"},{"name":"Add Attribute To Transaction","event":[{"listen":"test","script":{"type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (pm.response.code == 201) {","    // Bookmark the new coupon URI","    pm.environment.set(\"transaction_attribute_uri\", data[\"_links\"][\"self\"][\"href\"]);","}"]}}],"id":"b98e9a7a-8bf5-4c96-9598-29aa88d9fff8","request":{"method":"POST","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"name\": \"Postman Attribute\",\n\t\"value\": \"This was created via the hAPI using Postman\"\n}"},"url":"{{transaction_attributes_uri}}","urlObject":{"host":["{{transaction_attributes_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"b98e9a7a-8bf5-4c96-9598-29aa88d9fff8"},{"name":"View New Attribute","id":"4aea828d-d09e-4e3d-ac1d-5d6220eab565","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{transaction_attribute_uri}}","urlObject":{"host":["{{transaction_attribute_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"4aea828d-d09e-4e3d-ac1d-5d6220eab565"},{"name":"Replace Transaction Attribute","id":"388ce2ce-7d48-4ba9-bf67-49ba4b06b547","request":{"method":"PUT","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"visibility\": \"private\",\n\t\"name\": \"Postman Attribute\",\n\t\"value\": \"This was updated via a PUT request using Postman\"\n}"},"url":"{{transaction_attribute_uri}}","urlObject":{"host":["{{transaction_attribute_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"388ce2ce-7d48-4ba9-bf67-49ba4b06b547"},{"name":"Update Transaction Attribute","id":"bb135364-5024-4b7b-9323-f35374cbccd8","request":{"method":"PATCH","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"value\": \"This was updated via a PATCH request using Postman\"\n}"},"url":"{{transaction_attribute_uri}}","urlObject":{"host":["{{transaction_attribute_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"bb135364-5024-4b7b-9323-f35374cbccd8"},{"name":"Delete Transaction Attribute","event":[{"listen":"test","script":{"type":"text/javascript","exec":["if (pm.response.code == 200) {","    pm.environment.unset(\"transaction_attribute_uri\");","}"]}}],"id":"c292f6f7-3ff2-4ce5-9f1b-c18c787bee1c","request":{"method":"DELETE","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"raw","raw":""},"url":"{{transaction_attribute_uri}}","urlObject":{"host":["{{transaction_attribute_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"c292f6f7-3ff2-4ce5-9f1b-c18c787bee1c"}],"id":"33e560dd-1618-43ae-b69e-9f2979ecc396","_postman_id":"33e560dd-1618-43ae-b69e-9f2979ecc396","description":""},{"name":"Subscriptions","item":[{"name":"All Subscriptions","event":[{"listen":"test","script":{"id":"694bee9a-f462-43c9-b0f2-7df3b1140362","type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (data.returned_items > 0) {","    // Bookmark the relevant URI's","    pm.environment.set(\"subscription_uri\", data[\"_embedded\"][\"fx:subscriptions\"][0][\"_links\"][\"self\"][\"href\"]);","}"]}}],"id":"63771e5e-06a3-4357-a7d9-7a3f395d7da8","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{subscriptions_uri}}","urlObject":{"host":["{{subscriptions_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"63771e5e-06a3-4357-a7d9-7a3f395d7da8"},{"name":"View Subscription","event":[{"listen":"test","script":{"id":"023fe84f-0502-4ce2-9922-12f87ac20a87","type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (pm.response.code == 200) {","    // Bookmark the relevant URI's","    pm.environment.set(\"subscription_item_uri\", data[\"_embedded\"][\"fx:transaction_template\"][\"_embedded\"][\"fx:items\"][0][\"_links\"][\"self\"][\"href\"]);","}"]}}],"id":"fbf0e64c-17c6-4cc8-8e1a-fad7ec983b5b","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{subscription_uri}}?zoom=transaction_template:items,customer:default_shipping_address","urlObject":{"host":["{{subscription_uri}}"],"query":[{"key":"zoom","value":"transaction_template:items,customer:default_shipping_address"}],"variable":[]}},"response":[],"_postman_id":"fbf0e64c-17c6-4cc8-8e1a-fad7ec983b5b"},{"name":"View Subscription Item","event":[{"listen":"test","script":{"id":"ab553890-4fbf-433c-9e00-7c8d7488feb0","type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (data.returned_items > 0) {","    // Bookmark the relevant URI's","    pm.environment.set(\"subscription_item_uri\", data[\"_embedded\"][\"fx:transaction_template\"][\"_embedded\"][\"fx:items\"][0][\"_links\"][\"self\"][\"href\"]);","}"]}}],"id":"5a1ead6c-5c3a-465d-9271-103ccc259a48","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{subscription_item_uri}}","urlObject":{"host":["{{subscription_item_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"5a1ead6c-5c3a-465d-9271-103ccc259a48"},{"name":"Update Subscription Item","event":[{"listen":"test","script":{"id":"2ac8e31e-8527-434a-b65f-489048d76b38","type":"text/javascript","exec":[""]}}],"id":"6e651795-2549-43a8-ab94-921e0eee1df4","request":{"method":"PATCH","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"price\": 12.34,\n\t\"discount_name\": \"Postman Discount\",\n    \"discount_type\": \"quantity_amount\",\n    \"discount_details\": \"1-2\"\n}"},"url":"{{subscription_item_uri}}","urlObject":{"host":["{{subscription_item_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"6e651795-2549-43a8-ab94-921e0eee1df4"}],"id":"0c46ce10-230d-4e2b-8781-cf365b5774fb","_postman_id":"0c46ce10-230d-4e2b-8781-cf365b5774fb","description":""},{"name":"Coupons","item":[{"name":"All Coupons","id":"5c66f67e-ebb9-41db-908d-6abc024d1c92","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{coupons_uri}}","urlObject":{"host":["{{coupons_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"5c66f67e-ebb9-41db-908d-6abc024d1c92"},{"name":"Add New Coupon","event":[{"listen":"test","script":{"type":"text/javascript","exec":["var data = JSON.parse(responseBody);","if (pm.response.code == 201) {","    // Bookmark the new coupon URI","    pm.environment.set(\"postman_coupon_uri\", data[\"_links\"][\"self\"][\"href\"]);","    pm.environment.set(\"postman_coupon_codes_uri\", data[\"_links\"][\"fx:coupon_codes\"][\"href\"]);","}"]}}],"id":"4f773df6-81d5-44df-9ce4-b3b29b9f5efc","request":{"method":"POST","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"name\": \"Postman Coupon\",\n\t\"coupon_discount_type\": \"quantity_amount\",\n\t\"coupon_discount_details\": \"2-5\",\n\t\"number_of_uses_allowed\": 100,\n\t\"combinable\": true\n}"},"url":"{{coupons_uri}}","urlObject":{"host":["{{coupons_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"4f773df6-81d5-44df-9ce4-b3b29b9f5efc"},{"name":"Add Coupon Codes","id":"c5816185-2704-4723-b351-51bd70a4bcff","request":{"method":"POST","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"coupon_codes\": [\n        \"postman\",\n        \"postman-code\"\n    ]\n}"},"url":"{{postman_coupon_codes_uri}}","urlObject":{"host":["{{postman_coupon_codes_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"c5816185-2704-4723-b351-51bd70a4bcff"},{"name":"View New Coupon","id":"84fc3ed0-f532-46a0-9d58-7e583aa33ad3","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{postman_coupon_uri}}?zoom=coupon_codes","urlObject":{"host":["{{postman_coupon_uri}}"],"query":[{"key":"zoom","value":"coupon_codes"}],"variable":[]}},"response":[],"_postman_id":"84fc3ed0-f532-46a0-9d58-7e583aa33ad3"},{"name":"Update Coupon","id":"f63d4574-381d-4603-b597-2ffeb5e4b20a","request":{"method":"PATCH","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"coupon_discount_type\": \"quantity_percentage\",\n\t\"combinable\": false\n}"},"url":"{{postman_coupon_uri}}","urlObject":{"host":["{{postman_coupon_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"f63d4574-381d-4603-b597-2ffeb5e4b20a"},{"name":"Delete Coupon","event":[{"listen":"test","script":{"type":"text/javascript","exec":["if (pm.response.code == 200) {","    pm.environment.unset(\"postman_coupon_uri\");","    pm.environment.unset(\"postman_coupon_codes_uri\");","}"]}}],"id":"e37c2730-86be-408f-bdaa-6dd162c35dba","request":{"method":"DELETE","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"raw","raw":""},"url":"{{postman_coupon_uri}}","urlObject":{"host":["{{postman_coupon_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"e37c2730-86be-408f-bdaa-6dd162c35dba"}],"id":"09297338-bba4-4220-a13f-24a52e0525db","_postman_id":"09297338-bba4-4220-a13f-24a52e0525db","description":""},{"name":"Errors","item":[{"name":"All Errors","id":"c3115405-2c08-475c-a425-e7c50d96a10f","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{error_entries_uri}}","urlObject":{"host":["{{error_entries_uri}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"c3115405-2c08-475c-a425-e7c50d96a10f"},{"name":"Errors Filtered By Message","id":"97829e44-c545-44a9-9d44-45b1d489fe80","request":{"method":"GET","header":[{"key":"FOXY-API-VERSION","value":"1"},{"key":"Authorization","value":"Bearer {{access_token}}"}],"body":{"mode":"formdata","formdata":[]},"url":"{{error_entries_uri}}?error_message=*error processing your payment*","urlObject":{"host":["{{error_entries_uri}}"],"query":[{"key":"error_message","value":"*error processing your payment*"}],"variable":[]}},"response":[],"_postman_id":"97829e44-c545-44a9-9d44-45b1d489fe80"}],"id":"7a19c1cc-f980-4b25-80f5-2c62c315bea1","_postman_id":"7a19c1cc-f980-4b25-80f5-2c62c315bea1","description":""}]}