defineDurable() code on your own servers when it needs to reach systems that only your servers can, such as a database on your private network. Your servers run the code. Zapier saves each step’s result and tells your servers when to continue, so you do not need to build your own storage or scheduler for long waits. This is called push mode.
Push mode is in beta, with these known limits:
- Requests to your notification URL carry no credentials. Resume only executions your app started.
RestClientdoes not refresh an expired token. Create a new client each time you start or resume an execution.- You cannot check push-mode executions in the Workflow Manager or with a CLI command.
Before you begin
- A
defineDurable()workflow. @zapier/zapier-durableand@zapier/zapier-sdkinstalled in your app.- A Zapier login: run
npx zapier-sdk loginor setZAPIER_CREDENTIALS. In production, use client credentials. - A public HTTPS URL that accepts POST requests, such as
https://my-app.example.com/durable/resume. - Somewhere to store execution IDs, such as a database table.
Set up push mode
-
Create a function that returns a
RestClientpointed at your notification URL. Call it each time you start or resume an execution:Create the client -
Start an execution with that client, and save its ID. Replace
myWorkflowwith your workflow’s name:The execution runs until it finishes or reaches a wait or callback. If it suspends, Zapier keeps its journal.Start an execution -
Add a POST handler at your notification URL that checks the request and queues the execution to resume:
Handle the resume request
-
In a background worker, resume each queued execution:
When a wait ends or a callback arrives, Zapier sendsResume in a background worker
{ "execution_id": "..." }to your notification URL, and your worker resumes the execution from where it stopped. - Reply to every request from Zapier with a 2xx status.
How Zapier delivers resume requests
Verify the result
Check that your handler resumes executions:- Start an execution that calls
ctx.wait()for a short time, such as 60 seconds. - Wait for Zapier to send a request to your notification URL.
- Confirm the request reached your handler and that the resumed call to
myWorkflow()returnsdone: true.
Run without a Zapier account
Run without a Zapier account
You can also run
defineDurable() code fully on your own. Your process keeps the journal and decides when to resume, so you do not need a Zapier account. Use FilesystemClient for a single process, MemoryClient for tests, or write a DurableClient for Postgres, MySQL, or SQLite. The library does not include a scheduler.Related
How Next Gen Zaps in code work
Learn how steps, waits, callbacks, and replays work.
Deploy with client credentials
Authenticate the SDK in production without a browser login.