Optisway ana sayfa
Dokümantasyon menüsü

REST API referansı: Testler

API testleri listeler, okur ve çalıştırmalarını başlatır; manage anahtarıyla onları oluşturur, değiştirir ve siler, yapılandırmaları ise uygulamada kalır. Her testin sayısal bir id değeri ve uygulamada gösterilen herkese açık bir tst_… kimliği vardır; bir yol test {id} beklediği her yerde ikisi de çalışır.

Test

Türü, zamanlaması, sonraki ve son çalıştırması, başarı istatistikleri ve bildirim gönderdiği kanallarla bir test.

Alanlar: Test
AlanTürAçıklama
idstringTestin ondalık bir dize olarak sayısal kimliği.
customIdstring (tst_…)Uygulamada gösterilen herkese açık test kimliği (tst_ ve 12 karakter); hiç değişmez ve test kimliği beklenen her yerde kullanılabilir.
projectIdstringTestin ait olduğu projenin kimliği.
namestringTestin uygulamada gösterilen adı.
kind"availability" | "links" | "seo" | "vitals" | "visual" | "a11y" | "rest" | "graphql" | "script" | "journey"Testin neyi kontrol ettiği: on test türünden biri.
urlstringTestin açtığı ya da çağırdığı adres.
descriptionstringTestin açıklaması; açıklama yazılmamışsa boş bir dize.
scheduleMinutesinteger | nullİki zamanlanmış çalıştırma arasındaki dakika (1440 = günde bir kez) ya da test yalnızca istek üzerine çalışıyorsa null.
enabledbooleanTest duraklatıldığı sürece false; duraklatılmış bir test zamanlanmış çalıştırma almaz.
nextRunAtISO 8601 string | nullBir sonraki zamanlanmış çalıştırmanın zamanı (UTC) ya da etkin bir zamanlama yoksa null.
lastRunRunSummary | nullTestin en yeni çalıştırması (RunSummary) ya da ilk çalıştırmadan önce null.
stats.runsintegerTestin son 30 gündeki çalıştırma sayısı.
stats.passedintegerBu çalıştırmalardan kaçının başarılı olduğu.
stats.failedintegerBu çalıştırmalardan kaçının başarısız olduğu.
stats.passRateinteger (0–100) | nullSon 30 gündeki başarılı ve başarısız çalıştırmalar içinde başarılı olanların tam sayı yüzdesi (0–100) ya da hiç yoksa null.
notificationRoutingNotificationRoutingTestin biten çalıştırmalarının hangi bildirim kanallarına bildirim gönderdiği: kuruluşun her etkin kanalına (varsayılan) ya da yalnızca seçilenlere.
createdAtISO 8601 stringTestin oluşturulduğu zaman (UTC).
updatedAtISO 8601 stringTestin son değiştirildiği zaman (UTC).
links.selfstringBu testin yolu (GET /tests/{id}).
links.runsstringBu testin çalıştırmalarının yolu: GET onları listeler, POST yeni bir çalıştırma başlatır.
links.projectstringTestin ait olduğu projenin yolu.
Örnek: 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"
  }
}

Testleri listele GET /tests

Anahtarın kapsamındaki testleri listeler; isteğe bağlı project, kind ve query filtreleri birlikte kullanılabilir. read erişimi gerekir ve liste sayfalara bölünmez. Örnek, 42 numaralı projedeki “Checkout page” adlı ulaşılabilirlik ve yanıt testini bulur.

Gereken anahtar erişimi: Okuma

Parametreler

Parametreler: GET /tests
AdKonumTürZorunluAçıklamaÖrnek
projectSorgu dizesistring (numeric project id)HayırYalnızca bu projenin testlerini döndürür (sayısal kimlik).42
kindSorgu dizesi"availability" | "links" | "seo" | "vitals" | "visual" | "a11y" | "rest" | "graphql" | "script" | "journey"HayırYalnızca bu türdeki testleri döndürür.availability
querySorgu dizesistring, 2–100 charactersHayırYalnızca adı, URL'si ya da tst_… kimliği bu metni içeren testleri döndürür (2–100 karakter).checkout

Örnek istek

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")));
}

Örnek yanıt

Döndürür: items dizisinde Test nesneleri bulunan bir nesne.

Durum: 200 OK

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Yanıt gövdesi: Testleri listeleJSON
{
  "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"
      }
    }
  ]
}

Alabileceğiniz hatalar

  • invalid_request 400 Bir yol, filtre veya limit geçersiz ya da JSON gövdesi okunamıyor, çok büyük veya geçersiz.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Testi getir GET /tests/{id}

Bir testi sayısal kimliğiyle ya da uygulamada testin üzerinde gösterilen herkese açık tst_… kimliğiyle getirir. read erişimi gerekir. Testin yapılandırması (adımlar, betikler, API istekleri, görsel ve erişilebilirlik ayarları, oturum kurulumu) hiçbir zaman döndürülmez; onu uygulamada düzenlersiniz.

Gereken anahtar erişimi: Okuma

Parametreler

Parametreler: GET /tests/{id}
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric id or tst_… id)EvetTest: sayısal kimliği ya da uygulamadaki herkese açık tst_… kimliği.tst_7k2m9q4xh3vd

Örnek istek

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")}");

Örnek yanıt

Döndürür: Bir Test nesnesi.

Durum: 200 OK

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Yanıt gövdesi: Testi getirJSON
{
  "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"
  }
}

Alabileceğiniz hatalar

  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Test oluştur POST /projects/{id}/tests

Projede ad, tür ve adresle, isteğe bağlı olarak da açıklama, zamanlama ve duraklatılmış durumla bir test oluşturur. manage erişimli bir anahtar gerekir; API ulaşılabilirlik, bağlantı, SEO, Core Web Vitals, görsel ve erişilebilirlik testlerini varsayılan ayarlarıyla oluşturur, yolculuklar, betikli yolculuklar ve API testleri ise uygulamada eklediğiniz yapılandırmayı gerektirir. Örnek, 42 numaralı projeye fiyatlandırma sayfasının saatlik kontrolünü ekler.

Gereken anahtar erişimi: Yönetme

Parametreler

Parametreler: POST /projects/{id}/tests
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric project id)EvetProjenin Project.id alanında döndürülen sayısal kimliği.42
İstek gövdesi: POST /projects/{id}/tests
AdTürZorunluAçıklamaÖrnek
namestring, 1–100 charactersEvetTestin uygulamada gösterilen adı: satır sonu içermeyen 1–100 karakter."Pricing page"
kind"availability" | "links" | "seo" | "vitals" | "visual" | "a11y"EvetTestin neyi kontrol ettiği; API bu türleri varsayılan ayarlarıyla oluşturur, yolculuklar, betikli yolculuklar ve API testleri ise uygulamada oluşturulur."availability"
urlstring (public http:// or https:// URL)EvetTestin kontrol ettiği sayfa veya adres: eksiksiz, herkese açık bir http:// ya da https:// URL'si."https://shop.example.com/pricing"
descriptionstring, ≤ 500 characters | nullHayırEn fazla 500 karakterlik bir not; null ya da boş bir dize onu boş bırakır."Checks that the pricing page answers quickly."
scheduleMinutes15 | 60 | 180 | 360 | 720 | 960 | 1440 | nullHayırİki zamanlanmış çalıştırma arasındaki dakika (60 = saatlik, 1440 = günlük) ya da yalnızca isteğe bağlı çalıştırmalar için null; hangi zamanlamaların sunulduğuna organizasyonun planı karar verir.60
enabledboolean, default trueHayırfalse testi duraklatır, böylece zamanlanmış çalıştırma almaz; alanı göndermezseniz yeni test etkin olur.true

Örnek istek

İstek gövdesi: Test oluşturJSON
{
  "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}");

Örnek yanıt

Döndürür: Yeni Test nesnesi; 201 Created ve onu gösteren bir Location başlığıyla.

Durum: 201 Created

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store Location: /api/v1/tests/319

Test kaydedildi: betiklerde ve CI'da onun customId değerini, yani tst_… kimliğini kullanın. Zamanlaması varsa ilk çalıştırması şimdiden bir aralık sonra yapılır.

Yanıt gövdesi: Test oluşturJSON
{
  "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"
  }
}

Alabileceğiniz hatalar

  • forbidden 403 Anahtarın erişim düzeyi yetersiz: bir read anahtarı çalıştırma başlatmaya ya da manage erişimi olmayan bir anahtar testleri değiştirmeye çalıştı. Anahtarı oluşturan kişi test silemiyorsa da oluşur.
  • invalid_request 400 Bir yol, filtre veya limit geçersiz ya da JSON gövdesi okunamıyor, çok büyük veya geçersiz.
  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • plan_limit_reached 422 Organizasyonun planı buna izin vermiyor: test sınırına ulaşıldı, bu test türü plana dahil değil veya (artefakt indirmelerinde) çalıştırma kanıtları plana dahil değil.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Testi güncelle PATCH /tests/{id}

Gönderdiğiniz alanları değiştirir, diğerlerini korur; null değeri description alanını veya zamanlamayı temizler, kind ve yapılandırma ise burada hiç değişmez. manage erişimli bir anahtar gerekir; yeni bir zamanlama veya yeni bir enabled değeri aralığı şimdiden yeniden başlatır, bildirim kanalı seçmek ise bunları içeren bir plan gerektirir. Örnek, tst_7k2m9q4xh3vd testini yeniden adlandırır, saatte bir çalışmasını sağlar ve bildirimlerini yalnızca ödeme ekibinin Slack kanalına gönderir.

Gereken anahtar erişimi: Yönetme

Parametreler

Parametreler: PATCH /tests/{id}
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric id or tst_… id)EvetTest: sayısal kimliği ya da uygulamadaki herkese açık tst_… kimliği.tst_7k2m9q4xh3vd
İstek gövdesi: PATCH /tests/{id}
AdTürZorunluAçıklamaÖrnek
namestring, 1–100 charactersHayırTestin uygulamada gösterilen adı: satır sonu içermeyen 1–100 karakter."Checkout page (EU)"
urlstring (public http:// or https:// URL)HayırTestin kontrol ettiği sayfa veya adres: eksiksiz, herkese açık bir http:// ya da https:// URL'si.null
descriptionstring, ≤ 500 characters | nullHayırEn fazla 500 karakterlik bir not; null ya da boş bir dize onu boş bırakır.null
scheduleMinutes15 | 60 | 180 | 360 | 720 | 960 | 1440 | nullHayırİki zamanlanmış çalıştırma arasındaki dakika (60 = saatlik, 1440 = günlük) ya da yalnızca isteğe bağlı çalıştırmalar için null; hangi zamanlamaların sunulduğuna organizasyonun planı karar verir.60
enabledbooleanHayırfalse testi duraklatır, böylece zamanlanmış çalıştırma almaz; alanı göndermezseniz yeni test etkin olur.null
notificationRoutingNotificationRoutingHayırTestin hangi bildirim kanallarına bildirim göndereceği, kanal listesindeki kimliklerle; kanal seçmek bildirim kanallarını içeren bir plan gerektirir, tüm kanallar ise her zaman kullanılabilir.{"scope":"selected","channelIds":["12"]}

Örnek istek

İstek gövdesi: Testi güncelleJSON
{
  "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")}");

Örnek yanıt

Döndürür: Güncellenen Test nesnesi.

Durum: 200 OK

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Yanıt gövdesi: Testi güncelleJSON
{
  "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"
  }
}

Alabileceğiniz hatalar

  • forbidden 403 Anahtarın erişim düzeyi yetersiz: bir read anahtarı çalıştırma başlatmaya ya da manage erişimi olmayan bir anahtar testleri değiştirmeye çalıştı. Anahtarı oluşturan kişi test silemiyorsa da oluşur.
  • invalid_request 400 Bir yol, filtre veya limit geçersiz ya da JSON gövdesi okunamıyor, çok büyük veya geçersiz.
  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • plan_limit_reached 422 Organizasyonun planı buna izin vermiyor: test sınırına ulaşıldı, bu test türü plana dahil değil veya (artefakt indirmelerinde) çalıştırma kanıtları plana dahil değil.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Testi sil DELETE /tests/{id}

Testi çalıştırma geçmişiyle birlikte siler; bu işlem geri alınamaz. Oluşturanı sahip veya yönetici olan, manage erişimli bir anahtar gerekir; test sırada bekleyen veya çalışan bir çalıştırmaya sahipken API 409 run_in_progress döner ve hiçbir şeyi silmez. Örnek, tst_7k2m9q4xh3vd testini siler.

Gereken anahtar erişimi: Yönetme

Parametreler

Parametreler: DELETE /tests/{id}
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric id or tst_… id)EvetTest: sayısal kimliği ya da uygulamadaki herkese açık tst_… kimliği.tst_7k2m9q4xh3vd

Örnek istek

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})");

Örnek yanıt

Döndürür: Gövde yok: durum 204 No Content olur.

Durum: 204 No Content

Başlıklar: Cache-Control: no-store

Gövde yoktur. Test ve çalıştırmaları silindi; kimlikleri artık 404 not_found döner.

Alabileceğiniz hatalar

  • forbidden 403 Anahtarın erişim düzeyi yetersiz: bir read anahtarı çalıştırma başlatmaya ya da manage erişimi olmayan bir anahtar testleri değiştirmeye çalıştı. Anahtarı oluşturan kişi test silemiyorsa da oluşur.
  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • run_in_progress 409 Testin zaten devam eden bir çalıştırması var.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Bir testin çalıştırmalarını listele GET /tests/{id}/runs

Bir testin çalıştırmalarını en yeniden başlayarak sayfa sayfa listeler. read erişimi gerekir. Örnek, sayfa başına iki çalıştırma ister; sayfa dolu olduğu için next bir sonraki sayfanın yolunu içerir.

Gereken anahtar erişimi: Okuma

Parametreler

Parametreler: GET /tests/{id}/runs
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric id or tst_… id)EvetTest: sayısal kimliği ya da uygulamadaki herkese açık tst_… kimliği.tst_7k2m9q4xh3vd
limitSorgu dizesiinteger, 1–50, default 20HayırBir sayfadaki çalıştırma sayısı: 1 ile 50 arasında bir tam sayı; belirtilmezse bir sayfada 20 çalıştırma bulunur.2
beforeSorgu dizesistring (run id)HayırYalnızca bu çalıştırma kimliğinden daha eski çalıştırmaları döndürür; genellikle bu değeri kendiniz vermek yerine next bağlantısını izlersiniz.4790

Örnek istek

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")));
}

Örnek yanıt

Döndürür: items (Run nesneleri) ve next (bir sonraki sayfanın yolu ya da son sayfada null) alanlarını içeren bir nesne.

Durum: 200 OK

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Yanıt gövdesi: Bir testin çalıştırmalarını listeleJSON
{
  "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"
}

Alabileceğiniz hatalar

  • invalid_request 400 Bir yol, filtre veya limit geçersiz ya da JSON gövdesi okunamıyor, çok büyük veya geçersiz.
  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Çalıştırma başlat POST /tests/{id}/runs

Testin bir çalıştırmasını trigger değeri api olarak kuyruğa alır ve sonucu beklemeden hemen 202 Accepted yanıtı verir; çalıştırma, kuruluşun saatlik 30 elle ve API ile başlatılan çalıştırma hakkından düşülür. run erişimli bir anahtar gerekir; gövde göndermeyin (16 KiB'a kadar bir JSON gövdesi kabul edilir ve yok sayılır). Örnek, 4821 numaralı çalıştırmayı kuyruğa alır; Location başlığı bu çalıştırmayı gösterir.

Gereken anahtar erişimi: Çalıştırma

Parametreler

Parametreler: POST /tests/{id}/runs
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric id or tst_… id)EvetTest: sayısal kimliği ya da uygulamadaki herkese açık tst_… kimliği.tst_7k2m9q4xh3vd

Örnek istek

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.");

Örnek yanıt

Döndürür: Kuyruğa alınan çalıştırmanın Run nesnesi (status değeri queued).

Durum: 202 Accepted

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store Location: /api/v1/runs/4821

Çalıştırma kuyrukta, henüz bitmedi: status değeri passed, failed ya da error olana kadar GET /runs/{id} yolunu (Location başlığı) 10 saniyede bir okuyun.

Yanıt gövdesi: Çalıştırma başlatJSON
{
  "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"
  }
}

Alabileceğiniz hatalar

  • forbidden 403 Anahtarın erişim düzeyi yetersiz: bir read anahtarı çalıştırma başlatmaya ya da manage erişimi olmayan bir anahtar testleri değiştirmeye çalıştı. Anahtarı oluşturan kişi test silemiyorsa da oluşur.
  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • run_in_progress 409 Testin zaten devam eden bir çalıştırması var.
  • run_limit_reached 429 Organizasyon saatlik çalıştırma bütçesini ya da planının günlük veya aylık çalıştırma kotasını doldurdu; Retry-After ne zaman yeniden denenebileceğini söyler.
  • kind_unsupported 422 Bu sunucu testin türünü şu anda çalıştıramıyor.
  • plan_limit_reached 422 Organizasyonun planı buna izin vermiyor: test sınırına ulaşıldı, bu test türü plana dahil değil veya (artefakt indirmelerinde) çalıştırma kanıtları plana dahil değil.
  • invalid_request 400 Bir yol, filtre veya limit geçersiz ya da JSON gövdesi okunamıyor, çok büyük veya geçersiz.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.