Optisway home
Documentation menu

REST API reference: Projects

A project groups the tests of one website or app in Optisway, with its address and description. A key scoped to one project sees only that project; a key without a scope sees every project of the organisation.

Project

A project with its number of tests and its most recent run.

Fields: Project
FieldTypeDescription
idstringThe project's id, a decimal string.
namestringThe project's name as shown in the app.
urlstringThe website address the project covers.
descriptionstringThe project's description; an empty string when none was written.
testCountintegerHow many tests the project holds.
lastRunRunSummary | nullThe newest run of any test in the project as a RunSummary, or null before the first run.
createdAtISO 8601 stringWhen the project was created (UTC).
updatedAtISO 8601 stringWhen the project was last changed (UTC).
links.selfstringThe path of this project (GET /projects/{id}).
links.testsstringThe path that lists this project's tests (GET /tests?project={id}).
Example: ProjectJSON
{
  "id": "42",
  "name": "Acme Shop",
  "url": "https://shop.example.com/",
  "description": "Storefront, checkout and account pages.",
  "testCount": 6,
  "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"
  },
  "createdAt": "2026-09-01T10:00:00.000Z",
  "updatedAt": "2026-10-12T08:41:00.000Z",
  "links": {
    "self": "/api/v1/projects/42",
    "tests": "/api/v1/tests?project=42"
  }
}

List projects GET /projects

Lists the projects of the key's organisation; a project-scoped key sees only its own project. Needs read access, and the list is not paged. The example shows an organisation with one project, 42.

Needs a key with access: Read

Parameters

This endpoint takes no parameters.

Example request

curl --fail-with-body -sS "https://optisway.com/api/v1/projects" \
  -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/projects";
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/projects",
    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/projects")
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/projects");
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/projects";
    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/projects"
	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/projects";
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")));
}

Example response

Returns: An object whose items array holds Project objects.

Status: 200 OK

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

Response body: List projectsJSON
{
  "items": [
    {
      "id": "42",
      "name": "Acme Shop",
      "url": "https://shop.example.com/",
      "description": "Storefront, checkout and account pages.",
      "testCount": 6,
      "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"
      },
      "createdAt": "2026-09-01T10:00:00.000Z",
      "updatedAt": "2026-10-12T08:41:00.000Z",
      "links": {
        "self": "/api/v1/projects/42",
        "tests": "/api/v1/tests?project=42"
      }
    }
  ]
}

Errors you can get

  • unauthorized 401 The key is missing, malformed, unknown, revoked or expired, or its creator is no longer a member.
  • rate_limited 429 The key sent too many requests; wait the seconds in Retry-After.
  • unavailable 503 A temporary problem on our side; try again later.

Read a project GET /projects/{id}

Reads one project by its numeric id. Needs read access; a project outside the key's scope answers 404 not_found, exactly like one that does not exist. The example reads project 42, whose lastRun is the failed run 4821.

Needs a key with access: Read

Parameters

Parameters: GET /projects/{id}
NameInTypeRequiredDescriptionExample
idPathstring (numeric project id)YesThe numeric id of the project, as returned in Project.id.42

Example request

curl --fail-with-body -sS "https://optisway.com/api/v1/projects/42" \
  -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/projects/42";
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/projects/42",
    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/projects/42")
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/projects/42");
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/projects/42";
    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/projects/42"
	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/projects/42";
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")}");

Example response

Returns: A Project object.

Status: 200 OK

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

Response body: Read a projectJSON
{
  "id": "42",
  "name": "Acme Shop",
  "url": "https://shop.example.com/",
  "description": "Storefront, checkout and account pages.",
  "testCount": 6,
  "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"
  },
  "createdAt": "2026-09-01T10:00:00.000Z",
  "updatedAt": "2026-10-12T08:41:00.000Z",
  "links": {
    "self": "/api/v1/projects/42",
    "tests": "/api/v1/tests?project=42"
  }
}

Errors you can get

  • not_found 404 The resource does not exist or is outside the key’s scope.
  • unauthorized 401 The key is missing, malformed, unknown, revoked or expired, or its creator is no longer a member.
  • rate_limited 429 The key sent too many requests; wait the seconds in Retry-After.
  • unavailable 503 A temporary problem on our side; try again later.