Optisway Startseite
Dokumentationsmenü

REST-API-Referenz: Tests

Die API listet und liest Tests und startet ihre Läufe; mit einem manage-Schlüssel legt sie Tests außerdem an, ändert und löscht sie, während ihre Konfiguration in der App bleibt. Jeder Test hat eine numerische id und eine öffentliche tst_…-ID, die die App anzeigt, und beide funktionieren überall, wo ein Pfad eine Test-{id} erwartet.

Test

Ein Test mit Art, Zeitplan, nächstem Lauf, letztem Lauf, Erfolgsstatistik und den Benachrichtigungskanälen, die er benachrichtigt.

Felder: Test
FeldTypBeschreibung
idstringDie numerische ID des Tests als Dezimalzeichenkette.
customIdstring (tst_…)Die öffentliche Test-ID (tst_ und 12 Zeichen), die die App anzeigt; sie ändert sich nie und gilt überall, wo eine Test-ID erwartet wird.
projectIdstringDie ID des Projekts, zu dem der Test gehört.
namestringDer Name des Tests, wie die App ihn anzeigt.
kind"availability" | "links" | "seo" | "vitals" | "visual" | "a11y" | "rest" | "graphql" | "script" | "journey"Was der Test prüft: eine der zehn Testarten.
urlstringDie Adresse, die der Test öffnet oder aufruft.
descriptionstringDie Beschreibung des Tests; eine leere Zeichenkette, wenn keine angelegt wurde.
scheduleMinutesinteger | nullMinuten zwischen zwei geplanten Läufen (1440 = einmal täglich) oder null, wenn der Test nur auf Anforderung läuft.
enabledbooleanfalse, solange der Test pausiert ist; ein pausierter Test erhält keine geplanten Läufe.
nextRunAtISO 8601 string | nullWann der nächste geplante Lauf fällig ist (UTC), oder null ohne aktiven Zeitplan.
lastRunRunSummary | nullDer neueste Lauf des Tests als RunSummary oder null vor dem ersten Lauf.
stats.runsintegerWie viele Läufe der Test in den letzten 30 Tagen hatte.
stats.passedintegerWie viele dieser Läufe bestanden wurden.
stats.failedintegerWie viele dieser Läufe fehlgeschlagen sind.
stats.passRateinteger (0–100) | nullBestandene Läufe als ganzzahliger Prozentsatz (0–100) der bestandenen und fehlgeschlagenen Läufe der letzten 30 Tage oder null, wenn es keine gab.
notificationRoutingNotificationRoutingWelche Benachrichtigungskanäle die abgeschlossenen Läufe des Tests benachrichtigen: jeden aktiven Kanal der Organisation (Voreinstellung) oder nur die ausgewählten.
createdAtISO 8601 stringWann der Test angelegt wurde (UTC).
updatedAtISO 8601 stringWann der Test zuletzt geändert wurde (UTC).
links.selfstringDer Pfad dieses Tests (GET /tests/{id}).
links.runsstringDer Pfad der Läufe dieses Tests: GET listet sie auf, POST startet einen neuen.
links.projectstringDer Pfad des Projekts, zu dem der Test gehört.
Beispiel: TestJSON
{
  "id": "318",
  "customId": "tst_7k2m9q4xh3vd",
  "projectId": "42",
  "name": "Checkout page",
  "kind": "availability",
  "url": "https://shop.example.com/",
  "description": "Checks that the checkout answers quickly and without errors.",
  "scheduleMinutes": 1440,
  "enabled": true,
  "nextRunAt": "2026-10-20T09:12:00.000Z",
  "lastRun": {
    "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"
  },
  "stats": {
    "runs": 30,
    "passed": 28,
    "failed": 2,
    "passRate": 93
  },
  "notificationRouting": {
    "scope": "all",
    "channelIds": []
  },
  "createdAt": "2026-09-02T14:05:00.000Z",
  "updatedAt": "2026-10-12T08:41:00.000Z",
  "links": {
    "self": "/api/v1/tests/318",
    "runs": "/api/v1/tests/318/runs",
    "project": "/api/v1/projects/42"
  }
}

Tests auflisten GET /tests

Listet die Tests im Bereich des Schlüssels auf; die optionalen Filter project, kind und query lassen sich kombinieren. Erfordert read-Zugriff; die Liste ist nicht seitenweise aufgeteilt. Das Beispiel findet den Erreichbarkeitstest „Checkout page“ in Projekt 42.

Benötigt einen Schlüssel mit Zugriff: Lesen

Parameter

Parameter: GET /tests
NameOrtTypPflichtBeschreibungBeispiel
projectQuery-Stringstring (numeric project id)NeinLiefert nur die Tests dieses Projekts (numerische ID).42
kindQuery-String"availability" | "links" | "seo" | "vitals" | "visual" | "a11y" | "rest" | "graphql" | "script" | "journey"NeinLiefert nur Tests dieser Testart.availability
queryQuery-Stringstring, 2–100 charactersNeinLiefert nur Tests, deren Name, URL oder tst_…-ID diesen Text enthält (2–100 Zeichen).checkout

Beispielanfrage

curl --fail-with-body -sS \
  "https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout";
const response = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const { items } = await response.json();
for (const item of items) console.log(item.id, item.name);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.get(
    "https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
for item in response.json()["items"]:
    print(item["id"], item["name"])
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
JSON.parse(response.body)["items"].each do |item|
  puts [item["id"], item["name"]].join("  ")
end
<?php
$curl = curl_init("https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
foreach (json_decode($body, true)["items"] as $item) {
  echo $item["id"], "  ", $item["name"], "\n";
}
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout";
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    // { "items": [...], "next": ... } -- any JSON library (Jackson, Gson, org.json) parses it;
    // this example stays dependency-free and prints the raw JSON.
    System.out.println(response.body());
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	url := "https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout"
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	var body map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	for _, raw := range body["items"].([]any) {
		item := raw.(map[string]any)
		fmt.Println(item["id"], item["name"])
	}
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/tests?project=42&kind=availability&query=checkout";
using var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
foreach (var item in body.GetProperty("items").EnumerateArray())
{
  Console.WriteLine(string.Join("  ",
    item.GetProperty("id"), item.GetProperty("name")));
}

Beispielantwort

Liefert: Ein Objekt, dessen Array items Test-Objekte enthält.

Status: 200 OK

Header: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Antwort-Body: Tests auflistenJSON
{
  "items": [
    {
      "id": "318",
      "customId": "tst_7k2m9q4xh3vd",
      "projectId": "42",
      "name": "Checkout page",
      "kind": "availability",
      "url": "https://shop.example.com/",
      "description": "Checks that the checkout answers quickly and without errors.",
      "scheduleMinutes": 1440,
      "enabled": true,
      "nextRunAt": "2026-10-20T09:12:00.000Z",
      "lastRun": {
        "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"
      },
      "stats": {
        "runs": 30,
        "passed": 28,
        "failed": 2,
        "passRate": 93
      },
      "notificationRouting": {
        "scope": "all",
        "channelIds": []
      },
      "createdAt": "2026-09-02T14:05:00.000Z",
      "updatedAt": "2026-10-12T08:41:00.000Z",
      "links": {
        "self": "/api/v1/tests/318",
        "runs": "/api/v1/tests/318/runs",
        "project": "/api/v1/projects/42"
      }
    }
  ]
}

Mögliche Fehler

  • invalid_request 400 Ein Pfad, Filter oder limit ist ungültig, oder ein JSON-Body ist unlesbar, zu groß oder ungültig.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.

Test abrufen GET /tests/{id}

Ruft einen Test über seine numerische ID oder über die öffentliche tst_…-ID ab, die die App beim Test anzeigt. Erfordert read-Zugriff. Die Konfiguration des Tests (Schritte, Skripte, API-Anfragen, Einstellungen für visuelle Prüfung und Barrierefreiheit, Sitzungs-Setup) wird nie zurückgegeben; Sie bearbeiten sie in der App.

Benötigt einen Schlüssel mit Zugriff: Lesen

Parameter

Parameter: GET /tests/{id}
NameOrtTypPflichtBeschreibungBeispiel
idPfadstring (numeric id or tst_… id)JaDer Test: seine numerische ID oder seine öffentliche tst_…-ID aus der App.tst_7k2m9q4xh3vd

Beispielanfrage

curl --fail-with-body -sS "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
const response = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const body = await response.json();
console.log(`ID: ${body.id}`);
console.log(`Name: ${body.name}`);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.get(
    "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
body = response.json()
print("ID:", body["id"])
print("Name:", body["name"])
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
body = JSON.parse(response.body)
puts "ID: #{body["id"]}"
puts "Name: #{body["name"]}"
<?php
$curl = curl_init("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
$data = json_decode($body, true);
echo "ID: {$data['id']}\n";
echo "Name: {$data['name']}\n";
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    String body = response.body();
    System.out.println("ID: " + field(body, "id"));
    System.out.println("Name: " + field(body, "name"));
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	url := "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd"
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	var body map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	fmt.Println("ID:", body["id"])
	fmt.Println("Name:", body["name"])
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
using var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine($"ID: {body.GetProperty("id")}");
Console.WriteLine($"Name: {body.GetProperty("name")}");

Beispielantwort

Liefert: Ein Test-Objekt.

Status: 200 OK

Header: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Antwort-Body: Test abrufenJSON
{
  "id": "318",
  "customId": "tst_7k2m9q4xh3vd",
  "projectId": "42",
  "name": "Checkout page",
  "kind": "availability",
  "url": "https://shop.example.com/",
  "description": "Checks that the checkout answers quickly and without errors.",
  "scheduleMinutes": 1440,
  "enabled": true,
  "nextRunAt": "2026-10-20T09:12:00.000Z",
  "lastRun": {
    "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"
  },
  "stats": {
    "runs": 30,
    "passed": 28,
    "failed": 2,
    "passRate": 93
  },
  "notificationRouting": {
    "scope": "all",
    "channelIds": []
  },
  "createdAt": "2026-09-02T14:05:00.000Z",
  "updatedAt": "2026-10-12T08:41:00.000Z",
  "links": {
    "self": "/api/v1/tests/318",
    "runs": "/api/v1/tests/318/runs",
    "project": "/api/v1/projects/42"
  }
}

Mögliche Fehler

  • not_found 404 Die Ressource existiert nicht oder liegt außerhalb des Bereichs des Schlüssels.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.

Test anlegen POST /projects/{id}/tests

Legt im Projekt einen Test mit Name, Testart, Adresse und optional Beschreibung, Zeitplan und pausiertem Zustand an. Erfordert einen Schlüssel mit manage-Zugriff; die API legt Erreichbarkeits-, Link-, SEO-, Core-Web-Vitals-, visuelle und Barrierefreiheitstests mit ihren Standardeinstellungen an, während Journeys, Skript-Journeys und API-Tests eine Konfiguration brauchen, die Sie in der App ergänzen. Das Beispiel fügt Projekt 42 eine stündliche Prüfung der Preisseite hinzu.

Benötigt einen Schlüssel mit Zugriff: Verwalten

Parameter

Parameter: POST /projects/{id}/tests
NameOrtTypPflichtBeschreibungBeispiel
idPfadstring (numeric project id)JaDie numerische ID des Projekts, wie sie in Project.id zurückkommt.42
Request-Body: POST /projects/{id}/tests
NameTypPflichtBeschreibungBeispiel
namestring, 1–100 charactersJaDer Name des Tests, wie die App ihn anzeigt: 1–100 Zeichen ohne Zeilenumbrüche."Pricing page"
kind"availability" | "links" | "seo" | "vitals" | "visual" | "a11y"JaWas der Test prüft; die API legt diese Testarten mit ihren Standardeinstellungen an, Journeys, Skript-Journeys und API-Tests entstehen in der App."availability"
urlstring (public http:// or https:// URL)JaDie Seite oder Adresse, die der Test prüft: eine vollständige, öffentliche http://- oder https://-URL."https://shop.example.com/pricing"
descriptionstring, ≤ 500 characters | nullNeinEine Notiz mit bis zu 500 Zeichen; null oder eine leere Zeichenkette lässt sie leer."Checks that the pricing page answers quickly."
scheduleMinutes15 | 60 | 180 | 360 | 720 | 960 | 1440 | nullNeinMinuten zwischen zwei geplanten Läufen (60 = stündlich, 1440 = täglich) oder null für Läufe nur auf Anfrage; der Tarif der Organisation bestimmt, welche Zeitpläne verfügbar sind.60
enabledboolean, default trueNeinfalse pausiert den Test, sodass er keine geplanten Läufe erhält; ein neuer Test ist aktiviert, wenn Sie das Feld weglassen.true

Beispielanfrage

Request-Body: Test anlegenJSON
{
  "name": "Pricing page",
  "kind": "availability",
  "url": "https://shop.example.com/pricing",
  "description": "Checks that the pricing page answers quickly.",
  "scheduleMinutes": 60,
  "enabled": true
}
curl --fail-with-body -sS -X POST -i "https://optisway.com/api/v1/projects/42/tests" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY" \
  -H "Content-Type: application/json" -d '{
  "name": "Pricing page",
  "kind": "availability",
  "url": "https://shop.example.com/pricing",
  "description": "Checks that the pricing page answers quickly.",
  "scheduleMinutes": 60,
  "enabled": true
}'
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/projects/42/tests";
const response = await fetch(url, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Pricing page",
    "kind": "availability",
    "url": "https://shop.example.com/pricing",
    "description": "Checks that the pricing page answers quickly.",
    "scheduleMinutes": 60,
    "enabled": true
  }),
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const test = await response.json();
const location = response.headers.get("location");
console.log(`Created test ${test.customId} (${test.id}): ${location}`);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
payload = {
    "name": "Pricing page",
    "kind": "availability",
    "url": "https://shop.example.com/pricing",
    "description": "Checks that the pricing page answers quickly.",
    "scheduleMinutes": 60,
    "enabled": True,
}
response = requests.post(
    "https://optisway.com/api/v1/projects/42/tests",
    headers={"Authorization": f"Bearer {api_key}"},
    json=payload,  # sent as Content-Type: application/json
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
test = response.json()
print(f"Created test {test['customId']} ({test['id']}): {response.headers['Location']}")
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/projects/42/tests")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = JSON.generate({
  "name" => 'Pricing page',
  "kind" => 'availability',
  "url" => 'https://shop.example.com/pricing',
  "description" => 'Checks that the pricing page answers quickly.',
  "scheduleMinutes" => 60,
  "enabled" => true,
})
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
test = JSON.parse(response.body)
puts "Created test #{test["customId"]} (#{test["id"]}): #{response["Location"]}"
<?php
$location = null;
$curl = curl_init("https://optisway.com/api/v1/projects/42/tests");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode([
    'name' => 'Pricing page',
    'kind' => 'availability',
    'url' => 'https://shop.example.com/pricing',
    'description' => 'Checks that the pricing page answers quickly.',
    'scheduleMinutes' => 60,
    'enabled' => true,
  ]),
  CURLOPT_HEADERFUNCTION => function ($curl, $line) use (&$location) {
    if (stripos($line, "location:") === 0) $location = trim(substr($line, 9));
    return strlen($line);
  },
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
$test = json_decode($body, true);
echo "Created test {$test['customId']} ({$test['id']}): $location\n";
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/projects/42/tests";
    String json = String.join("\n",
        "{",
        "  \"name\": \"Pricing page\",",
        "  \"kind\": \"availability\",",
        "  \"url\": \"https://shop.example.com/pricing\",",
        "  \"description\": \"Checks that the pricing page answers quickly.\",",
        "  \"scheduleMinutes\": 60,",
        "  \"enabled\": true",
        "}");
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .header("Content-Type", "application/json")
        .POST(HttpRequest.BodyPublishers.ofString(json))
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    String body = response.body();
    String location = response.headers().firstValue("Location").orElse("");
    System.out.println("Created test " + field(body, "customId") + " (" + field(body, "id") + "): "
        + location);
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"strings"
)

func main() {
	url := "https://optisway.com/api/v1/projects/42/tests"
	payload := `{
	"name": "Pricing page",
	"kind": "availability",
	"url": "https://shop.example.com/pricing",
	"description": "Checks that the pricing page answers quickly.",
	"scheduleMinutes": 60,
	"enabled": true
}`
	req, err := http.NewRequest(http.MethodPost, url, strings.NewReader(payload))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	var body map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	location := resp.Header.Get("Location")
	fmt.Printf("Created test %v (%v): %s\n", body["customId"], body["id"], location)
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/projects/42/tests";
var json = """
  {
    "name": "Pricing page",
    "kind": "availability",
    "url": "https://shop.example.com/pricing",
    "description": "Checks that the pricing page answers quickly.",
    "scheduleMinutes": 60,
    "enabled": true
  }
  """;
using var response = await client.PostAsync(url,
  new StringContent(json, Encoding.UTF8, "application/json"));
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
var test = await response.Content.ReadFromJsonAsync<JsonElement>();
var customId = test.GetProperty("customId");
var id = test.GetProperty("id");
Console.WriteLine($"Created test {customId} ({id}): {response.Headers.Location}");

Beispielantwort

Liefert: Das neue Test-Objekt mit 201 Created und einem Location-Header, der darauf zeigt.

Status: 201 Created

Header: Content-Type: application/json; charset=utf-8 Cache-Control: no-store Location: /api/v1/tests/319

Der Test ist gespeichert: Verwenden Sie seine customId, die tst_…-ID, in Skripten und in der CI. Mit Zeitplan ist sein erster Lauf ein Intervall nach jetzt fällig.

Antwort-Body: Test anlegenJSON
{
  "id": "319",
  "customId": "tst_9w4n2r8c5t1p",
  "projectId": "42",
  "name": "Pricing page",
  "kind": "availability",
  "url": "https://shop.example.com/pricing",
  "description": "Checks that the pricing page answers quickly.",
  "scheduleMinutes": 60,
  "enabled": true,
  "nextRunAt": "2026-10-20T10:30:00.000Z",
  "lastRun": null,
  "stats": {
    "runs": 0,
    "passed": 0,
    "failed": 0,
    "passRate": null
  },
  "notificationRouting": {
    "scope": "all",
    "channelIds": []
  },
  "createdAt": "2026-10-20T09:30:00.000Z",
  "updatedAt": "2026-10-20T09:30:00.000Z",
  "links": {
    "self": "/api/v1/tests/319",
    "runs": "/api/v1/tests/319/runs",
    "project": "/api/v1/projects/42"
  }
}

Mögliche Fehler

  • forbidden 403 Die Zugriffsstufe des Schlüssels reicht nicht: Ein read-Schlüssel wollte einen Lauf starten, oder ein Schlüssel ohne manage wollte Tests ändern. Auch, wenn der Ersteller des Schlüssels keine Tests löschen darf.
  • invalid_request 400 Ein Pfad, Filter oder limit ist ungültig, oder ein JSON-Body ist unlesbar, zu groß oder ungültig.
  • not_found 404 Die Ressource existiert nicht oder liegt außerhalb des Bereichs des Schlüssels.
  • plan_limit_reached 422 Der Tarif der Organisation erlaubt es nicht: Das Testlimit ist erreicht, die Testart ist nicht enthalten, oder (bei Artefakt-Downloads) der Tarif enthält keine Laufnachweise.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.

Test ändern PATCH /tests/{id}

Ändert die gesendeten Felder und behält die übrigen; null leert description oder den Zeitplan, und kind sowie die Konfiguration ändern sich hier nie. Erfordert einen Schlüssel mit manage-Zugriff; ein neuer Zeitplan oder ein neuer Wert für enabled startet das Intervall ab jetzt neu, und die Auswahl von Benachrichtigungskanälen erfordert einen Tarif, der sie enthält. Das Beispiel benennt Test tst_7k2m9q4xh3vd um, lässt ihn stündlich laufen und sendet seine Benachrichtigungen nur an den Slack-Kanal des Checkout-Teams.

Benötigt einen Schlüssel mit Zugriff: Verwalten

Parameter

Parameter: PATCH /tests/{id}
NameOrtTypPflichtBeschreibungBeispiel
idPfadstring (numeric id or tst_… id)JaDer Test: seine numerische ID oder seine öffentliche tst_…-ID aus der App.tst_7k2m9q4xh3vd
Request-Body: PATCH /tests/{id}
NameTypPflichtBeschreibungBeispiel
namestring, 1–100 charactersNeinDer Name des Tests, wie die App ihn anzeigt: 1–100 Zeichen ohne Zeilenumbrüche."Checkout page (EU)"
urlstring (public http:// or https:// URL)NeinDie Seite oder Adresse, die der Test prüft: eine vollständige, öffentliche http://- oder https://-URL.null
descriptionstring, ≤ 500 characters | nullNeinEine Notiz mit bis zu 500 Zeichen; null oder eine leere Zeichenkette lässt sie leer.null
scheduleMinutes15 | 60 | 180 | 360 | 720 | 960 | 1440 | nullNeinMinuten zwischen zwei geplanten Läufen (60 = stündlich, 1440 = täglich) oder null für Läufe nur auf Anfrage; der Tarif der Organisation bestimmt, welche Zeitpläne verfügbar sind.60
enabledbooleanNeinfalse pausiert den Test, sodass er keine geplanten Läufe erhält; ein neuer Test ist aktiviert, wenn Sie das Feld weglassen.null
notificationRoutingNotificationRoutingNeinWelche Benachrichtigungskanäle der Test benachrichtigt, mit den IDs aus der Kanalliste; Kanäle auszuwählen erfordert einen Tarif mit Benachrichtigungskanälen, alle Kanäle sind immer erlaubt.{"scope":"selected","channelIds":["12"]}

Beispielanfrage

Request-Body: Test ändernJSON
{
  "name": "Checkout page (EU)",
  "scheduleMinutes": 60,
  "notificationRouting": {
    "scope": "selected",
    "channelIds": [
      "12"
    ]
  }
}
curl --fail-with-body -sS -X PATCH "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY" \
  -H "Content-Type: application/json" -d '{
  "name": "Checkout page (EU)",
  "scheduleMinutes": 60,
  "notificationRouting": {
    "scope": "selected",
    "channelIds": [
      "12"
    ]
  }
}'
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
const response = await fetch(url, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Checkout page (EU)",
    "scheduleMinutes": 60,
    "notificationRouting": {
      "scope": "selected",
      "channelIds": [
        "12"
      ]
    }
  }),
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const body = await response.json();
console.log(`Name: ${body.name}`);
console.log(`Next run: ${body.nextRunAt}`);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
payload = {
    "name": "Checkout page (EU)",
    "scheduleMinutes": 60,
    "notificationRouting": {
        "scope": "selected",
        "channelIds": ["12"],
    },
}
response = requests.patch(
    "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd",
    headers={"Authorization": f"Bearer {api_key}"},
    json=payload,  # sent as Content-Type: application/json
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
body = response.json()
print("Name:", body["name"])
print("Next run:", body["nextRunAt"])
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd")
request = Net::HTTP::Patch.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = JSON.generate({
  "name" => 'Checkout page (EU)',
  "scheduleMinutes" => 60,
  "notificationRouting" => {
    "scope" => 'selected',
    "channelIds" => ['12'],
  },
})
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
body = JSON.parse(response.body)
puts "Name: #{body["name"]}"
puts "Next run: #{body["nextRunAt"]}"
<?php
$curl = curl_init("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => json_encode([
    'name' => 'Checkout page (EU)',
    'scheduleMinutes' => 60,
    'notificationRouting' => [
      'scope' => 'selected',
      'channelIds' => ['12'],
    ],
  ]),
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
$data = json_decode($body, true);
echo "Name: {$data['name']}\n";
echo "Next run: {$data['nextRunAt']}\n";
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
    String json = String.join("\n",
        "{",
        "  \"name\": \"Checkout page (EU)\",",
        "  \"scheduleMinutes\": 60,",
        "  \"notificationRouting\": {",
        "    \"scope\": \"selected\",",
        "    \"channelIds\": [",
        "      \"12\"",
        "    ]",
        "  }",
        "}");
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .header("Content-Type", "application/json")
        .method("PATCH", HttpRequest.BodyPublishers.ofString(json))
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    String body = response.body();
    System.out.println("Name: " + field(body, "name"));
    System.out.println("Next run: " + field(body, "nextRunAt"));
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"strings"
)

func main() {
	url := "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd"
	payload := `{
	"name": "Checkout page (EU)",
	"scheduleMinutes": 60,
	"notificationRouting": {
		"scope": "selected",
		"channelIds": [
			"12"
		]
	}
}`
	req, err := http.NewRequest(http.MethodPatch, url, strings.NewReader(payload))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	var body map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	fmt.Println("Name:", body["name"])
	fmt.Println("Next run:", body["nextRunAt"])
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
var json = """
  {
    "name": "Checkout page (EU)",
    "scheduleMinutes": 60,
    "notificationRouting": {
      "scope": "selected",
      "channelIds": [
        "12"
      ]
    }
  }
  """;
using var response = await client.PatchAsync(url,
  new StringContent(json, Encoding.UTF8, "application/json"));
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine($"Name: {body.GetProperty("name")}");
Console.WriteLine($"Next run: {body.GetProperty("nextRunAt")}");

Beispielantwort

Liefert: Das geänderte Test-Objekt.

Status: 200 OK

Header: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Antwort-Body: Test ändernJSON
{
  "id": "318",
  "customId": "tst_7k2m9q4xh3vd",
  "projectId": "42",
  "name": "Checkout page (EU)",
  "kind": "availability",
  "url": "https://shop.example.com/",
  "description": "Checks that the checkout answers quickly and without errors.",
  "scheduleMinutes": 60,
  "enabled": true,
  "nextRunAt": "2026-10-20T10:45:00.000Z",
  "lastRun": {
    "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"
  },
  "stats": {
    "runs": 30,
    "passed": 28,
    "failed": 2,
    "passRate": 93
  },
  "notificationRouting": {
    "scope": "selected",
    "channelIds": [
      "12"
    ]
  },
  "createdAt": "2026-09-02T14:05:00.000Z",
  "updatedAt": "2026-10-20T09:45:00.000Z",
  "links": {
    "self": "/api/v1/tests/318",
    "runs": "/api/v1/tests/318/runs",
    "project": "/api/v1/projects/42"
  }
}

Mögliche Fehler

  • forbidden 403 Die Zugriffsstufe des Schlüssels reicht nicht: Ein read-Schlüssel wollte einen Lauf starten, oder ein Schlüssel ohne manage wollte Tests ändern. Auch, wenn der Ersteller des Schlüssels keine Tests löschen darf.
  • invalid_request 400 Ein Pfad, Filter oder limit ist ungültig, oder ein JSON-Body ist unlesbar, zu groß oder ungültig.
  • not_found 404 Die Ressource existiert nicht oder liegt außerhalb des Bereichs des Schlüssels.
  • plan_limit_reached 422 Der Tarif der Organisation erlaubt es nicht: Das Testlimit ist erreicht, die Testart ist nicht enthalten, oder (bei Artefakt-Downloads) der Tarif enthält keine Laufnachweise.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.

Test löschen DELETE /tests/{id}

Löscht den Test mit seinem Laufverlauf; das lässt sich nicht rückgängig machen. Erfordert einen Schlüssel mit manage-Zugriff, dessen Ersteller Inhaber oder Admin ist, und solange der Test einen wartenden oder laufenden Lauf hat, antwortet die API mit 409 run_in_progress und löscht nichts. Das Beispiel löscht Test tst_7k2m9q4xh3vd.

Benötigt einen Schlüssel mit Zugriff: Verwalten

Parameter

Parameter: DELETE /tests/{id}
NameOrtTypPflichtBeschreibungBeispiel
idPfadstring (numeric id or tst_… id)JaDer Test: seine numerische ID oder seine öffentliche tst_…-ID aus der App.tst_7k2m9q4xh3vd

Beispielanfrage

curl --fail-with-body -sS -X DELETE "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY" \
  -w "HTTP %{http_code}\n"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
const response = await fetch(url, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
console.log(`Deleted (HTTP ${response.status})`);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.delete(
    "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
print(f"Deleted (HTTP {response.status_code})")
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd")
request = Net::HTTP::Delete.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
puts "Deleted (HTTP #{response.code})"
<?php
$curl = curl_init("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
  CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
echo "Deleted (HTTP $status)\n";
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .DELETE()
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    System.out.println("Deleted (HTTP " + response.statusCode() + ")");
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	url := "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd"
	req, err := http.NewRequest(http.MethodDelete, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	fmt.Printf("Deleted (HTTP %d)\n", resp.StatusCode)
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd";
using var response = await client.DeleteAsync(url);
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
Console.WriteLine($"Deleted (HTTP {(int)response.StatusCode})");

Beispielantwort

Liefert: Kein Body: Der Status ist 204 No Content.

Status: 204 No Content

Header: Cache-Control: no-store

Es gibt keinen Body. Der Test und seine Läufe sind entfernt, und seine IDs antworten jetzt mit 404 not_found.

Mögliche Fehler

  • forbidden 403 Die Zugriffsstufe des Schlüssels reicht nicht: Ein read-Schlüssel wollte einen Lauf starten, oder ein Schlüssel ohne manage wollte Tests ändern. Auch, wenn der Ersteller des Schlüssels keine Tests löschen darf.
  • not_found 404 Die Ressource existiert nicht oder liegt außerhalb des Bereichs des Schlüssels.
  • run_in_progress 409 Für den Test läuft bereits ein Lauf.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.

Läufe eines Tests auflisten GET /tests/{id}/runs

Listet die Läufe eines Tests seitenweise auf, die neuesten zuerst. Erfordert read-Zugriff. Das Beispiel fordert zwei Läufe pro Seite an; weil die Seite voll ist, enthält next den Pfad der nächsten Seite.

Benötigt einen Schlüssel mit Zugriff: Lesen

Parameter

Parameter: GET /tests/{id}/runs
NameOrtTypPflichtBeschreibungBeispiel
idPfadstring (numeric id or tst_… id)JaDer Test: seine numerische ID oder seine öffentliche tst_…-ID aus der App.tst_7k2m9q4xh3vd
limitQuery-Stringinteger, 1–50, default 20NeinWie viele Läufe eine Seite enthält: eine ganze Zahl von 1 bis 50; ohne Angabe enthält eine Seite 20.2
beforeQuery-Stringstring (run id)NeinLiefert nur Läufe, die älter sind als diese Lauf-ID; normalerweise folgen Sie next, statt den Wert selbst zu setzen.4790

Beispielanfrage

curl --fail-with-body -sS "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2";
const response = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const { items } = await response.json();
for (const item of items) console.log(item.id, item.status, item.summary);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.get(
    "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
for item in response.json()["items"]:
    print(item["id"], item["status"], item["summary"])
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
JSON.parse(response.body)["items"].each do |item|
  puts [item["id"], item["status"], item["summary"]].join("  ")
end
<?php
$curl = curl_init("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
foreach (json_decode($body, true)["items"] as $item) {
  echo $item["id"], "  ", $item["status"], "  ", $item["summary"], "\n";
}
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2";
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    // { "items": [...], "next": ... } -- any JSON library (Jackson, Gson, org.json) parses it;
    // this example stays dependency-free and prints the raw JSON.
    System.out.println(response.body());
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	url := "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2"
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	var body map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	for _, raw := range body["items"].([]any) {
		item := raw.(map[string]any)
		fmt.Println(item["id"], item["status"], item["summary"])
	}
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2";
using var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
foreach (var item in body.GetProperty("items").EnumerateArray())
{
  Console.WriteLine(string.Join("  ",
    item.GetProperty("id"), item.GetProperty("status"), item.GetProperty("summary")));
}

Beispielantwort

Liefert: Ein Objekt mit items (Run-Objekte) und next (Pfad der nächsten Seite oder null auf der letzten Seite).

Status: 200 OK

Header: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Antwort-Body: Läufe eines Tests auflistenJSON
{
  "items": [
    {
      "id": "4821",
      "testId": "318",
      "testName": "Checkout page",
      "testKind": "availability",
      "projectId": "42",
      "projectName": "Acme Shop",
      "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",
      "checks": {
        "total": 3,
        "passed": 2,
        "failed": 1
      },
      "findings": [
        {
          "severity": "fail",
          "code": "status",
          "message": "503 Service Unavailable",
          "target": "https://shop.example.com/",
          "value": 503,
          "unit": "status",
          "ruleId": null
        },
        {
          "severity": "pass",
          "code": "redirect-chain",
          "message": "No redirects",
          "target": "https://shop.example.com/",
          "value": 0,
          "unit": "count",
          "ruleId": null
        },
        {
          "severity": "pass",
          "code": "response-time",
          "message": "184 ms",
          "target": "https://shop.example.com/",
          "value": 184,
          "unit": "ms",
          "ruleId": null
        }
      ],
      "artifacts": {
        "bytes": 48213,
        "video": false,
        "url": "/api/v1/runs/4821/artifacts",
        "filesUrl": "/api/v1/runs/4821/files"
      },
      "artifactError": null,
      "createdAt": "2026-10-19T09:12:00.000Z",
      "links": {
        "self": "/api/v1/runs/4821",
        "test": "/api/v1/tests/318"
      }
    },
    {
      "id": "4790",
      "testId": "318",
      "testName": "Checkout page",
      "testKind": "availability",
      "projectId": "42",
      "projectName": "Acme Shop",
      "status": "failed",
      "trigger": "schedule",
      "startedAt": "2026-10-18T09:12:02.000Z",
      "finishedAt": "2026-10-18T09:12:12.310Z",
      "durationMs": 10310,
      "summary": "The page could not be loaded: No response within 10 s.",
      "checks": {
        "total": 1,
        "passed": 0,
        "failed": 1
      },
      "findings": [
        {
          "severity": "fail",
          "code": "fetch-error",
          "message": "No response within 10 s.",
          "target": "https://shop.example.com/",
          "value": null,
          "unit": null,
          "ruleId": null
        }
      ],
      "artifacts": {
        "bytes": 41877,
        "video": false,
        "url": "/api/v1/runs/4790/artifacts",
        "filesUrl": "/api/v1/runs/4790/files"
      },
      "artifactError": null,
      "createdAt": "2026-10-18T09:12:00.000Z",
      "links": {
        "self": "/api/v1/runs/4790",
        "test": "/api/v1/tests/318"
      }
    }
  ],
  "next": "/api/v1/tests/tst_7k2m9q4xh3vd/runs?limit=2&before=4790"
}

Mögliche Fehler

  • invalid_request 400 Ein Pfad, Filter oder limit ist ungültig, oder ein JSON-Body ist unlesbar, zu groß oder ungültig.
  • not_found 404 Die Ressource existiert nicht oder liegt außerhalb des Bereichs des Schlüssels.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.

Lauf starten POST /tests/{id}/runs

Stellt einen Lauf des Tests mit trigger api in die Warteschlange und antwortet sofort mit 202 Accepted, ohne auf das Ergebnis zu warten; der Lauf zählt zu den 30 manuellen und API-Läufen pro Stunde der Organisation. Erfordert einen Schlüssel mit run-Zugriff; senden Sie keinen Body (ein JSON-Body bis 16 KiB wird angenommen und ignoriert). Das Beispiel stellt Lauf 4821 ein, auf den der Header Location zeigt.

Benötigt einen Schlüssel mit Zugriff: Ausführen

Parameter

Parameter: POST /tests/{id}/runs
NameOrtTypPflichtBeschreibungBeispiel
idPfadstring (numeric id or tst_… id)JaDer Test: seine numerische ID oder seine öffentliche tst_…-ID aus der App.tst_7k2m9q4xh3vd

Beispielanfrage

curl --fail-with-body -sS -X POST -i "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs";
const response = await fetch(url, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const run = await response.json();
console.log(`Run ${run.id} is ${run.status}: ${response.headers.get("location")}`);
console.log("Poll GET /runs/{id} every 10 seconds until status is passed, failed or error.");
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.post(
    "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
run = response.json()
print(f"Run {run['id']} is {run['status']}: {response.headers['Location']}")
print("Poll GET /runs/{id} every 10 seconds until status is passed, failed or error.")
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
run = JSON.parse(response.body)
puts "Run #{run["id"]} is #{run["status"]}: #{response["Location"]}"
puts "Poll GET /runs/{id} every 10 seconds until status is passed, failed or error."
<?php
$location = null;
$curl = curl_init("https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HEADERFUNCTION => function ($curl, $line) use (&$location) {
    if (stripos($line, "location:") === 0) $location = trim(substr($line, 9));
    return strlen($line);
  },
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
$run = json_decode($body, true);
echo "Run {$run['id']} is {$run['status']}: $location\n";
echo "Poll GET /runs/{id} every 10 seconds until status is passed, failed or error.", "\n";
// Java 11+: save as Main.java and run `java Main.java`
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs";
    HttpRequest request = HttpRequest.newBuilder(URI.create(url))
        .header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
        .POST(HttpRequest.BodyPublishers.noBody())
        .build();
    HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() >= 300) {
      String error = response.body();
      System.err.println(response.statusCode() + " " + field(error, "error") + ": "
          + field(error, "message"));
      System.exit(1);
    }
    String body = response.body();
    String location = response.headers().firstValue("Location").orElse("");
    System.out.println("Run " + field(body, "id") + " is " + field(body, "status") + ": " + location);
    System.out.println("Poll GET /runs/{id} every 10 seconds until status is passed, failed or error.");
  }

  /** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */
  static String field(String json, String key) {
    Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
        .matcher(json);
    return match.find() ? match.group(1) : null;
  }
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	url := "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs"
	req, err := http.NewRequest(http.MethodPost, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		var envelope struct {
			Error   string `json:"error"`
			Message string `json:"message"`
		}
		_ = json.NewDecoder(resp.Body).Decode(&envelope)
		fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
		os.Exit(1)
	}
	var body map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	fmt.Printf("Run %v is %v: %s\n", body["id"], body["status"], resp.Header.Get("Location"))
	fmt.Println("Poll GET /runs/{id} every 10 seconds until status is passed, failed or error.")
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/tests/tst_7k2m9q4xh3vd/runs";
using var response = await client.PostAsync(url, null);
if (!response.IsSuccessStatusCode)
{
  var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
  var error = envelope.GetProperty("error");
  var message = envelope.GetProperty("message");
  Console.Error.WriteLine($"{(int)response.StatusCode} {error}: {message}");
  Environment.Exit(1);
}
var run = await response.Content.ReadFromJsonAsync<JsonElement>();
var id = run.GetProperty("id");
var status = run.GetProperty("status");
Console.WriteLine($"Run {id} is {status}: {response.Headers.Location}");
Console.WriteLine("Poll GET /runs/{id} every 10 seconds until status is passed, failed or error.");

Beispielantwort

Liefert: Das Run-Objekt des eingestellten Laufs (status ist queued).

Status: 202 Accepted

Header: Content-Type: application/json; charset=utf-8 Cache-Control: no-store Location: /api/v1/runs/4821

Der Lauf wartet, er ist noch nicht fertig: Rufen Sie GET /runs/{id} (der Header Location) alle 10 Sekunden ab, bis status passed, failed oder error ist.

Antwort-Body: Lauf startenJSON
{
  "id": "4821",
  "testId": "318",
  "testName": "Checkout page",
  "testKind": "availability",
  "projectId": "42",
  "projectName": "Acme Shop",
  "status": "queued",
  "trigger": "api",
  "startedAt": null,
  "finishedAt": null,
  "durationMs": null,
  "summary": "",
  "checks": {
    "total": 0,
    "passed": 0,
    "failed": 0
  },
  "findings": [],
  "artifacts": null,
  "artifactError": null,
  "createdAt": "2026-10-19T09:12:00.000Z",
  "links": {
    "self": "/api/v1/runs/4821",
    "test": "/api/v1/tests/318"
  }
}

Mögliche Fehler

  • forbidden 403 Die Zugriffsstufe des Schlüssels reicht nicht: Ein read-Schlüssel wollte einen Lauf starten, oder ein Schlüssel ohne manage wollte Tests ändern. Auch, wenn der Ersteller des Schlüssels keine Tests löschen darf.
  • not_found 404 Die Ressource existiert nicht oder liegt außerhalb des Bereichs des Schlüssels.
  • run_in_progress 409 Für den Test läuft bereits ein Lauf.
  • run_limit_reached 429 Die Organisation hat ihr stündliches Laufbudget oder das Tages- oder Monatskontingent ihres Tarifs aufgebraucht; Retry-After nennt, wann es weitergeht.
  • kind_unsupported 422 Dieser Server kann die Testart gerade nicht ausführen.
  • plan_limit_reached 422 Der Tarif der Organisation erlaubt es nicht: Das Testlimit ist erreicht, die Testart ist nicht enthalten, oder (bei Artefakt-Downloads) der Tarif enthält keine Laufnachweise.
  • invalid_request 400 Ein Pfad, Filter oder limit ist ungültig, oder ein JSON-Body ist unlesbar, zu groß oder ungültig.
  • unauthorized 401 Der Schlüssel fehlt, ist fehlerhaft, unbekannt, widerrufen oder abgelaufen, oder sein Ersteller ist kein Mitglied mehr.
  • rate_limited 429 Der Schlüssel hat zu viele Anfragen gesendet; warten Sie die Sekunden aus Retry-After ab.
  • unavailable 503 Ein vorübergehendes Problem bei uns; versuchen Sie es später erneut.