API Reference (v2)Units
Get unit
Retrieve a single unit by its serial number. Returns comprehensive unit data including part information, parent/child relationships, and test run history.
Access
| API Key | Access Level | Description |
|---|---|---|
| User | Full | Users can read units |
| Station | Full | Stations can read units |
Endpoint
GET
/v2/units/{serial_number}AuthorizationBearer <token>
API key for authentication. Use format: Bearer YOUR_API_KEY
In: header
Path Parameters
serial_numberstring
Serial number of the unit to retrieve.
Response Body
from tofupilot.v2 import TofuPilot
# Initialize the TofuPilot client
client = TofuPilot()
# Execute the operation
result = client.units.get(
serial_number="string"
)
# Handle response
print(result){
"id": "550e8400-e29b-41d4-a716-446655440000",
"serial_number": "SN-2024-001234",
"created_at": "2024-01-15T10:30:00Z",
"created_by_user": {
"id": "550e8400-e29b-41d4-a716-446655440001",
"name": "John Doe"
},
"created_by_station": {
"id": "550e8400-e29b-41d4-a716-446655440002",
"name": "Assembly Station 01"
},
"part": {
"id": "550e8400-e29b-41d4-a716-446655440007",
"number": "PCB-MAIN-001",
"name": "Main Control Board",
"revision": {
"id": "550e8400-e29b-41d4-a716-446655440006",
"number": "REV-A"
}
},
"batch": {
"id": "550e8400-e29b-41d4-a716-446655440005",
"number": "BATCH-2024-Q1-001"
},
"parent": {
"id": "550e8400-e29b-41d4-a716-446655440004",
"serial_number": "SN-2024-001234",
"part": {
"id": "550e8400-e29b-41d4-a716-446655440003",
"number": "PCB-MAIN-V2",
"name": "Main PCB Assembly",
"revision": {
"id": "550e8400-e29b-41d4-a716-446655440002",
"number": "Rev-A"
}
}
},
"children": [
{
"id": "550e8400-e29b-41d4-a716-446655440005",
"serial_number": "SN-2024-001235",
"part": {
"id": "550e8400-e29b-41d4-a716-446655440006",
"number": "PCB-SUB-V1",
"name": "Sub Assembly PCB",
"revision": {
"id": "550e8400-e29b-41d4-a716-446655440007",
"number": "Rev-B"
}
}
}
],
"created_during": {
"id": "550e8400-e29b-41d4-a716-446655440009",
"created_at": "2024-01-15T10:20:00Z",
"started_at": "2024-01-15T10:25:00Z",
"ended_at": "2024-01-15T10:30:00Z",
"duration": "PT5M",
"outcome": "PASS",
"procedure": {
"id": "550e8400-e29b-41d4-a716-446655440011",
"name": "PCB Assembly Procedure"
}
},
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440011",
"name": "calibration-cert.pdf",
"size": 1048576,
"content_type": "application/pdf",
"download_url": "https://s3.amazonaws.com/bucket/file?X-Amz-Algorithm=..."
}
]
}{
"message": "Bad request",
"code": "BAD_REQUEST",
"issues": []
}{
"message": "Unauthorized",
"code": "UNAUTHORIZED",
"issues": []
}{
"message": "Not found",
"code": "NOT_FOUND",
"issues": []
}{
"message": "Internal server error",
"code": "INTERNAL_SERVER_ERROR",
"issues": []
}How is this guide?
Attach file to unit POST
Create an attachment linked to a unit and get a temporary pre-signed URL. Upload the file to the URL with a PUT request to complete the attachment.
List and filter units GET
Retrieve a paginated list of units with filtering by serial number, part number, and batch. Uses cursor-based pagination for efficient large dataset traversal.