REST API reference: Webhooks
When a test run finishes, Optisway sends a test.run.completed event to every webhook endpoint of the organisation, signed with the endpoint's own secret. Check the Optisway-Signature header before you trust a delivery.
When Optisway sends an event
Every finished run is sent, whether it passed, failed or ended in error, and whether it was started in the app, by its schedule or through the API. Optisway posts the same JSON body to every endpoint of the test's organisation at the same time.
Each endpoint gets one attempt: the request times out after 5 seconds, redirects are not followed and a failed delivery is not retried today. Answer with any 2xx status within those 5 seconds and do slow work afterwards; your answer is recorded but never changes the run.
Only public https:// addresses are accepted. Optisway checks the address again before each delivery and skips an endpoint that resolves to a private network.
Where to configure endpoints
Owners and admins add and delete endpoints in Settings → Integrations, up to 20 per organisation. A new endpoint gets its own signing secret whsec_…, shown once right after you add it: store it with your receiver, for example as OPTISWAY_WEBHOOK_SECRET.
Rotate secret replaces the secret and shows the new one once. The old secret stops working at once, so update your receiver right after rotating. Endpoints added before signing existed are listed as Unsigned: they receive deliveries without Optisway-Signature until you rotate their secret.
Example payload
The delivery of run 4821, which failed because the checkout page answered 503. run carries the status, trigger, times, summary, check counts and findings, test and project say what ran, and links.test opens the test in the app.
The body is pretty-printed here; the real body is compact JSON and the signature covers its exact bytes, so verify before you parse. New fields can appear at any time: ignore the ones you do not know.
{
"event": "test.run.completed",
"sentAt": "2026-10-19T09:12:03.412Z",
"run": {
"id": "4821",
"status": "failed",
"trigger": "api",
"startedAt": "2026-10-19T09:12:01.000Z",
"finishedAt": "2026-10-19T09:12:03.140Z",
"durationMs": 2140,
"summary": "503 Service Unavailable in 184 ms",
"checksTotal": 3,
"checksPassed": 2,
"checksFailed": 1,
"findings": [
{
"severity": "fail",
"code": "status",
"message": "503 Service Unavailable",
"target": "https://shop.example.com/",
"value": 503,
"unit": "status"
},
{
"severity": "pass",
"code": "redirect-chain",
"message": "No redirects",
"target": "https://shop.example.com/",
"value": 0,
"unit": "count"
},
{
"severity": "pass",
"code": "response-time",
"message": "184 ms",
"target": "https://shop.example.com/",
"value": 184,
"unit": "ms"
}
]
},
"test": {
"id": "318",
"customId": "tst_7k2m9q4xh3vd",
"name": "Checkout page",
"kind": "availability",
"url": "https://shop.example.com/"
},
"project": {
"id": "42",
"name": "Acme Shop"
},
"links": {
"test": "https://optisway.com/en/app/tests/view/318"
}
}Headers
Every delivery carries these headers. Header names are case-insensitive; most frameworks hand them to you in lower case.
| Header | Example | Meaning |
|---|---|---|
| Content-Type | application/json | Always application/json; the body is UTF-8 JSON. |
| User-Agent | OptiswayBot/1.0 (+https://optisway.com) | Identifies Optisway's delivery client. |
| Optisway-Event | test.run.completed | The event name. test.run.completed is the only event today; ignore events you do not handle. |
| Optisway-Delivery | 01m59pxa2m8w5n1c6p0rtyb3ga | Unique per endpoint and delivery: 26 characters, sortable by time. Store it to ignore a delivery you have already processed, and quote it when you contact support. |
| Optisway-Signature | t=1792401123,v1=2f2c68c0c86897b88540d42a2c5f151a862ba6e5e460b761bb15d38949fdd194 | Only for endpoints with a signing secret. t is the Unix time in seconds, v1 the hex HMAC-SHA256 of <t>.<raw body> keyed with the whole secret, whsec_ included. |
Verify the signature
Check every delivery before you act on it. Each example runs a small receiver on port 8080 with the standard library of its language (Ruby uses Rack) and reads the secret from OPTISWAY_WEBHOOK_SECRET.
- Read the raw request body as bytes, before any JSON parsing or re-encoding.
- Split
Optisway-Signatureat the commas into itst=andv1=parts. - Compute HMAC-SHA256 of
<t>.<raw body>with the whole secret as the key, and compare the hex result withv1in constant time. - Reject the delivery when
tis more than 300 seconds away from your clock, which stops replays of an old delivery. Then answer with a2xxstatus.
# curl cannot compute an HMAC: verify deliveries in your receiver with one of the other
# languages. Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
# Reject a delivery whose t is more than 300 seconds away from your clock.
#
# This replays the example delivery against your own receiver; payload.json must hold the
# exact raw body. A correct receiver answers 400: the example's t is long past 300 seconds.
curl -sS -X POST "https://hooks.example.com/optisway" \
-H "Content-Type: application/json" \
-H "User-Agent: OptiswayBot/1.0 (+https://optisway.com)" \
-H "Optisway-Event: test.run.completed" \
-H "Optisway-Delivery: 01m59pxa2m8w5n1c6p0rtyb3ga" \
-H "Optisway-Signature: t=1792401123,v1=2f2c68c0c86897b88540d42a2c5f151a862ba6e5e460b761bb15d38949fdd194" \
--data-binary @payload.json// Node.js 18+: save as receiver.mjs and run `node receiver.mjs`
// Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";
const secret = process.env.OPTISWAY_WEBHOOK_SECRET; // whsec_…
const toleranceSeconds = 300;
// True when the Optisway-Signature header signs this exact raw body and is recent.
function verifyOptisway(rawBody, header = "") {
const parts = {};
for (const part of header.split(",")) {
const [key, value] = part.trim().split("=");
parts[key] = value;
}
const t = parts.t ?? "";
if (!/^\d+$/.test(t) || !parts.v1) return false;
if (Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false;
const expected = createHmac("sha256", secret).update(`${t}.`).update(rawBody).digest();
const received = Buffer.from(parts.v1, "hex");
return received.length === expected.length && timingSafeEqual(received, expected);
}
createServer((request, response) => {
const chunks = [];
request.on("data", (chunk) => chunks.push(chunk));
request.on("end", () => {
const rawBody = Buffer.concat(chunks);
if (!verifyOptisway(rawBody, request.headers["optisway-signature"])) {
response.writeHead(400).end("invalid signature");
return;
}
const event = JSON.parse(rawBody.toString("utf8"));
console.log(request.headers["optisway-delivery"], event.test.name, event.run.status);
response.writeHead(204).end();
});
}).listen(8080);# Python 3.8+, standard library only: save as receiver.py and run `python receiver.py`
# Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
import hashlib
import hmac
import json
import os
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
SECRET = os.environ["OPTISWAY_WEBHOOK_SECRET"].encode() # whsec_…
TOLERANCE_SECONDS = 300
def verify_optisway(raw_body: bytes, header: str) -> bool:
"""True when the Optisway-Signature header signs this exact raw body and is recent."""
parts = dict(part.strip().split("=", 1) for part in header.split(",") if "=" in part)
t, v1 = parts.get("t", ""), parts.get("v1", "")
if not (t.isascii() and t.isdigit()) or not v1:
return False
if abs(time.time() - int(t)) > TOLERANCE_SECONDS:
return False
expected = hmac.new(SECRET, t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v1)
class Receiver(BaseHTTPRequestHandler):
def do_POST(self):
raw_body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
if not verify_optisway(raw_body, self.headers.get("Optisway-Signature", "")):
self.send_response(400)
self.end_headers()
return
event = json.loads(raw_body)
print(self.headers["Optisway-Delivery"], event["test"]["name"], event["run"]["status"])
self.send_response(204)
self.end_headers()
HTTPServer(("", 8080), Receiver).serve_forever()# config.ru: `gem install rack rackup`, then `rackup -p 8080`
# Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
require "json"
require "openssl"
require "rack"
SECRET = ENV.fetch("OPTISWAY_WEBHOOK_SECRET") # whsec_…
TOLERANCE_SECONDS = 300
# True when the Optisway-Signature header signs this exact raw body and is recent.
def verify_optisway(raw_body, header)
parts = {}
header.to_s.split(",").each do |part|
key, value = part.strip.split("=", 2)
parts[key] = value.to_s
end
t = parts.fetch("t", "")
v1 = parts.fetch("v1", "")
return false unless t.match?(/\A\d+\z/) && !v1.empty?
return false if (Time.now.to_i - t.to_i).abs > TOLERANCE_SECONDS
expected = OpenSSL::HMAC.hexdigest("SHA256", SECRET, "#{t}.#{raw_body}")
Rack::Utils.secure_compare(expected, v1)
end
run lambda { |env|
raw_body = Rack::Request.new(env).body.read
return [400, {}, ["invalid signature"]] unless verify_optisway(raw_body, env["HTTP_OPTISWAY_SIGNATURE"])
event = JSON.parse(raw_body)
puts "#{env["HTTP_OPTISWAY_DELIVERY"]} #{event["test"]["name"]} #{event["run"]["status"]}"
[204, {}, []]
}<?php
// optisway.php behind your web server (PHP 7.3+)
// Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
const TOLERANCE_SECONDS = 300;
// True when the Optisway-Signature header signs this exact raw body and is recent.
function verify_optisway(string $rawBody, string $header, string $secret): bool
{
$parts = [];
foreach (explode(",", $header) as $part) {
[$key, $value] = array_pad(explode("=", trim($part), 2), 2, "");
$parts[$key] = $value;
}
$t = $parts["t"] ?? "";
$v1 = $parts["v1"] ?? "";
if (!ctype_digit($t) || $v1 === "") {
return false;
}
if (abs(time() - (int) $t) > TOLERANCE_SECONDS) {
return false;
}
$expected = hash_hmac("sha256", "$t.$rawBody", $secret);
return hash_equals($expected, $v1);
}
$rawBody = file_get_contents("php://input");
$header = $_SERVER["HTTP_OPTISWAY_SIGNATURE"] ?? "";
if (!verify_optisway($rawBody, $header, (string) getenv("OPTISWAY_WEBHOOK_SECRET"))) {
http_response_code(400);
exit("invalid signature");
}
$event = json_decode($rawBody, true);
error_log(($_SERVER["HTTP_OPTISWAY_DELIVERY"] ?? "") . " " . $event["test"]["name"] . " " . $event["run"]["status"]);
http_response_code(204);// Java 17+: save as Main.java and run `java Main.java`
// Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
import com.sun.net.httpserver.HttpServer;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.HexFormat;
import java.util.Map;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class Main {
static final byte[] SECRET =
System.getenv("OPTISWAY_WEBHOOK_SECRET").getBytes(StandardCharsets.UTF_8); // whsec_\u2026
static final long TOLERANCE_SECONDS = 300;
// True when the Optisway-Signature header signs this exact raw body and is recent.
static boolean verifyOptisway(byte[] rawBody, String header) throws Exception {
Map<String, String> parts = new HashMap<>();
for (String part : (header == null ? "" : header).split(",")) {
String[] pair = part.trim().split("=", 2);
if (pair.length == 2) {
parts.put(pair[0], pair[1]);
}
}
String t = parts.getOrDefault("t", "");
String v1 = parts.getOrDefault("v1", "");
if (!t.matches("\\d+") || v1.isEmpty()) {
return false;
}
long now = System.currentTimeMillis() / 1000;
if (Math.abs(now - Long.parseLong(t)) > TOLERANCE_SECONDS) {
return false;
}
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(SECRET, "HmacSHA256"));
mac.update((t + ".").getBytes(StandardCharsets.UTF_8));
byte[] expected = mac.doFinal(rawBody);
byte[] received;
try {
received = HexFormat.of().parseHex(v1);
} catch (IllegalArgumentException error) {
return false;
}
return MessageDigest.isEqual(expected, received);
}
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/optisway", exchange -> {
try {
byte[] rawBody = exchange.getRequestBody().readAllBytes();
String header = exchange.getRequestHeaders().getFirst("Optisway-Signature");
boolean valid = verifyOptisway(rawBody, header);
if (valid) {
System.out.println(exchange.getRequestHeaders().getFirst("Optisway-Delivery") + " verified");
}
exchange.sendResponseHeaders(valid ? 204 : 400, -1);
} catch (Exception error) {
exchange.sendResponseHeaders(500, -1);
} finally {
exchange.close();
}
});
server.start();
}
}// Go 1.20+: save as main.go and run `go run main.go`
// Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
)
const toleranceSeconds = 300
var secret = []byte(os.Getenv("OPTISWAY_WEBHOOK_SECRET")) // whsec_…
// verifyOptisway reports whether the Optisway-Signature header signs this exact raw body and is recent.
func verifyOptisway(rawBody []byte, header string) bool {
parts := map[string]string{}
for _, part := range strings.Split(header, ",") {
if key, value, ok := strings.Cut(strings.TrimSpace(part), "="); ok {
parts[key] = value
}
}
t, err := strconv.ParseUint(parts["t"], 10, 63)
if err != nil || parts["v1"] == "" {
return false
}
if age := time.Now().Unix() - int64(t); age > toleranceSeconds || age < -toleranceSeconds {
return false
}
received, err := hex.DecodeString(parts["v1"])
if err != nil {
return false
}
mac := hmac.New(sha256.New, secret)
mac.Write([]byte(parts["t"] + "."))
mac.Write(rawBody)
return hmac.Equal(mac.Sum(nil), received)
}
func main() {
http.HandleFunc("/optisway", func(w http.ResponseWriter, r *http.Request) {
rawBody, err := io.ReadAll(r.Body)
if err != nil || !verifyOptisway(rawBody, r.Header.Get("Optisway-Signature")) {
http.Error(w, "invalid signature", http.StatusBadRequest)
return
}
fmt.Println(r.Header.Get("Optisway-Delivery"), "verified")
w.WriteHeader(http.StatusNoContent)
})
panic(http.ListenAndServe(":8080", nil))
}// .NET 8: `dotnet new web`, replace Program.cs with this file, then `dotnet run`
// Optisway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
using System.Security.Cryptography;
using System.Text;
var secret = Encoding.UTF8.GetBytes(Environment.GetEnvironmentVariable("OPTISWAY_WEBHOOK_SECRET") ?? ""); // whsec_…
const long ToleranceSeconds = 300;
// True when the Optisway-Signature header signs this exact raw body and is recent.
bool VerifyOptisway(byte[] rawBody, string header)
{
var parts = new Dictionary<string, string>();
foreach (var part in header.Split(','))
{
var pair = part.Trim().Split('=', 2);
if (pair.Length == 2) parts[pair[0]] = pair[1];
}
if (!parts.TryGetValue("t", out var t) || !long.TryParse(t, out var timestamp)) return false;
if (!parts.TryGetValue("v1", out var v1) || v1.Length == 0) return false;
if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - timestamp) > ToleranceSeconds) return false;
using var hmac = new HMACSHA256(secret);
var expected = hmac.ComputeHash(Encoding.UTF8.GetBytes($"{t}.").Concat(rawBody).ToArray());
byte[] received;
try { received = Convert.FromHexString(v1); } catch (FormatException) { return false; }
return CryptographicOperations.FixedTimeEquals(expected, received);
}
var app = WebApplication.Create(args);
app.MapPost("/optisway", async (HttpRequest request) =>
{
using var buffer = new MemoryStream();
await request.Body.CopyToAsync(buffer);
if (!VerifyOptisway(buffer.ToArray(), request.Headers["Optisway-Signature"].ToString()))
return Results.BadRequest("invalid signature");
Console.WriteLine($"{request.Headers["Optisway-Delivery"]} verified");
return Results.NoContent();
});
app.Run();curl cannot compute the HMAC, so its tab replays the example delivery against your own receiver instead: a correct receiver answers 400, because the example is older than 300 seconds.