> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTPS push consumers

> StackShift POSTs each batch to your HTTPS endpoint, signed with Ed25519. Your reply says which messages to ack and which to retry.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Receive batches on your own endpoint, verify them, and ack or retry each message.

## Prerequisites

* A public HTTPS endpoint
* An API key to fetch the verification key once

## Workflow

**Step 1**

Fetch the public key from GET /api/v1/jobs/verification-key and store it in your app's config.

**Step 2**

Set the queue's consumer to HTTPS push with your URL.

**Step 3**

In your endpoint, verify the signature over the raw body before parsing it.

**Step 4**

Handle each message and reply with the ids to ack and to retry.

## What StackShift sends

A POST with a JSON body and three headers. The timeout is 60 seconds.

* X-StackShift-Timestamp: Unix seconds.
* X-StackShift-Invocation: an id for this delivery.
* X-StackShift-Signature: base64 Ed25519 signature over timestamp, a newline, the invocation id, a newline, then the raw body bytes.

```json Request body theme={null}
{
  "queue": { "id": "q_7Hk2", "name": "orders" },
  "messages": [
    {
      "id": "msg_4fT9aQ2mZx1L",
      "body": { "order_id": "ord_123" },
      "content_type": "json",
      "attempts": 1,
      "sent_at": "2026-12-04T10:00:00Z"
    }
  ]
}
```

## How to reply

* 2xx with \{"ack": \[...], "retry": \[...]}: retried ids come back after delay\_seconds (or the consumer's retry delay). Every other message in the batch is acked, whether or not it is listed in ack.
* 2xx with an empty body: every message in the batch is acked.
* Non-2xx, or no answer within 60 seconds: the whole batch is retried.

```json Reply body theme={null}
{
  "ack": ["msg_4fT9aQ2mZx1L"],
  "retry": [{ "id": "msg_9pQ1rT7uVw3K", "delay_seconds": 60 }]
}
```

## Verification key

The key is the same one Durable Jobs uses to sign job callbacks. Fetch it with your API key and keep the base64 public\_key in your config. Never fetch a key from a URL the request gives you.

```bash GET /api/v1/jobs/verification-key theme={null}
curl https://api.stackshift.cloud/api/v1/jobs/verification-key \
  -H "Authorization: Bearer $STACKSHIFT_API_KEY"
# {"user_id": "...", "algorithm": "Ed25519", "public_key": "..."}
```

## Verify and reply with the SDK

Each SDK verifies the signature and timestamp and returns the parsed batch, or throws: QueuePushError in JavaScript, Python and Ruby, ErrQueuePushInvalid in Go, EventSignatureError in PHP. The error code is missing\_signature, invalid\_signature, expired or invalid\_body. In JavaScript verifyPush is async. In Python, install the queues extra for verification: pip install "stackshift\[queues]".

pushReply (push\_reply in Python and Ruby, WriteQueuePushReply in Go) builds the reply body. To fetch the key from code, call client.queues.verificationKey() (verification\_key in Python and Ruby, VerificationKey in Go and PHP).

```ts JavaScript theme={null}
import { verifyPush, pushReply } from '@stackshift-cloud/sdk'

export async function POST(request: Request) {
  const raw = new Uint8Array(await request.arrayBuffer())
  let batch
  try {
    batch = await verifyPush(raw, request.headers, process.env.STACKSHIFT_QUEUES_PUBLIC_KEY!)
  } catch {
    return new Response('Unauthorized', { status: 401 })
  }
  const ack = []
  const retry = []
  for (const message of batch.messages) {
    try {
      await fulfil(message.body)
      ack.push(message.id)
    } catch {
      retry.push({ id: message.id, delaySeconds: 60 })
    }
  }
  return Response.json(pushReply({ ack, retry }))
}
```

```python Python theme={null}
import os
from stackshift import push_reply, verify_push

@app.post("/queues/orders")
def orders():
    try:
        batch = verify_push(request.get_data(), request.headers, os.environ["STACKSHIFT_QUEUES_PUBLIC_KEY"])
    except ValueError:
        return "", 401
    ack, retry = [], []
    for message in batch["messages"]:
        try:
            fulfil(message["body"])
            ack.append(message["id"])
        except Exception:
            retry.append({"id": message["id"], "delay_seconds": 60})
    return push_reply(ack=ack, retry=retry)
```

```go Go theme={null}
func orders(w http.ResponseWriter, r *http.Request) {
	body, _ := io.ReadAll(r.Body)
	batch, err := stackshift.VerifyQueuePush(r.Header, body, os.Getenv("STACKSHIFT_QUEUES_PUBLIC_KEY"), time.Now())
	if err != nil {
		http.Error(w, "unauthorized", http.StatusUnauthorized)
		return
	}
	reply := stackshift.QueuePushReply{}
	for _, message := range batch.Messages {
		if err := fulfil(message.Body); err != nil {
			delay := 60
			reply.Retry = append(reply.Retry, stackshift.QueuePushRetry{ID: message.ID, DelaySeconds: &delay})
			continue
		}
		reply.Ack = append(reply.Ack, message.ID)
	}
	_ = stackshift.WriteQueuePushReply(w, reply)
}
```

```php PHP theme={null}
$batch = \StackShift\QueuesClient::verifyPush(
    $request->getContent(),
    $request->headers->all(),
    config('services.stackshift.queue_public_key'),
);
$ack = [];
$retry = [];
foreach ($batch['messages'] as $message) {
    try {
        fulfil($message['body']);
        $ack[] = $message['id'];
    } catch (\Throwable $e) {
        $retry[] = ['id' => $message['id'], 'delay_seconds' => 60];
    }
}
return response(\StackShift\QueuesClient::pushReply($ack, $retry), 200, ['Content-Type' => 'application/json']);
```

```ruby Ruby theme={null}
require "stackshift/queues"

batch = StackShift::Queues.verify_push(
  raw_body: request.raw_post,
  headers: request.headers,
  public_key: ENV.fetch("STACKSHIFT_QUEUES_PUBLIC_KEY")
)
render json: StackShift::Queues.push_reply(ack: batch["messages"].map { |m| m["id"] }, retry: [])
```

## Expected result

> [!TIP]
>
> Batches arrive at your endpoint, acked messages leave the queue, and retried ones come back after their delay.

## Common failures

> [!WARNING]
>
> * Signature check fails: verify the raw bytes, not a re-serialised body, and check the server clock. Requests older than 300 seconds or more than 60 seconds in the future are rejected.
> * Every batch is retried: the endpoint answered non-2xx or took longer than 60 seconds.

## Related guides

> [card] [Consumers and Function consumers](https://docs.stackshift.cloud/queues/consumers.md)
>
> Each queue has one consumer: a Function, an HTTPS endpoint, or pull. Function consumers are chosen in the dashboard or API, not in code.

> [card] [Batching, retries and delays](https://docs.stackshift.cloud/queues/batching-retries-and-delays.md)
>
> How batch size and wait, retries, retry delays, concurrency and delivery guarantees work.

> [card] [Durable Jobs overview](https://docs.stackshift.cloud/durable-jobs/overview.md)
>
> Durable Jobs is the reliable execution engine for backend work on StackShift. Deploy the app. Offload the work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.