Publish Messages
Publishing a message is as easy as sending a HTTP request to the /publish
endpoint. All you need is a valid url of your destination.
Send a message via the Upstash Console
Destination URLs must always include the protocol (http://
or https://
)
The message
The message you want to send is passed in the request body. Upstash does not
use, parse, or validate the body, so you can send any kind of data you want. We
suggest you add a Content-Type
header to your request to make sure your
destination API knows what kind of data you are sending.
Sending custom HTTP headers
In addition to sending the message itself, you can also forward HTTP headers.
Simply add them prefixed with Upstash-Forward-
and we will include them in the
message.
Here’s an example
In this case, we would deliver a POST
request to https://example.com
with
the following body and headers:
What happens after publishing?
When you publish a message, it will be durably stored in an Upstash Redis database. Then we try to deliver the message to your chosen destination API. If your API is down or does not respond with a success status code (200-299), the message will be retried and delivered when it comes back online. You do not need to worry about retrying messages or ensuring that they are delivered.
By default, the multiple messages published to QStash are sent to your API in parallel.
Publish to URL Group
URL Groups allow you to publish a single message to more than one API endpoints. To learn more about URL Groups, check URL Groups section.
Publishing to a URL Group is very similar to publishing to a single destination. All
you need to do is replace the URL
in the /publish
endpoint with the URL Group
name.
Optional parameters and configuration
QStash supports a number of optional parameters and configuration that you can use to customize the delivery of your message. All configuration is done using HTTP headers.
Was this page helpful?