POST
/
v2
/
publish
/
{destination}

Request

destination
string
required

Destination can either be a topic name or id that you configured in the Upstash console, a valid url where the message gets sent to, or a valid QStash API name like api/llm. If the destination is a URL, make sure the URL is prefixed with a valid protocol (http:// or https://)

body
string

The raw request message passed to the endpoints as is

Content-Type
string

ContentType is the MIME type of the message.

We highly recommend sending a Content-Type header along, as this will help your destination API to understand the content of the message.

Set this to whatever data you are sending through QStash, if your message is json, then use application/json. Some frameworks like Next.js will not parse your body correctly if the content type is not correct.

For example application/json, application/xml, application/octet-stream, text/plain

Upstash-Method
string
default: "POST"

The HTTP method to use when sending a webhook to your API.

Upstash-Timeout
string

Timeout value to set how long your endpoint is going to take. This parameter can be used to shorten the default allowed timeout value on your plan. Examples: 1 second = "1s", 5 minutes = "5m", 2 hours = "2h" See Max HTTP Connection Timeout on the pricing page for default values.

Upstash-Retries
int
default: 3

How often should this message be retried in case the destination API is not available.

The total number of deliveries is therefore capped at 1 + retries

Leave this empty to use the default value, (free tier: 3, paid tier: 5)

The backoff duration in seconds is calculated as follows: n is the number of times the task has been retried.

min(86400, e ** (2 * n))

Upstash-Callback
string

You can define a callback url that will be called after each attempt. See the content of what will be delivered to a callback here

  • The callback url must be prefixed with a valid protocol (http:// or https://)
  • Callbacks are charged as a regular message.
  • Callbacks will use the retry setting from the original request.

For the api/llm destination, specifying a callback is required.

Upstash-Failure-Callback
string

You can define a failure callback url that will be called when a delivery is failed. That is when all the defined retries are exhausted. See the content of what will be delivered to a failure callback here

  • The failure callback url must be prefixed with a valid protocol (http:// or https://)
  • Callbacks are charged as a regular message.
  • Callbacks will use the retry setting from the original request.
Upstash-Forward-*
string

You can send custom headers along with your message.

To send a custom header, prefix the header name with Upstash-Forward-. We will strip efix and them to the destination API.

example: "Upstash-Forward-My-Header: my-value" -> "My-Header: my-value"

Upstash-Delay
string

Delay the message delivery.

Format for this header is a number followed by duration abbreviation, like 10s. Available durations are s (seconds), m (minutes), h (hours), d (days).

example: "50s" | "3m" | "10h" | "1d"

Upstash-Not-Before
int

Delay the message delivery until a certain time in the future.

The format is a unix timestamp in seconds, based on the UTC timezone.

When both Upstash-Not-Before and Upstash-Delay headers are provided, Upstash-Not-Before will be used.

Upstash-Deduplication-Id
string

Id to use while deduplicating messages, so that only one message with the given deduplication id is published.

Upstash-Content-Based-Deduplication
boolean

When set to true, automatically deduplicates messages based on their content, so that only one message with the same content is published.

Content based deduplication creates unique deduplication ids based on the following message fields:

  • Destination
  • Body
  • Headers
Upstash-Not-Before
int

Delay a message until a certain time in the future. The format is a unix timestamp in seconds, based on the UTC timezone.

Upstash-Not-Before will override the Upstash-Delay header when both are used together.

example: 1719996572

Response

Either a single object or an array of objects is returned, depending on whether you have sent the message to a url, URL group, or an API.

Single Object Response

This is returned when the destination is a url or an api.

messageId
string
required

The unique id of this message.

deduplicated
boolean

Whether this message is a duplicate and was not sent to the destination.

Array of Objects Response

This is returned when the destination is a topic, and array contains one element for each url in the topic.

array
object[]
messageId
string
required

The unique id of this message.

url
string
required

The url where the message was sent to.

deduplicated
boolean

Whether this message is a duplicate and was not sent to the destination.