#!/usr/bin/env bash # Submit the same order twice under one Idempotency-Key. # The first call returns 201 with a fresh orderId; the replay returns 200 with # the identical body and an "Idempotent-Replay: true" response header. set -euo pipefail ENDPOINT="${1:-https://idempotent-orders.example.workers.dev}" KEY="$(uuidgen)" submit() { curl -sS -D - -o /tmp/order-body.json \ -X POST "$ENDPOINT" \ -H "Idempotency-Key: $KEY" \ -H "content-type: application/json" \ -d '{"symbol":"MSFT","side":"buy","quantity":100}' echo cat /tmp/order-body.json echo } echo "# First submission" submit echo "# Retry with the same key" submit