TofuPilotTofuPilot
v2 Reference (Preview)/Runs

Create run

Create a new test run linking to a procedure and unit. Unit identifiers are matched case-insensitively - existing entities are reused, new ones are created automatically.

API v2 Preview

The TofuPilot API v2.0 is currently in public preview and is subject to change as we stabilize until release (planned for Aug 2025).

Access

API KeyAccess LevelDescription
UserFullUsers can create runs for any procedure
StationLimitedStations can only create runs for procedures to which they are currently linked

Endpoint

POST/v2/runs
AuthorizationBearer <token>

API key for authentication. Use format: Bearer YOUR_API_KEY

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"PASS" | "FAIL" | "ERROR" | "TIMEOUT" | "ABORTED"
procedure_idstring

Procedure ID. Create the procedure in the app first, then find the auto-generated ID on the procedure page.

Formatuuid
procedure_version?string | null

Specific version of the test procedure used for the run. Matched case-insensitively. If none exist, a procedure with this procedure version will be created. If no procedure version is specified, the run will not be linked to any specific version.

Match^[a-zA-Z0-9_.:+-]+$
Length1 <= length <= 60
operated_by?string

Email address of the operator who executed the test run. The operator must exist as a user in the system. The run will be linked to this user to track who performed the test.

Formatemail
Lengthlength <= 254
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
serial_numberstring

Unique serial number of the unit under test. Matched case-insensitively. If no unit with this serial number exists, one will be created.

Match^[a-zA-Z0-9_.:+-]+$
Length1 <= length <= 60
part_number?string

Component part number for the unit. Matched case-insensitively. This field is required if the part number cannot be extracted from the serial number (as set in the settings). This field takes precedence over extraction from serial number. A component with the provided or extracted part number will be created if one does not exist.

Match^[a-zA-Z0-9_.:+-]+$
Length1 <= length <= 60
revision_number?string

Hardware revision identifier for the unit. Matched case-insensitively. If none exist, a revision with this number will be created. If no revision is specified, the unit will be linked to the default revision of the part number.

Match^[a-zA-Z0-9_.:+-]+$
Length1 <= length <= 60
batch_number?string

Production batch identifier for grouping units manufactured together. Matched case-insensitively. If none exist, a batch with this batch number will be created. If no batch number is specified, the unit will not be linked to any batch.

Match^[a-zA-Z0-9_.:+-]+$
Length1 <= length <= 60
sub_units?array<string>

Array of sub-unit serial numbers that are part of this main unit. Matched case-insensitively. Each sub-unit must already exist and will be 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.

docstring?string

Additional notes or documentation about this test run.

Lengthlength <= 50000
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. 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. If no logs are specified, the run will be created without log entries.

Response Body

from tofupilot.v2 import TofuPilot
from datetime import datetime, timedelta, timezone

# Initialize the TofuPilot client
client = TofuPilot()

# Execute the operation
result = client.runs.create(
    outcome="PASS",
    procedure_id="550e8400-e29b-41d4-a716-446655440000",
    started_at=datetime.now(timezone.utc) - timedelta(minutes=5),
    ended_at=datetime.now(timezone.utc),
    serial_number="SN-001234"
)

# Handle response
print(result)
{
  "id": "550e8400-e29b-41d4-a716-446655440000"
}
{
  "code": "BAD_REQUEST",
  "message": "Procedure name is required",
  "issues": []
}
{
  "code": "FORBIDDEN",
  "message": "Part creation failed.; Revision creation failed.; Batch creation failed.; Unit creation failed.; Version creation failed.; Plan upgrade required.; Monthly limit exceeded.",
  "issues": []
}
{
  "code": "NOT_FOUND",
  "message": "Procedure not found: {id}",
  "issues": []
}
{
  "code": "UNPROCESSABLE_CONTENT",
  "message": "Part number extraction failed for serial number {serial_number}. 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?