{"_id":"55fc9b7d3c21291900e7e0f0","parentDoc":null,"project":"5553d36165e8260d0024419a","__v":0,"category":{"_id":"55fc9b7a3c21291900e7e0dd","__v":1,"pages":["55fc9b7d3c21291900e7e0ef","55fc9b7d3c21291900e7e0f0","55fc9b7d3c21291900e7e0f1","55fc9b7d3c21291900e7e0f2"],"version":"55fc9b793c21291900e7e0d7","project":"5553d36165e8260d0024419a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-13T22:52:32.399Z","from_sync":false,"order":5,"slug":"work-flows","title":"Work Flows"},"user":"5553d33065e8260d00244199","version":{"_id":"55fc9b793c21291900e7e0d7","__v":12,"project":"5553d36165e8260d0024419a","createdAt":"2015-09-18T23:17:13.545Z","releaseDate":"2015-09-18T23:17:13.545Z","categories":["55fc9b7a3c21291900e7e0d8","55fc9b7a3c21291900e7e0d9","55fc9b7a3c21291900e7e0da","55fc9b7a3c21291900e7e0db","55fc9b7a3c21291900e7e0dc","55fc9b7a3c21291900e7e0dd","55fc9b7a3c21291900e7e0de","55fc9b7a3c21291900e7e0df","55fc9b7a3c21291900e7e0e0","55fc9b7a3c21291900e7e0e1","55fc9b7a3c21291900e7e0e2","55fc9b7a3c21291900e7e0e3","55fc9bad4c80910d00b9bece","56394a0c3539050d00082122","56394a2f68b11f0d0048c9ff","56394a462fc5520d001a4db3","56394a4c2fc5520d001a4db4","56394a5b049e420d00476b5c","56394a6a2fc5520d001a4db5","56394f791593e4190073a44b","567b3adfb56bac0d0019d8d9","569d590e5a2b060d008741eb","569ea93dffccd10d00a05c7f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-14T20:19:32.540Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Using the [Conditions Handler](doc:handling-api-call-conditions-alerts-errors-and-var) you can set variables for a particular Work Flow that can be passed between API calls in the Work Flow.\n\nVariables set in a Work Flow only are persistent inside the Work Flow.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example - Extracting a Variable from an API\"\n}\n[/block]\nIn this example, we are looking up a Daily Deal from a retail API, extracting the ID number for an item and then looking up that item.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/FiarGnWWRXKqb9PSSimq_workflow3.jpg\",\n        \"workflow3.jpg\",\n        \"976\",\n        \"168\",\n        \"#4ea4bc\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIn the first API Call to the Daily Deals API, we are setting the Variable DEALPARTNUMBER in the Conditions tab of the API call.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/FA7C3EKhSsmU4FpvRk9k_workflow4.jpg\",\n        \"workflow4.jpg\",\n        \"1058\",\n        \"220\",\n        \"#47646f\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe condition:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"product.0.PartNumber exists\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\nis seeking the first item in the product list of returned JSON:\n\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"HTTP/1.1 200 status\\nAccess-Control-Allow-Credentials: true\\nAccess-Control-Allow-Headers: Origin, Content-Type, Accept\\nApiname: deals\\nAppid: sonoa_portal\\nContent-Type: application/json;charset=UTF-8\\nDate: Sat, 16 May 2015 18:06:15 GMT\\nFromcache: N\\nServer: Apache\\nSessionkey: \\nUniqreqid: 3492791850859034244\\nContent-Length: 9992\\nConnection: keep-alive\\nAge: 604\\nX-Google-Cache-Control: remote-cache-hit\\nVia: HTTP/1.1 GWA (remote cache hit)\\n\\n{  \\n\\t\\\"start_time\\\":\\\"00:00:00\\\",\\n\\t\\\"end_time\\\":\\\"23:59:59\\\",\\n\\t\\\"sub_header\\\":\\\"\\\",\\n\\t\\\"social_header\\\":\\\"\\\",\\n\\t\\\"future_option\\\":\\\"0\\\",\\n\\t\\\"future_title\\\":\\\"\\\",\\n\\t\\\"related_header\\\":\\\"\\\",\\n        \\\"sneak_peak_img\\\":\\\"http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_1252387812\\\",\\n\\t\\\"products\\\":\\n\\t[\\n\\t\\t\\n\\t\\t{\\n\\t\\t\\t\\\"PartNumber\\\":\\\"00624988000P\\\",\\n\\t\\t\\t\\\"ItemPNO\\\":\\\"00624988000\\\",\\n\\t\\t\\t\\\"ProductURL\\\":\\\"/nordictrack-c-700-treadmill\\\",\\n\\t\\t\\t\\\"SEOURL\\\":\\\"http://www.sears.com/nordictrack-c-700-treadmill/p-00624988000P\\\",\\n\\t\\t\\t\\\"BrandName\\\":\\\"NordicTrack\\\",\\n\\t\\t\\t\\\"Headline\\\":\\\"\\\",\\n\\t\\t\\t\\\"Subheading\\\":\\\"\\\",\\n\\t\\t\\t\\\"DescriptionName\\\":\\\"C 700 Treadmill\\\",\\n\\t\\t\\t\\\"LongDescription\\\":\\\"\\\",\\n\\t\\t\\t\\\"MainImageUrl\\\":\\\"http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_882013012\\\",\\n\\t\\t\\t\\\"ImageURLs\\\":\\\"http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_882013012http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_882012912http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_898893812http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_898893912http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_898894012http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_900954112http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_926100912\\\",\\n\\t\\t\\t\\\"SoldOut\\\":\\\"1\\\",\\n\\t\\t\\t\\\"FreeShipping\\\":\\\"0\\\",\\n\\t\\t\\t\\\"FreeShippingExclusions\\\":\\\"\\\",\\n\\t\\t\\t\\\"SYWR\\\":\\\"0\\\",\\n\\t\\t\\t\\\"SYWRExclusions\\\":\\\"\\\",\\n\\t\\t\\t\\\"CraftsmanClub\\\":\\\"0\\\",\\n\\t\\t\\t\\\"CraftsmanClubExclusions\\\":\\\"\\\",\\n\\t\\t\\t\\\"ShipVantage\\\":\\\"0\\\",\\n\\t\\t\\t\\\"ShipVantageExclusions\\\":\\\"\\\",\\n\\t\\t\\t\\\"SalePrice\\\":\\\"759.99\\\",\\n\\t\\t\\t\\\"RegularPrice\\\":\\\"1199.99\\\",\\n\\t\\t\\t\\\"AddToCart\\\":\\\"1\\\",\\n\\t\\t\\t\\\"AddToCartLink\\\":\\\"http://www.sears.com/shc/s/ProductOptionsOrderItemAddCmd?langId=-1&storeId=10153&catalogId=12605&catEntryId_1=44038586&URL=OrderItemDisplay&quantity_1=1\\\",\\n\\t\\t\\t\\\"Link\\\":\\\"http://www.sears.com/shc/s/p_10153_12605_00624988000P\\\",\\n\\t\\t\\t\\\"SRESEligible\\\":\\\"1\\\",\\n\\t\\t\\t\\\"Storepickupeligible\\\":\\\"1\\\",\\n\\t\\t\\t\\\"SPOption\\\":\\\"0\\\",\\n\\t\\t\\t\\\"StartTime\\\":\\\"\\\",\\n\\t\\t\\t\\\"SoldBy\\\":\\\"Sears\\\",\\n\\t\\t\\t\\\"Category\\\":\\\"\\\",\\n\\t\\t\\t\\\"Occasion\\\":\\\"\\\",\\n\\t\\t\\t\\\"MemberPrice\\\":\\\"\\\",\\n\\t\\t\\t\\\"BonusMemberMessaging\\\":\\\"\\\",\\n\\t\\t\\t\\\"ExtraDescription\\\":\\\"\\\",\\n\\t\\t\\t\\\"IsMarketPlaceitem\\\":false,\\n\\t\\t\\t\\\"DealType\\\":\\\"\\\",\\n\\t\\t\\t\\\"FlagText\\\":\\\"\\\",\\n\\t\\t\\t\\\"FlagColor\\\":\\\"\\\"\\n\\t\\t},\\n\\t\\t\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe variable is then set to 00624988000P\n\nIn the subsequent call, the variable is handled in the parameters of the next call with format:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"__DEALPARTNUMBER__\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3h4nrfKkRHGINw5G65xp_workflow5.jpg\",\n        \"workflow5.jpg\",\n        \"998\",\n        \"463\",\n        \"#556799\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]","excerpt":"Passing variables between individual API calls in a Work Flow","slug":"passing-variables-between-api-calls-in-a-work-flow","type":"basic","title":"Variables in Work Flows"}

Variables in Work Flows

Passing variables between individual API calls in a Work Flow

Using the [Conditions Handler](doc:handling-api-call-conditions-alerts-errors-and-var) you can set variables for a particular Work Flow that can be passed between API calls in the Work Flow. Variables set in a Work Flow only are persistent inside the Work Flow. [block:api-header] { "type": "basic", "title": "Example - Extracting a Variable from an API" } [/block] In this example, we are looking up a Daily Deal from a retail API, extracting the ID number for an item and then looking up that item. [block:image] { "images": [ { "image": [ "https://files.readme.io/FiarGnWWRXKqb9PSSimq_workflow3.jpg", "workflow3.jpg", "976", "168", "#4ea4bc", "" ] } ] } [/block] In the first API Call to the Daily Deals API, we are setting the Variable DEALPARTNUMBER in the Conditions tab of the API call. [block:image] { "images": [ { "image": [ "https://files.readme.io/FA7C3EKhSsmU4FpvRk9k_workflow4.jpg", "workflow4.jpg", "1058", "220", "#47646f", "" ] } ] } [/block] The condition: [block:code] { "codes": [ { "code": "product.0.PartNumber exists", "language": "text" } ] } [/block] is seeking the first item in the product list of returned JSON: [block:code] { "codes": [ { "code": "HTTP/1.1 200 status\nAccess-Control-Allow-Credentials: true\nAccess-Control-Allow-Headers: Origin, Content-Type, Accept\nApiname: deals\nAppid: sonoa_portal\nContent-Type: application/json;charset=UTF-8\nDate: Sat, 16 May 2015 18:06:15 GMT\nFromcache: N\nServer: Apache\nSessionkey: \nUniqreqid: 3492791850859034244\nContent-Length: 9992\nConnection: keep-alive\nAge: 604\nX-Google-Cache-Control: remote-cache-hit\nVia: HTTP/1.1 GWA (remote cache hit)\n\n{ \n\t\"start_time\":\"00:00:00\",\n\t\"end_time\":\"23:59:59\",\n\t\"sub_header\":\"\",\n\t\"social_header\":\"\",\n\t\"future_option\":\"0\",\n\t\"future_title\":\"\",\n\t\"related_header\":\"\",\n \"sneak_peak_img\":\"http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_1252387812\",\n\t\"products\":\n\t[\n\t\t\n\t\t{\n\t\t\t\"PartNumber\":\"00624988000P\",\n\t\t\t\"ItemPNO\":\"00624988000\",\n\t\t\t\"ProductURL\":\"/nordictrack-c-700-treadmill\",\n\t\t\t\"SEOURL\":\"http://www.sears.com/nordictrack-c-700-treadmill/p-00624988000P\",\n\t\t\t\"BrandName\":\"NordicTrack\",\n\t\t\t\"Headline\":\"\",\n\t\t\t\"Subheading\":\"\",\n\t\t\t\"DescriptionName\":\"C 700 Treadmill\",\n\t\t\t\"LongDescription\":\"\",\n\t\t\t\"MainImageUrl\":\"http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_882013012\",\n\t\t\t\"ImageURLs\":\"http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_882013012http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_882012912http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_898893812http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_898893912http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_898894012http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_900954112http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_926100912\",\n\t\t\t\"SoldOut\":\"1\",\n\t\t\t\"FreeShipping\":\"0\",\n\t\t\t\"FreeShippingExclusions\":\"\",\n\t\t\t\"SYWR\":\"0\",\n\t\t\t\"SYWRExclusions\":\"\",\n\t\t\t\"CraftsmanClub\":\"0\",\n\t\t\t\"CraftsmanClubExclusions\":\"\",\n\t\t\t\"ShipVantage\":\"0\",\n\t\t\t\"ShipVantageExclusions\":\"\",\n\t\t\t\"SalePrice\":\"759.99\",\n\t\t\t\"RegularPrice\":\"1199.99\",\n\t\t\t\"AddToCart\":\"1\",\n\t\t\t\"AddToCartLink\":\"http://www.sears.com/shc/s/ProductOptionsOrderItemAddCmd?langId=-1&storeId=10153&catalogId=12605&catEntryId_1=44038586&URL=OrderItemDisplay&quantity_1=1\",\n\t\t\t\"Link\":\"http://www.sears.com/shc/s/p_10153_12605_00624988000P\",\n\t\t\t\"SRESEligible\":\"1\",\n\t\t\t\"Storepickupeligible\":\"1\",\n\t\t\t\"SPOption\":\"0\",\n\t\t\t\"StartTime\":\"\",\n\t\t\t\"SoldBy\":\"Sears\",\n\t\t\t\"Category\":\"\",\n\t\t\t\"Occasion\":\"\",\n\t\t\t\"MemberPrice\":\"\",\n\t\t\t\"BonusMemberMessaging\":\"\",\n\t\t\t\"ExtraDescription\":\"\",\n\t\t\t\"IsMarketPlaceitem\":false,\n\t\t\t\"DealType\":\"\",\n\t\t\t\"FlagText\":\"\",\n\t\t\t\"FlagColor\":\"\"\n\t\t},\n\t\t", "language": "json" } ] } [/block] The variable is then set to 00624988000P In the subsequent call, the variable is handled in the parameters of the next call with format: [block:code] { "codes": [ { "code": "__DEALPARTNUMBER__", "language": "curl" } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/3h4nrfKkRHGINw5G65xp_workflow5.jpg", "workflow5.jpg", "998", "463", "#556799", "" ] } ] } [/block]