TofuPilotTofuPilot
REST API v2.0 (Preview)/Runs

Create test run

Create a new test run that links to a procedure and either links to an existing unit or automatically creates one. Optionally include metadata, phases, measurements, and logs to capture comprehensive test execution data.

API v2 Preview

This API version might be subject to breaking changes as we stabilize until release planned for Aug 2025.

Access

API KeyAccess LevelDescription
UserFullUsers can create runs for any procedure of their organization
StationLimitedStations can only create runs for procedures they were previously linked to from the app

Endpoint

POST
/v2/runs
AuthorizationBearer <token>

In: header

outcomestring

Overall test result. Use PASS when test succeeds, FAIL when test fails but script execution completed successfully, ERROR when script execution fails, TIMEOUT when test exceeds time limit, ABORTED for manual script interruption.

Value in"RUNNING" | "PASS" | "FAIL" | "ERROR" | "TIMEOUT" | "ABORTED"
procedure_idstring

Unique identifier of the procedure for the current run. The procedure needs to be created manually before in the app. The run will be linked to the procedure at creation.

serial_numberstring

Unique serial number of the unit under test. The unit will be automatically linked to the run if already exists or automatically created and linked to the run if not found. You will need to specify a part number if no automatic serial number parsing has been configured in organization settings of app.

started_atstring

ISO 8601 timestamp when the test run began execution. This timestamp will be used to track when the test execution started and for historical analysis of test runs. A separate created_at timestamp is stored internally server side to track upload date.

Formatdate-time
ended_atstring

ISO 8601 timestamp when the test run finished execution.

Formatdate-time
part_number?string

Component part number for the unit. The part number will be automatically created if not found, or unit will be linked to one found. If no revision is specified will create and link to default revision. If serial number parsing has been configured on app, the part number will be extracted from the serial number.

revision?string

Hardware revision identifier for the unit. The revision will be automatically created if not found, or unit will be linked to an existing one. If no revision is specified, the unit will be linked to the default revision of the part number.

batch_number?string

Production batch identifier for grouping units manufactured together. The batch will be automatically created if not found, or unit will be linked to an existing one. If no batch number is specified, the unit will not be linked to any batch.

procedure_version?string | null

Specific version of the test procedure used for the run. The procedure version will be automatically created if not found, or run will be linked to an existing one. If no procedure version is specified, the run will not be linked to any specific version.

docstring?string

Additional notes or documentation about this test run.

phases?array<object>

Array of test phases with measurements and results. Each phase represents a distinct stage of the test execution with timing information, outcome status, and optional measurements. Phases will be automatically created and linked to the run. If no phases are specified, the run will be created without phase-level organization of test data.

logs?array<object>

Array of log messages generated during the test execution. Each log entry captures events, errors, and diagnostic information with severity levels and source code references. Logs will be automatically created and linked to the run. If no logs are specified, the run will be created without log entries.

sub_units?array<object>

Array of sub-units that are part of this main unit. Each sub-unit must already exist and will be automatically linked as a sub-component of the main unit under test. If no sub-units are specified, the unit will be created without sub-unit relationships.

Response Body

from tofupilot import TofuPilotClient

client = TofuPilotClient()
result = client.create_run(
    outcome="PASS",
    procedure_id="FVT1",
    serial_number="SN-001234",
    started_at="2024-01-15T10:30:00Z",
    ended_at="2024-01-15T10:35:30Z"
)
print(result)
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}
{
  "code": "BAD_REQUEST",
  "message": "Part number is required but not provided and no automatic parsing is configured. Provide a part_number parameter or configure serial number parsing in organization settings.",
  "issues": []
}
{
  "code": "NOT_FOUND",
  "message": "Procedure with ID {procedureId} does not exist. Create the procedure first in the app.",
  "issues": []
}
{
  "code": "UNPROCESSABLE_CONTENT",
  "message": "Part number extraction failed for serial number {serialNumber}. Provide a part_number parameter explicitly or fix the regex pattern in organization settings.",
  "issues": []
}
{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error",
  "issues": []
}

How is this guide?