Use $.flow.suspend when you want to pause a workflow and proceed with the remaining steps only when manually approved or cancelled.For example, you can suspend a workflow and send yourself a link to manually resume or cancel the rest of the workflow:
export default defineComponent({ async run({ $ }) { const { resume_url, cancel_url } = $.flow.suspend(); $.send.email({ subject: "Please approve this important workflow", text: `Click here to approve the workflow: ${resume_url}, and cancel here: ${cancel_url}`, }); // Pipedream suspends your workflow at the end of the step },});
You’ll receive an email like this:
And can resume or cancel the rest of the workflow by clicking on the appropriate link.
In general, calling $.flow.suspend returns a cancel_url and resume_url that lets you cancel or resume paused executions. Since Pipedream pauses your workflow at the end of the step, you can pass these URLs to any external service before the workflow pauses. If that service accepts a callback URL, it can trigger the resume_url when its work is complete.These URLs are specific to a single execution of your workflow. While the workflow is paused, you can load these in your browser or send any HTTP request to them:
Sending an HTTP request to the cancel_url will cancel that execution
Sending an HTTP request to the resume_url will resume that execution
If you resume a workflow, any data sent in the HTTP request is passed to the workflow and returned in the $resume_datastep export of the suspended step. For example, if you call $.flow.suspend within a step named code, the $resume_data export should contain the data sent in the resume_url request:
By default, $.flow.suspend will automatically cancel the workflow after 24 hours. You can set your own timeout (in milliseconds) as the first argument:
Use $.flow.rerun when you want to run a specific step of a workflow multiple times. This is useful when you need to start a job in an external API and poll for its completion, or have the service call back to the step and let you process the HTTP request within the step.
$.flow.rerun can be used to conditionally retry a failed API request due to a service outage or rate limit reached. Place the $.flow.rerun call within a catch block to only retry the API request if an error is thrown:
import { axios } from "@pipedream/platform";export default defineComponent({ props: { openai: { type: "app", app: "openai", }, }, async run({ steps, $ }) { try { return await axios($, { url: `https://api.openai.com/v1/completions`, method: "post", headers: { Authorization: `Bearer ${this.openai.$auth.api_key}`, }, data: { model: "text-davinci-003", prompt: "Say this is a test", max_tokens: 7, temperature: 0, }, }); } catch (error) { const MAX_RETRIES = 3; const DELAY = 1000 * 30; // Retry the request every 30 seconds, for up to 3 times $.flow.rerun(DELAY, null, MAX_RETRIES); } },});
Sometimes you need to poll for the status of an external job until it completes. $.flow.rerun lets you rerun a specific step multiple times:
import axios from "axios";export default defineComponent({ async run({ $ }) { const MAX_RETRIES = 3; // 10 seconds const DELAY = 1000 * 10; const { run } = $.context; // $.context.run.runs starts at 1 and increments when the step is rerun if (run.runs === 1) { // $.flow.rerun(delay, context (discussed below), max retries) $.flow.rerun(DELAY, null, MAX_RETRIES); } else if (run.runs === MAX_RETRIES + 1) { throw new Error("Max retries exceeded"); } else { // Poll external API for status const { data } = await axios({ method: "GET", url: "https://example.com/status", }); // If we're done, continue with the rest of the workflow if (data.status === "DONE") return data; // Else retry later $.flow.rerun(DELAY, null, MAX_RETRIES); } },});
$.flow.rerun accepts the following arguments:
$.flow.rerun( delay, // The number of milliseconds until the step will be rerun context, // JSON-serializable data you need to pass between runs maxRetries // The total number of times the step will rerun. Defaults to 10);
When you trigger a job in an external service, and that service can send back data in an HTTP callback to Pipedream, you can process that data within the same step using $.flow.rerun:
import axios from "axios";export default defineComponent({ async run({ steps, $ }) { const TIMEOUT = 86400 * 1000; const { run } = $.context; // $.context.run.runs starts at 1 and increments when the step is rerun if (run.runs === 1) { const { cancel_url, resume_url } = $.flow.rerun(TIMEOUT, null, 1); // Send resume_url to external service await axios({ method: "POST", url: "your callback URL", data: { resume_url, cancel_url, }, }); } // When the external service calls back into the resume_url, you have access to // the callback data within $.context.run.callback_request else if (run.callback_request) { return run.callback_request; } },});
Within a Node.js code step, $.context.run.context contains the context passed from the prior call to rerun. This lets you pass data from one run to another. For example, if you call:
By default, maxRetries is 10.When you exceed maxRetries, the workflow proceeds to the next step. If you need to handle this case with an exception, throw an error from the step:
When you’re building a workflow and test a step with $.flow.suspend or $.flow.rerun, it will not suspend the workflow, and you’ll see a message like the following:
Workflow execution canceled — this may be due to $.flow.suspend() usage (not supported in test)
These functions will only suspend and resume when run in production.
You are not charged for the time your workflow is suspended during a $.flow.rerun or $.flow.suspend. Only when workflows are resumed will compute time count toward credit usage.
When a suspended workflow reawakens, it will reset the credit counter.Each rerun or reawakening from a suspension will count as a new fresh credit.
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Pipedream","colors":{"primary":"#095c32","light":"#19f995","dark":"#0f9954"},"logo":{"light":"https://mintcdn.com/pipedream/J-J7n6QGsUEW1AZY/logo/pipedream_workday_lockup.png?fit=max\u0026auto=format\u0026n=J-J7n6QGsUEW1AZY\u0026q=85\u0026s=20f01e899a0e49424e3d16d1e84adc60","dark":"https://mintcdn.com/pipedream/J-J7n6QGsUEW1AZY/logo/pipedream_workday_lockup_dark.png?fit=max\u0026auto=format\u0026n=J-J7n6QGsUEW1AZY\u0026q=85\u0026s=cc9220550d73764499689dbac60a3615","href":"https://pipedream.com/docs"},"favicon":"https://mintcdn.com/pipedream/l2pOewTBZm3Zi3d2/logo/pipedream_icon.svg?fit=max\u0026auto=format\u0026n=l2pOewTBZm3Zi3d2\u0026q=85\u0026s=561dca46a7ea8017f3146eb1899554a6","api":{"playground":{"display":"interactive"},"examples":{"defaults":"all","languages":["curl","typescript","python","java","go"]},"mdx":{"auth":{"method":"bearer"},"server":"https://api.pipedream.com/v1"}},"appearance":{"default":"system"},"background":{"decoration":"grid"},"navbar":{"links":[{"icon":"slack","href":"https://pipedream.com/join-slack","label":"Join community"}],"primary":{"type":"button","label":"Sign up for free","href":"https://pipedream.com/auth/signup"}},"footer":{"socials":{"github":"https://github.com/PipedreamHQ/pipedream","twitter":"https://twitter.com/pipedream","slack":"https://pipedream.com/join-slack"}},"seo":{"metatags":{"robots":"index, follow","charset":"UTF-8","viewport":"width=device-width, initial-scale=1.0","description":"Pipedream provides the toolkit to add thousands of integrations to your app and enables you to automate any process.","keywords":"api, mcp, ai, integrations, pipedream, workflow, automation, connect, apis","author":"Pipedream","googlebot":"index, follow","language":"en","og:type":"website","og:url":"https://pipedream.com","og:description":"Pipedream provides the toolkit to add thousands of integrations to your app and enables you to automate any process.","og:site_name":"Pipedream","og:locale":"en_US","twitter:card":"summary","twitter:site":"@pipedream","twitter:creator":"@pipedream","twitter:title":"Pipedream","twitter:description":"Pipedream provides the toolkit to add thousands of integrations to your app and enables you to automate any process.","twitter:image":"https://pipedream.com/image.jpg","twitter:image:alt":"Pipedream Logo","canonical":"https://pipedream.com/docs"}},"fonts":{"family":"Geist Sans","source":"https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/Geist-Variable.woff2","format":"woff2"},"styling":{"eyebrows":"breadcrumbs","latex":false},"contextual":{"options":["copy","view","chatgpt","claude","mcp"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"pipedream","hasAudioNarration":false,"actualSubdomain":"pipedream","customDomains":["pipedream.com"],"gitSource":{"_id":"6ad7fa91692c7c940ff17a0e","type":"github","owner":"pipedreamhq","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae3a5720a6b341ae2998df2","collectionId":"7ef074a5-8f02-412a-b9bc-10204278f6b8","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae3a5720a6b341ae2998df2"},"feedback":{"thumbs":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae3a5720a6b341ae2998df2","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"Connect","count":218},{"language":"default","tag":"Documentation","count":126},{"language":"default","tag":"Conduit","count":77},{"language":"default","tag":"Connect API","count":63},{"language":"default","tag":"Workflows","count":62},{"language":"default","tag":"Guides","count":41},{"language":"default","tag":"Building Workflows","count":39},{"language":"default","tag":"API","count":35},{"language":"default","tag":"Write your own code","count":22},{"language":"default","tag":"Platform","count":21}]},"assistantConfig":{"enableStarterQuestions":true,"deflection":{"enabled":true,"email":"support@pipedream.com"}},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[{"_id":"68eabbe039150a938c8e901c","deploymentId":"6852099e30dd5c4192fd61e1","questionText":"How do I get started with Pipedream Connect?","status":"active","generatedBy":"manual","createdAt":"2025-10-11T20:19:44.842Z","updatedAt":"2025-10-11T20:19:44.842Z","__v":0}],"googleFontsInlined":false},"customCss":[{"filePath":"styles/custom.css","content":"#banner{min-height:64px;display:flex;align-items:center;justify-content:center;gap:10px;padding:12px 24px;position:relative;background-color:rgba(239,246,255,.9)!important;border-top:1px solid #bfdbfe;border-bottom:1px solid #bfdbfe;box-shadow:0 1px 2px rgba(15,23,42,.08);transition:all .5s ease-out}:is(html.dark, body.dark) #banner{background-color:#0f172a!important;border-top-color:#334155;border-bottom-color:#334155}@media (max-width:639px){#banner{flex-direction:row;align-items:center;gap:6px;padding:10px}#banner::before{flex:0 0 auto;margin-right:2px}}#banner::before{content:\"\";width:120px;height:28px;background-image:url(https://pipedream.com/docs/images/wday_logo_no-TM_primary-RGB.svg);background-size:contain;background-repeat:no-repeat;background-position:center;flex:0 0 auto}:is(html.dark, body.dark) #banner::before{background-image:url(https://pipedream.com/docs/images/wday_logo_no-TM_reversed-RGB.svg)}@media (max-width:639px){#banner::before{width:100px;height:24px}}#banner button{position:absolute;right:20px;top:50%;transform:translateY(-50%);padding:6px;border-radius:999px;color:#2563eb!important;background:0 0;transition:color .2s ease,background-color .2s ease}#banner button svg{color:inherit;stroke:currentColor}#banner button:hover{background-color:rgba(191,219,254,.4);color:#1d4ed8!important}:is(html.dark, body.dark) #banner button{color:#bfdbfe!important}:is(html.dark, body.dark) #banner button:hover{background-color:rgba(51,65,85,.6);color:#e2e8f0!important}@media (max-width:639px){#banner button{top:12px;right:12px;transform:none}}#banner>div,#banner>div>p{display:flex!important;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px;text-align:center;max-width:720px}#banner p{display:inline;margin:0}@media (max-width:639px){#banner>div{width:100%;max-width:none;flex-direction:column;align-items:flex-start;justify-content:flex-start;gap:2px;text-align:left}#banner>div>p{display:block!important;width:100%;text-align:left}#banner p,#banner strong{text-align:left;line-height:1.3}}#banner,#banner *,#banner p,#banner p strong,#banner strong{color:#475569!important;font-size:1rem;font-weight:500}:is(html.dark, body.dark) #banner,:is(html.dark, body.dark) #banner *,:is(html.dark, body.dark) #banner p,:is(html.dark, body.dark) #banner p strong,:is(html.dark, body.dark) #banner strong{color:#dbeafe!important}@media (min-width:640px){#banner p strong,#banner strong{font-size:1.125rem}}#banner a[href*=\"newsroom.workday.com\"]:nth-of-type(1){display:inline-flex!important;align-items:center;justify-content:center;padding:8px 16px;height:36px;background-color:#3b82f6;color:#fff!important;border-radius:6px;text-decoration:none!important;font-weight:500;font-size:1rem;transition:background-color .2s ease;margin-left:36px;flex-shrink:0;white-space:nowrap;box-shadow:0 1px 2px rgba(15,23,42,.12)}#banner a[href*=\"newsroom.workday.com\"]:nth-of-type(1):hover{background-color:#1d4ed8}:is(html.dark, body.dark) #banner a[href*=\"newsroom.workday.com\"]:nth-of-type(1){background-color:#3b82f6}:is(html.dark, body.dark) #banner a[href*=\"newsroom.workday.com\"]:nth-of-type(1):hover{background-color:#2563eb}@media (max-width:639px){#banner a[href*=\"newsroom.workday.com\"]:nth-of-type(1){display:inline!important;align-self:flex-start;padding:0;height:auto;margin-left:0;background-color:transparent;color:#2563eb!important;text-decoration:underline;text-decoration-thickness:1px;border-radius:0;box-shadow:none;white-space:normal}#banner a[href*=\"newsroom.workday.com\"]:nth-of-type(1):hover{background-color:transparent}}#banner-content{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:center;text-align:center}.nav-logo{height:2.5rem}"}],"page":{"pagePath":"workflows/building-workflows/code/nodejs/rerun","slug":"/workflows/building-workflows/code/nodejs/rerun","pageMetadata":{"title":"Pause, Resume, and Rerun a Workflow","sidebarTitle":"Pause, Resume, and Rerun Steps","boost":0.25,"description":null,"href":"/workflows/building-workflows/code/nodejs/rerun"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,blockquote:`blockquote`,code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Frame,Heading,OptimizedImage,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Workflows and String are shutting down on March 31, 2027.`}),` `,_jsx(_components.a,{href:`/workflows`,children:`Learn more`})]})}),`\n`,_jsxs(_components.p,{children:[`You can use `,_jsx(_components.code,{children:`$.flow.suspend`}),` and `,_jsx(_components.code,{children:`$.flow.rerun`}),` to pause a workflow and resume it later.`]}),`\n`,_jsx(_components.p,{children:`This is useful when you want to:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Pause a workflow until someone manually approves it`}),`\n`,_jsx(_components.li,{children:`Poll an external API until some job completes, and proceed with the workflow when it’s done`}),`\n`,_jsx(_components.li,{children:`Trigger an external API to start a job, pause the workflow, and resume it when the external API sends an HTTP callback`}),`\n`]}),`\n`,_jsx(_components.p,{children:`We’ll cover all of these examples below.`}),`\n`,_jsx(Heading,{level:`2`,id:`$-flow-suspend`,children:_jsx(_components.code,{children:`$.flow.suspend`})}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`$.flow.suspend`}),` when you want to pause a workflow and proceed with the remaining steps only when manually approved or cancelled.`]}),`\n`,_jsx(_components.p,{children:`For example, you can suspend a workflow and send yourself a link to manually resume or cancel the rest of the workflow:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineComponent`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`resume_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`cancel_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`suspend`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`send`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`email`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` subject:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Please approve this important workflow\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` text:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Click here to approve the workflow: \"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`resume_url`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`, and cancel here: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`cancel_url`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Pipedream suspends your workflow at the end of the step`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`You’ll receive an email like this:`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=35a084406b8d3f88d428adf4a62bff5d`,alt:``,\"data-og-width\":`1442`,width:`1442`,\"data-og-height\":`294`,height:`294`,\"data-path\":`images/e970ce4a-approve-workflow_oc06k3.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?w=280\u0026fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=4113f85a436720c38a44f7fcedd06a50 280w, https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?w=560\u0026fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=a38ad51ccba3505cdd12b6844e2eb83e 560w, https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?w=840\u0026fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=f81ee289ca15ae8219fa4abadf356da2 840w, https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?w=1100\u0026fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=a6924710bec1280b0019a3e0d6b3f759 1100w, https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?w=1650\u0026fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=bf8aa745778280712cb27d1a90f2ca4a 1650w, https://mintcdn.com/pipedream/nKh6d_6A4aXFb6xD/images/e970ce4a-approve-workflow_oc06k3.png?w=2500\u0026fit=max\u0026auto=format\u0026n=nKh6d_6A4aXFb6xD\u0026q=85\u0026s=7efe832b7eea3f6fbd1a0ab50c8b0a21 2500w`})}),`\n`,_jsx(_components.p,{children:`And can resume or cancel the rest of the workflow by clicking on the appropriate link.`}),`\n`,_jsxs(Heading,{level:`3`,id:`resume_url-and-cancel_url`,children:[_jsx(_components.code,{children:`resume_url`}),` and `,_jsx(_components.code,{children:`cancel_url`})]}),`\n`,_jsxs(_components.p,{children:[`In general, calling `,_jsx(_components.code,{children:`$.flow.suspend`}),` returns a `,_jsx(_components.code,{children:`cancel_url`}),` and `,_jsx(_components.code,{children:`resume_url`}),` that lets you cancel or resume paused executions. Since Pipedream pauses your workflow at the `,_jsx(_components.em,{children:`end`}),` of the step, you can pass these URLs to any external service before the workflow pauses. If that service accepts a callback URL, it can trigger the `,_jsx(_components.code,{children:`resume_url`}),` when its work is complete.`]}),`\n`,_jsx(_components.p,{children:`These URLs are specific to a single execution of your workflow. While the workflow is paused, you can load these in your browser or send any HTTP request to them:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Sending an HTTP request to the `,_jsx(_components.code,{children:`cancel_url`}),` will cancel that execution`]}),`\n`,_jsxs(_components.li,{children:[`Sending an HTTP request to the `,_jsx(_components.code,{children:`resume_url`}),` will resume that execution`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`If you resume a workflow, any data sent in the HTTP request is passed to the workflow and returned in the `,_jsx(_components.code,{children:`$resume_data`}),` `,_jsx(_components.a,{href:`/workflows/overview/#step-exports`,children:`step export`}),` of the suspended step. For example, if you call `,_jsx(_components.code,{children:`$.flow.suspend`}),` within a step named `,_jsx(_components.code,{children:`code`}),`, the `,_jsx(_components.code,{children:`$resume_data`}),` export should contain the data sent in the `,_jsx(_components.code,{children:`resume_url`}),` request:`]}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=215b09447a5b7900949c2347b5e74d4c`,alt:``,\"data-og-width\":`682`,width:`682`,\"data-og-height\":`430`,height:`430`,\"data-path\":`images/c9712a37-resume_data_lafhxr.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?w=280\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=7fc4d3b504e7d4917d0b586b933579db 280w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?w=560\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=754c100485238d0403f6fb62c36a452a 560w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?w=840\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=374da4912f53db1f6fe4af4969ec0cfd 840w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?w=1100\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=90bdb3439c2a24f665fbd0c5feb63dac 1100w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?w=1650\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=6dd0e979b5830141fac8a6aa3194f033 1650w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/c9712a37-resume_data_lafhxr.png?w=2500\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=b143c22f1944b40fcb9cc5d51c8d1f70 2500w`})}),`\n`,_jsxs(_components.p,{children:[`Requests to the `,_jsx(_components.code,{children:`resume_url`}),` have `,_jsx(_components.a,{href:`/workflows/limits/#http-request-body-size`,children:`the same limits as any HTTP request to Pipedream`}),`, but you can send larger payloads using our `,_jsx(_components.a,{href:`/workflows/building-workflows/triggers/#sending-large-payloads`,children:`large payload`}),` or `,_jsx(_components.a,{href:`/workflows/building-workflows/triggers/#large-file-support`,children:`large file`}),` interfaces.`]}),`\n`,_jsx(Heading,{level:`3`,id:`default-timeout-of-24-hours`,children:`Default timeout of 24 hours`}),`\n`,_jsxs(_components.p,{children:[`By default, `,_jsx(_components.code,{children:`$.flow.suspend`}),` will automatically cancel the workflow after 24 hours. You can set your own timeout (in milliseconds) as the first argument:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineComponent`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // 7 days`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` TIMEOUT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 60`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 60`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 24`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 7`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`suspend`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`TIMEOUT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`$-flow-rerun`,children:_jsx(_components.code,{children:`$.flow.rerun`})}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`$.flow.rerun`}),` when you want to run a specific step of a workflow multiple times. This is useful when you need to start a job in an external API and poll for its completion, or have the service call back to the step and let you process the HTTP request within the step.`]}),`\n`,_jsx(Heading,{level:`3`,id:`retrying-a-failed-api-request`,children:`Retrying a Failed API Request`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`$.flow.rerun`}),` can be used to conditionally retry a failed API request due to a service outage or rate limit reached. Place the `,_jsx(_components.code,{children:`$.flow.rerun`}),` call within a `,_jsx(_components.code,{children:`catch`}),` block to only retry the API request if an error is thrown:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`33`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`33`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`axios`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@pipedream/platform\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineComponent`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` props:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` openai:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"app\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` app:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"openai\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`steps`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` axios`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` url:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://api.openai.com/v1/completions`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"post\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Authorization:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Bearer \"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`this`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`openai`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$auth`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`api_key`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"text-davinci-003\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` prompt:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Say this is a test\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` max_tokens:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 7`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` temperature:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`catch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` DELAY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 30`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Retry the request every 30 seconds, for up to 3 times`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`DELAY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`polling-for-the-status-of-an-external-job`,children:`Polling for the status of an external job`}),`\n`,_jsxs(_components.p,{children:[`Sometimes you need to poll for the status of an external job until it completes. `,_jsx(_components.code,{children:`$.flow.rerun`}),` lets you rerun a specific step multiple times:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`28`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`28`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` axios`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"axios\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineComponent`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // 10 seconds`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` DELAY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 10`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // $.context.run.runs starts at 1 and increments when the step is rerun`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`runs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // $.flow.rerun(delay, context (discussed below), max retries)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`DELAY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`runs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` throw`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Max retries exceeded\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`else`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Poll external API for status`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` axios`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"GET\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` url:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://example.com/status\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // If we're done, continue with the rest of the workflow`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`status`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"DONE\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Else retry later`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`DELAY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`$.flow.rerun`}),` accepts the following arguments:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` delay`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// The number of milliseconds until the step will be rerun`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// JSON-serializable data you need to pass between runs`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` maxRetries`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // The total number of times the step will rerun. Defaults to 10`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`accept-an-http-callback-from-an-external-service`,children:`Accept an HTTP callback from an external service`}),`\n`,_jsxs(_components.p,{children:[`When you trigger a job in an external service, and that service can send back data in an HTTP callback to Pipedream, you can process that data within the same step using `,_jsx(_components.code,{children:`$.flow.rerun`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`28`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`28`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` axios`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"axios\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineComponent`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`steps`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` TIMEOUT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 86400`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // $.context.run.runs starts at 1 and increments when the step is rerun`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`runs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`cancel_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`resume_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`TIMEOUT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Send resume_url to external service`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` axios`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"POST\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` url:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"your callback URL\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` resume_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` cancel_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // When the external service calls back into the resume_url, you have access to`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // the callback data within $.context.run.callback_request`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`callback_request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`callback_request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(Heading,{level:`3`,id:`passing-context-to-$-flow-rerun`,children:[`Passing `,_jsx(_components.code,{children:`context`}),` to `,_jsx(_components.code,{children:`$.flow.rerun`})]}),`\n`,_jsxs(_components.p,{children:[`Within a Node.js code step, `,_jsx(_components.code,{children:`$.context.run.context`}),` contains the `,_jsx(_components.code,{children:`context`}),` passed from the prior call to `,_jsx(_components.code,{children:`rerun`}),`. This lets you pass data from one run to another. For example, if you call:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`hello:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"world\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`$.context.run.context`}),` will contain:`]}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=e634f74069415264dfd45803c6a5fb83`,alt:``,\"data-og-width\":`456`,width:`456`,\"data-og-height\":`214`,height:`214`,\"data-path\":`images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?w=280\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=2b684f331821e30bddeca7d692b617ca 280w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?w=560\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=71c1b7b7d02aee826d40d800b2a60c78 560w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?w=840\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=813c1bbb5375ee281f013a4d1ad62d10 840w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?w=1100\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=dd1f2ac28cefd1b1d17305aad14c51f9 1100w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?w=1650\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=ef22a4d4740e4cd402f7f8eea169d434 1650w, https://mintcdn.com/pipedream/xnRKrRxEtt3vxd6I/images/da6c184e-Screen_Shot_2022-06-14_at_11.32.06_PM_dmzgkh.png?w=2500\u0026fit=max\u0026auto=format\u0026n=xnRKrRxEtt3vxd6I\u0026q=85\u0026s=d6f486518f84d34c3b17b908662c15c0 2500w`})}),`\n`,_jsx(Heading,{level:`3`,id:`maxretries`,children:_jsx(_components.code,{children:`maxRetries`})}),`\n`,_jsxs(_components.p,{children:[`By default, `,_jsx(_components.code,{children:`maxRetries`}),` is `,_jsx(_components.strong,{children:`10`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`When you exceed `,_jsx(_components.code,{children:`maxRetries`}),`, the workflow proceeds to the next step. If you need to handle this case with an exception, `,_jsx(_components.code,{children:`throw`}),` an error from the step:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineComponent`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`$`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`runs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`flow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rerun`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`runs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` MAX_RETRIES`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` throw`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Max retries exceeded\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`behavior-when-testing`,children:`Behavior when testing`}),`\n`,_jsxs(_components.p,{children:[`When you’re building a workflow and test a step with `,_jsx(_components.code,{children:`$.flow.suspend`}),` or `,_jsx(_components.code,{children:`$.flow.rerun`}),`, it will not suspend the workflow, and you’ll see a message like the following:`]}),`\n`,_jsxs(_components.blockquote,{children:[`\n`,_jsxs(_components.p,{children:[`Workflow execution canceled — this may be due to `,_jsx(_components.code,{children:`$.flow.suspend()`}),` usage (not supported in test)`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`These functions will only suspend and resume when run in production.`}),`\n`,_jsxs(Heading,{level:`2`,id:`credits-when-using-suspend-/-rerun`,children:[`Credits when using `,_jsx(_components.code,{children:`suspend`}),` / `,_jsx(_components.code,{children:`rerun`})]}),`\n`,_jsxs(_components.p,{children:[`You are not charged for the time your workflow is suspended during a `,_jsx(_components.code,{children:`$.flow.rerun`}),` or `,_jsx(_components.code,{children:`$.flow.suspend`}),`. Only when workflows are resumed will compute time count toward `,_jsx(_components.a,{href:`/pricing/#credits-and-billing`,children:`credit usage`}),`.`]}),`\n`,_jsxs(Warning,{children:[_jsx(_components.p,{children:`When a suspended workflow reawakens, it will reset the credit counter.`}),_jsx(_components.p,{children:`Each rerun or reawakening from a suspension will count as a new fresh credit.`})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Pause, Resume, and Rerun a Workflow","sidebarTitle":"Pause, Resume, and Rerun Steps","boost":0.25,"description":null,"href":"/workflows/building-workflows/code/nodejs/rerun"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"$.flow.suspend","slug":"$-flow-suspend","depth":2,"children":[{"title":"resume_url and cancel_url","slug":"resume_url-and-cancel_url","depth":3,"children":[]},{"title":"Default timeout of 24 hours","slug":"default-timeout-of-24-hours","depth":3,"children":[]}]},{"title":"$.flow.rerun","slug":"$-flow-rerun","depth":2,"children":[{"title":"Retrying a Failed API Request","slug":"retrying-a-failed-api-request","depth":3,"children":[]},{"title":"Polling for the status of an external job","slug":"polling-for-the-status-of-an-external-job","depth":3,"children":[]},{"title":"Accept an HTTP callback from an external service","slug":"accept-an-http-callback-from-an-external-service","depth":3,"children":[]},{"title":"Passing context to $.flow.rerun","slug":"passing-context-to-$-flow-rerun","depth":3,"children":[]},{"title":"maxRetries","slug":"maxretries","depth":3,"children":[]}]},{"title":"Behavior when testing","slug":"behavior-when-testing","depth":2,"children":[]},{"title":"Credits when using suspend / rerun","slug":"credits-when-using-suspend-/-rerun","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"pipedream","siteName":"Pipedream","title":"Pause, Resume, and Rerun a Workflow - Pipedream","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-29T19:00:34.024Z","originalFileLocation":"workflows/building-workflows/code/nodejs/rerun.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Pipedream provides the toolkit to add thousands of integrations to your app and enables you to automate any process.\">\u003cmeta data-mint-head name=\"keywords\" content=\"api, mcp, ai, integrations, pipedream, workflow, automation, connect, apis\">\u003cmeta data-mint-head name=\"application-name\" content=\"Pipedream\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index, follow\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Pause, Resume, and Rerun a Workflow - Pipedream\">\u003cmeta data-mint-head property=\"og:description\" content=\"Pipedream provides the toolkit to add thousands of integrations to your app and enables you to automate any process.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Pipedream\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://pipedream.mintlify.app/_mintlify/api/og/v2?division=Node.js\u0026amp;title=Pause%2C+Resume%2C+and+Rerun+a+Workflow\u0026amp;theme=0d4512b4a13a7a889c737c15\u0026amp;signature=1f93bf3f7ebbf55dcbb6c629868865db5ecf870dbf23bfb744c7a548bb496627\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Pipedream\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Pipedream provides the toolkit to add thousands of integrations to your app and enables you to automate any process.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://pipedream.mintlify.app/_mintlify/api/og/v2?division=Node.js\u0026amp;title=Pause%2C+Resume%2C+and+Rerun+a+Workflow\u0026amp;theme=0d4512b4a13a7a889c737c15\u0026amp;signature=1f93bf3f7ebbf55dcbb6c629868865db5ecf870dbf23bfb744c7a548bb496627\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/pipedream/BXAUbH3bs99htewI/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Pipedream\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#095c32\">\u003cmeta data-mint-head name=\"og:locale\" content=\"en_US\">\u003cmeta data-mint-head name=\"charset\" content=\"UTF-8\">\u003cmeta data-mint-head name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\u003cmeta data-mint-head name=\"author\" content=\"Pipedream\">\u003cmeta data-mint-head name=\"googlebot\" content=\"index, follow\">\u003cmeta data-mint-head name=\"language\" content=\"en\">\u003cmeta data-mint-head name=\"twitter:creator\" content=\"@pipedream\">\u003cmeta data-mint-head name=\"twitter:image:alt\" content=\"Pipedream Logo\">\u003clink data-mint-head rel=\"canonical\" href=\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/workflows/building-workflows/code/nodejs/rerun.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://pipedream.com/#organization\",\"name\":\"Pipedream\",\"url\":\"https://pipedream.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/pipedream/J-J7n6QGsUEW1AZY/logo/pipedream_workday_lockup.png?fit=max\u0026auto=format\u0026n=J-J7n6QGsUEW1AZY\u0026q=85\u0026s=20f01e899a0e49424e3d16d1e84adc60\"}},{\"@type\":\"WebSite\",\"@id\":\"https://pipedream.com/docs#website\",\"name\":\"Pipedream\",\"url\":\"https://pipedream.com/docs\",\"publisher\":{\"@id\":\"https://pipedream.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun#webpage\",\"url\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun\",\"name\":\"Pause, Resume, and Rerun a Workflow\",\"dateModified\":\"2026-10-29T19:00:34.024Z\",\"isPartOf\":{\"@id\":\"https://pipedream.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Workflows\",\"item\":\"https://pipedream.com/docs/workflows\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building Workflows\",\"item\":\"https://pipedream.com/docs/workflows/building-workflows/triggers\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Write your own code\",\"item\":\"https://pipedream.com/docs/workflows/building-workflows/code\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Node.js\",\"item\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Pause, Resume, and Rerun a Workflow\",\"item\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun#article\",\"headline\":\"Pause, Resume, and Rerun a Workflow\",\"name\":\"Pause, Resume, and Rerun a Workflow\",\"url\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun\",\"mainEntityOfPage\":{\"@id\":\"https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun#webpage\"},\"dateModified\":\"2026-10-29T19:00:34.024Z\",\"publisher\":{\"@id\":\"https://pipedream.com/#organization\"},\"isPartOf\":{\"@id\":\"https://pipedream.com/docs#website\"}}]}\u003c/script>","siteName":"Pipedream","nav":{"global":null,"products":[{"product":"Connect","icon":"https://mintlify.s3.us-west-1.amazonaws.com/pipedream/logo/pipedream_icon.svg","description":"Integration layer for AI agents","tabs":[{"tab":"Documentation","icon":"book","groups":[{"group":"Getting Started","pages":[{"title":"Introduction to Pipedream","sidebarTitle":"Introduction","icon":"house","href":""},{"group":"Workspaces","icon":"users","pages":[{"title":"Managing workspaces","href":"/workspaces"},{"group":"Single-Sign On","pages":[{"title":"Single Sign On Overview","sidebarTitle":"Overview","href":"/workspaces/sso"},{"title":"Configure SSO with Google Workspace","sidebarTitle":"Google Workspace","href":"/workspaces/sso/google"},{"title":"Configure SSO with Okta","sidebarTitle":"Okta","href":"/workspaces/sso/okta"},{"title":"Configure SSO with Another SAML Provider","sidebarTitle":"SAML","href":"/workspaces/sso/saml"}]},{"title":"Domain Verification","href":"/workspaces/domain-verification"}]},{"group":"Projects","icon":"folder","pages":[{"title":"Projects","sidebarTitle":"Overview","href":"/projects"},{"title":"Access Controls","href":"/projects/access-controls"},{"title":"Project Variables and Secrets","sidebarTitle":"Variables and Secrets","href":"/projects/secrets"}]},{"title":"Using AI Tooling with Pipedream","sidebarTitle":"AI Tooling","icon":"wand-magic-sparkles","href":"/ai-tooling"}]},{"group":"Connect","pages":[{"title":"Overview","icon":"plug","href":"/connect"},{"title":"Connect Quickstart","sidebarTitle":"Quickstart","icon":"rocket","href":"/connect/quickstart"},{"title":"App Discovery","sidebarTitle":"App Discovery","icon":"location-dot","href":"/connect/app-discovery"},{"group":"Managed Auth","icon":"key","pages":[{"title":"Managed Auth Quickstart","sidebarTitle":"Quickstart","href":"/connect/managed-auth/quickstart"},{"title":"Users","href":"/connect/managed-auth/users"},{"title":"Connect Tokens","href":"/connect/managed-auth/tokens"},{"title":"Connect Link","href":"/connect/managed-auth/connect-link"},{"title":"OAuth Clients","href":"/connect/managed-auth/oauth-clients"},{"title":"App Overrides","href":"/connect/managed-auth/app-overrides"},{"title":"Environments","href":"/connect/managed-auth/environments"},{"title":"Project Configuration","href":"/connect/managed-auth/customization"},{"title":"Troubleshooting","href":"/connect/managed-auth/troubleshooting"}]},{"group":"Tool Use","icon":"wrench","pages":[{"title":"Pre Built Tools for Your App or Agent","sidebarTitle":"Overview","href":"/connect/components"},{"title":"Executing Actions","href":"/connect/components/actions"},{"title":"Deploying Triggers","href":"/connect/components/triggers"},{"title":"Working with Files","href":"/connect/components/files"},{"title":"Using Custom Tools","sidebarTitle":"Custom Tools","href":"/connect/components/custom-tools"},{"title":"Troubleshooting","href":"/connect/components/troubleshooting"}]},{"group":"MCP","icon":"robot","pages":[{"title":"MCP Servers","sidebarTitle":"Overview","href":"/connect/mcp"},{"title":"Develop with Pipedream MCP","sidebarTitle":"Developers","href":"/connect/mcp/developers"},{"group":"AI Frameworks","pages":[{"title":"Pipedream MCP with Vercel's AI SDK","sidebarTitle":"Vercel AI SDK","href":"/connect/mcp/ai-frameworks/vercel-ai-sdk"},{"title":"OpenAI Integration","sidebarTitle":"OpenAI","href":"/connect/mcp/ai-frameworks/openai"},{"title":"Pipedream MCP with Anthropic","sidebarTitle":"Anthropic","href":"/connect/mcp/ai-frameworks/anthropic"},{"title":"Pipedream MCP with Gemini","sidebarTitle":"Gemini","href":"/connect/mcp/ai-frameworks/gemini"}]},{"title":"Using Pipedream MCP as an End User","sidebarTitle":"Consumers","href":"/connect/mcp/users"}]},{"title":"Webhooks","icon":"webhook","href":"/connect/webhooks"},{"title":"Connect API Proxy","sidebarTitle":"API Proxy","icon":"arrows-left-right","href":"/connect/api-proxy"},{"title":"Pipedream Connect Use Cases","sidebarTitle":"Use Cases","icon":"lightbulb","href":"/connect/use-cases"}]},{"group":"Workflows","pages":[{"title":"Workflows and String Are Shutting Down on March 31, 2027","sidebarTitle":"Important Update","icon":"bullhorn","href":"/workflows"},{"title":"What Are Workflows?","sidebarTitle":"Overview","icon":"diagram-project","href":"/workflows/overview"},{"title":"Workflow Development","sidebarTitle":"Quickstart","icon":"rocket","href":"/workflows/quickstart"},{"group":"Building Workflows","icon":"hammer","pages":[{"title":"Triggers","href":"/workflows/building-workflows/triggers"},{"title":"Actions","href":"/workflows/building-workflows/actions"},{"title":"HTTP","href":"/workflows/building-workflows/http"},{"title":"Using Props","href":"/workflows/building-workflows/using-props"},{"title":"Build with AI","sidebarTitle":"Build with AI","href":"/workflows/building-workflows/build-with-ai"},{"group":"Write your own code","pages":[{"title":"Overview","href":"/workflows/building-workflows/code"},{"group":"Node.js","pages":[{"title":"Running Node.js in Workflows","href":"/workflows/building-workflows/code/nodejs"},{"title":"Using AI to Generate Code","sidebarTitle":"Use AI to Generate Code","href":"/workflows/building-workflows/code/nodejs/ai-code-generation"},{"title":"Connecting Apps in Node.js","sidebarTitle":"Connect Apps","href":"/workflows/building-workflows/code/nodejs/auth"},{"title":"Make HTTP Requests with Node.js","sidebarTitle":"HTTP Requests","href":"/workflows/building-workflows/code/nodejs/http-requests"},{"title":"Working with the Filesystem in Node.js","sidebarTitle":"Files","href":"/workflows/building-workflows/code/nodejs/working-with-files"},{"title":"Using Data Stores","sidebarTitle":"Data Stores","href":"/workflows/building-workflows/code/nodejs/using-data-stores"},{"title":"Delaying a Workflow","sidebarTitle":"Delaying Steps","description":null,"href":"/workflows/building-workflows/code/nodejs/delay"},{"title":"Pause, Resume, and Rerun a Workflow","sidebarTitle":"Pause, Resume, and Rerun Steps","href":"/workflows/building-workflows/code/nodejs/rerun"},{"title":"Running Asynchronous Code in Node.js","sidebarTitle":"Running Asynchronous Code","description":null,"href":"/workflows/building-workflows/code/nodejs/async"},{"title":"Sharing Code Across Workflows","href":"/workflows/building-workflows/code/nodejs/sharing-code"},{"title":"Browser Automation with Node.js","sidebarTitle":"Browser Automation","href":"/workflows/building-workflows/code/nodejs/browser-automation"}]},{"group":"Python","pages":[{"title":"Python","sidebarTitle":"Running Python in Workflows","href":"/workflows/building-workflows/code/python"},{"title":"Connecting Apps in Python","sidebarTitle":"Connect Apps","href":"/workflows/building-workflows/code/python/auth"},{"title":"Making HTTP Requests with Python","sidebarTitle":"HTTP Requests","href":"/workflows/building-workflows/code/python/http-requests"},{"title":"Working with the Filesystem in Python","sidebarTitle":"Files","href":"/workflows/building-workflows/code/python/working-with-files"},{"title":"Using Data Stores","sidebarTitle":"Data Stores","href":"/workflows/building-workflows/code/python/using-data-stores"},{"title":"Delaying a Workflow","sidebarTitle":"Delaying Steps","href":"/workflows/building-workflows/code/python/delay"},{"title":"Pause, Resume, and Rerun a Workflow","sidebarTitle":"Pause, Resume, and Rerun Steps","href":"/workflows/building-workflows/code/python/rerun"},{"title":"Use PyPI Packages with Differing Import Names","sidebarTitle":"Different PyPI Package Name and Import Name","href":"/workflows/building-workflows/code/python/import-mappings"}]},{"title":"Go","href":"/workflows/building-workflows/code/go"},{"title":"Bash","href":"/workflows/building-workflows/code/bash"}]},{"group":"Control Flow","pages":[{"title":"Overview","href":"/workflows/building-workflows/control-flow"},{"title":"If/Else","sidebarTitle":"Branching - If/Else","href":"/workflows/building-workflows/control-flow/ifelse"},{"title":"Switch","sidebarTitle":"Branching - Switch","href":"/workflows/building-workflows/control-flow/switch"},{"title":"Parallel","sidebarTitle":"Branching - Parallel","href":"/workflows/building-workflows/control-flow/parallel"},{"title":"Delay","href":"/workflows/building-workflows/control-flow/delay"},{"title":"Filter","href":"/workflows/building-workflows/control-flow/filter"},{"title":"End Workflow","href":"/workflows/building-workflows/control-flow/end-workflow"}]},{"title":"Inspect Events","href":"/workflows/building-workflows/inspect"},{"title":"Handling Errors","href":"/workflows/building-workflows/errors"},{"title":"Sharing Workflows","href":"/workflows/building-workflows/sharing"},{"group":"Settings","pages":[{"title":"Settings","sidebarTitle":"Overview","href":"/workflows/building-workflows/settings"},{"title":"Concurrency and Throttling","href":"/workflows/building-workflows/settings/concurrency-and-throttling"}]}]},{"group":"Data Management","icon":"database","pages":[{"title":"Data Stores","href":"/workflows/data-management/data-stores"},{"group":"File Stores","pages":[{"title":"File Stores","sidebarTitle":"Overview","href":"/workflows/data-management/file-stores"},{"title":"File Stores Node.js Reference","sidebarTitle":"Reference","href":"/workflows/data-management/file-stores/reference"}]},{"group":"Destinations","pages":[{"title":"Destinations","sidebarTitle":"Overview","href":"/workflows/data-management/destinations"},{"title":"Email","href":"/workflows/data-management/destinations/email"},{"title":"HTTP","href":"/workflows/data-management/destinations/http"},{"title":"Emit Events","sidebarTitle":"Emit","href":"/workflows/data-management/destinations/emit"},{"title":"Server Sent Events (SSE)","sidebarTitle":"SSE","href":"/workflows/data-management/destinations/sse"},{"title":"Amazon S3","sidebarTitle":"S3","href":"/workflows/data-management/destinations/s3"}]},{"group":"Databases","pages":[{"title":"Connecting to Databases","sidebarTitle":"Overview","href":"/workflows/data-management/databases"},{"title":"Working with SQL","href":"/workflows/data-management/databases/working-with-sql"}]}]},{"title":"Event History","icon":"columns-3","href":"/workflows/event-history"},{"title":"Export Workflows","icon":"file-export","href":"/workflows/export-workflows"},{"title":"Environment Variables","icon":"key","href":"/workflows/environment-variables"},{"title":"GitHub Sync","icon":"github","iconType":"brands","href":"/workflows/git"},{"title":"Custom Domains","icon":"globe","href":"/workflows/domains"},{"title":"Virtual Private Clouds","icon":"cloud","href":"/workflows/vpc"},{"title":"Limits","icon":"gauge","href":"/workflows/limits"},{"title":"Workflow Troubleshooting","sidebarTitle":"Troubleshooting","icon":"wrench","href":"/workflows/troubleshooting"},{"title":"Workflow Security Best Practices","sidebarTitle":"Security best practices","icon":"shield","href":"/workflows/security-best-practices"}]},{"group":"Platform","pages":[{"group":"Components","icon":"puzzle-piece","pages":[{"title":"Overview","href":"/components"},{"group":"Contributing","pages":[{"title":"Pipedream Registry","sidebarTitle":"Overview","href":"/components/contributing"},{"title":"Component API Reference","sidebarTitle":"Component API","href":"/components/contributing/api"},{"title":"Quickstart: Action Development","sidebarTitle":"Quickstart — Actions","href":"/components/contributing/actions-quickstart"},{"title":"Quickstart: Source Development","sidebarTitle":"Quickstart — Sources","href":"/components/contributing/sources-quickstart"},{"title":"Components Guidelines and Patterns","sidebarTitle":"Guidelines","href":"/components/contributing/guidelines"},{"title":"TypeScript Components","href":"/components/contributing/typescript"}]}]},{"group":"CLI","icon":"laptop-code","pages":[{"title":"Installing the CLI","sidebarTitle":"Install","href":"/cli/install"},{"title":"Logging into the CLI","sidebarTitle":"Login","href":"/cli/login"},{"title":"CLI Reference","href":"/cli/reference"}]},{"group":"Pricing","icon":"dollar-sign","pages":[{"title":"Plans and Pricing","sidebarTitle":"Overview","href":"/pricing"},{"title":"FAQ","href":"/pricing/faq"}]},{"group":"Account","icon":"user","pages":[{"title":"User Settings","href":"/account/user-settings"},{"title":"Billing Settings","href":"/account/billing-settings"}]},{"group":"Security","icon":"shield","pages":[{"title":"Privacy and Security at Pipedream","sidebarTitle":"Privacy and Security","href":"/privacy-and-security"},{"title":"Security Best Practices","href":"/privacy-and-security/best-practices"},{"title":"HIPAA Compliance","href":"/privacy-and-security/hipaa"},{"title":"PGP Key","href":"/privacy-and-security/pgp-key"},{"title":"Subprocessors","href":"/subprocessors"}]},{"title":"Troubleshooting Common Issues","sidebarTitle":"Troubleshooting","icon":"wrench","href":"/troubleshooting"},{"title":"Pipedream Glossary","sidebarTitle":"Glossary of Terms","icon":"book","href":"/glossary"}]},{"group":"Additional Resources","pages":[{"title":"Support","url":"https://pipedream.com/support","href":"/additional-resources/support"},{"title":"Status","url":"https://status.pipedream.com","href":"/additional-resources/status"},{"title":"Terms of Service","url":"https://pipedream.com/terms","href":"/additional-resources/terms"},{"title":"Privacy Policy","url":"https://pipedream.com/privacy","href":"/additional-resources/privacy"}]}]},{"tab":"Connect API","icon":"square-terminal","pages":[{"title":"Connect API","href":"/connect/api-reference/introduction"}]},{"tab":"Changelog","icon":"bullhorn","pages":[{"title":"Changelog","href":"/changelog"}]}]},{"product":"Conduit","icon":"https://mintlify.s3.us-west-1.amazonaws.com/pipedream/images/conduit/conduit-mark.svg","description":"Enterprise MCP Gateway","pages":[{"title":"Conduit","href":"/conduit"}]}]},"basePath":"","title":"Pause, Resume, and Rerun a Workflow - Pipedream","buildId":"dpl_6cCEiK8XNNvaLBBkWzcBhdE9QfLC","deploymentId":"dpl_6cCEiK8XNNvaLBBkWzcBhdE9QfLC","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-Bj1PpgeO.js","DynamicMarkdown-Bas9A7wq.js","zoom-image-lightbox-B-WKhCOL.js","lightbox-handle-r17bVUz3.js"]}