You can run the async code by importing Client from upstash_qstash.asyncio and awaiting the methods.

Create a schedule that runs every 5 minutes

from upstash_qstash import Client



client = Client("<QSTASH_TOKEN>")

schedules = client.schedules()

res = schedules.create({

  "destination": "https://my-api...",

  "cron": "*/5 * * * *",

})



print(res["scheduleId"])

Create a schedule that runs every hour and sends the result to a callback URL

from upstash_qstash import Client



client = Client("<QSTASH_TOKEN>")

schedules = client.schedules()

schedules.create({

  "destination": "https://my-api...",

  "cron": "0 * * * *",

  "callback": "https://my-callback...",

  "failure_callback": "https://my-failure-callback...",

})

Create a schedule to a topic that runs every minute

from upstash_qstash import Client



client = Client("<QSTASH_TOKEN>")

schedules = client.schedules()

schedules.create({

  "destination": "my-topic",

  "cron": "* * * * *",

})

Get a schedule by schedule id

from upstash_qstash import Client



client = Client("<QSTASH_TOKEN>")

schedules = client.schedules()

res = schedules.get("scheduleId")

print(res["cron"])

List all schedules

from upstash_qstash import Client



client = Client("<QSTASH_TOKEN>")

schedules = client.schedules()

all_scheds = schedules.list()

print(all_scheds)

Delete a schedule

from upstash_qstash import Client



client = Client("<QSTASH_TOKEN>")

schedules = client.schedules()

schedules.delete("scheduleId")