Skip to main content

API Examples

Publish a message to an endpoint

curl -XPOST \
-H 'Authorization: Bearer XXX' \
-H "Content-type: application/json" \
-d '{ "hello": "world" }' \
'https://qstash.upstash.io/v1/publish/https://example.com'

Publish a message to a topic

curl -XPOST \
-H 'Authorization: Bearer XXX' \
-H "Content-type: application/json" \
-d '{ "hello": "world" }' \
'https://qstash.upstash.io/v1/publish/myTopic'

Publish a message with 5 minutes delay

curl -XPOST \
-H 'Authorization: Bearer XXX' \
-H "Content-type: application/json" \
-H "Upstash-Delay: 5m" \
-d '{ "hello": "world" }' \
'https://qstash.upstash.io/v1/publish/https://example.com'

Send a custom header

curl -XPOST \
-H 'Authorization: Bearer XXX' \
-H 'Upstash-Forward-My-Header: my-value' \
-H "Content-type: application/json" \
-d '{ "hello": "world" }' \
'https://qstash.upstash.io/v1/publish/https://example.com'

Schedule to run once a day

curl -XPOST \
-H 'Authorization: Bearer XXX' \
-H "Upstash-Cron: 0 0 * * *" \
-H "Content-type: application/json" \
-d '{ "hello": "world" }' \
'https://qstash.upstash.io/v1/publish/https://example.com'

Set max retry count to 3

curl -XPOST \
-H 'Authorization: Bearer XXX' \
-H "Upstash-Retries: 3" \
-H "Content-type: application/json" \
-d '{ "hello": "world" }' \
'https://qstash.upstash.io/v1/publish/https://example.com'