GitHub Repository
You can find the project source code on GitHub.
Prerequisites
- An Upstash QStash API key.
- Python and pip installed.
Step 1: Installation
First, create a new directory and set up a virtual environment:Step 2: Configure Environment Variables
Create a.env
file in your project root and add your QStash token. This token is used to authenticate your application with the QStash service.
Terminal
Option 1: Local QStash Server
To start the local QStash server, run:QSTASH_URL
and QSTASH_TOKEN
values in the console. Add these values to your .env
file:
.env
Option 2: Local Tunnel
Alternatively, you can set up a local tunnel. For this option:- Copy the
QSTASH_TOKEN
from the Upstash Console. - Update your
.env
file with the following:
.env
- Replace
***
with your actual QStash token. - Set
UPSTASH_WORKFLOW_URL
to the public URL provided by your local tunnel.

Step 3: Create a Workflow Endpoint
A workflow endpoint allows you to define a set of steps that, together, make up a workflow. Each step contains a piece of business logic that is automatically retried on failure, with easy monitoring via our visual workflow dashboard. To define a workflow endpoint in a Flask project, create amain.py
file that contains your workflow:
main.py
Step 4: Run the Workflow Endpoint
Don’t forget to source your environment file to set your environment variables:Terminal
base_url
option, trigger your workflow by first starting your Flask app:
Terminal
Terminal


Next Steps
- Learn how to protect your workflow endpoint from unauthorized access by securing your workflow endpoint.
- Explore our the source code for a detailed, end-to-end example and best practices.
- For setting up and testing your workflows in a local environment, check out our local development guide.