TofuPilotTofuPilot
API Reference (v2)Units

Create unit

Create a new unit with a serial number and link it to a part revision. Units represent individual hardware items tracked for manufacturing traceability.

Access

API KeyAccess LevelDescription
UserFullUsers can create units
StationFullStations can create units

Endpoint

POST/v2/units
AuthorizationBearer <token>

API key for authentication. Use format: Bearer YOUR_API_KEY

In: header

serial_numberstring

Unique serial number identifier for the unit. Must be unique within the organization.

Match^[a-zA-Z0-9_-]+$
Length1 <= length <= 60
part_numberstring

Component part number that defines what type of unit this is. If the part does not exist, it will be created.

Match^[a-zA-Z0-9_-]+$
Length1 <= length <= 60
revision_numberstring

Hardware revision identifier for the specific version of the part. If the revision does not exist, it will be created.

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

Response Body

from tofupilot.v2 import TofuPilot

# Initialize the TofuPilot client
client = TofuPilot()

# Execute the operation
result = client.units.create(
    serial_number="SN-001234",
    part_number="PCB-V1.2",
    revision_number="REV-1.0"
)

# Handle response
print(result)
{
  "id": "550e8400-e29b-41d4-a716-446655440000"
}
{
  "message": "Unauthorized",
  "code": "UNAUTHORIZED",
  "issues": []
}
{
  "message": "Not found",
  "code": "NOT_FOUND",
  "issues": []
}
{
  "message": "Conflict",
  "code": "CONFLICT",
  "issues": []
}
{
  "message": "Internal server error",
  "code": "INTERNAL_SERVER_ERROR",
  "issues": []
}

How is this guide?