Complete documentation of all data models used in the LISA REST API.
Represents a user in the LISA system.
interface User {
Email: string; // User's email address
Flagged: boolean; // Whether user is flagged
Inactive: boolean; // Whether user is inactive
Language: string; // User's preferred language
Name: string; // User's display name
Phone: string; // User's phone number
Uid: string; // Unique user identifier
FCMTokens?: UserPhone[]; // FCM tokens for push notifications
RequestDeletion?: boolean; // Whether user requested account deletion
betaUser?: boolean; // Beta user flag
WedaIntegration?: boolean; // Weda integration flag
integrators?: string[]; // Array of integratorUIDs that can access this user's data
}
Represents a user's FCM token for push notifications.
interface UserPhone {
CustomName: string; // Custom name for the device
Name: string; // Device name
t: number; // Timestamp when token was added
Token: string; // FCM token string
Rank?: number; // 1=Admin, 2=Manager, 3=Worker
Email: string; // Associated email address
}
Represents an integrator with access permissions.
interface UserIntegrator {
uid: string; // Integrator UID
email: string; // Integrator email
name: string; // Integrator name
integrators: string[]; // Array of integratorUIDs this user has access to
createdAt: string; // Creation timestamp
updatedAt: string; // Last update timestamp
isActive: boolean; // Whether integrator is active
permissions?: { // Optional permission object
canRead: boolean;
canWrite: boolean;
canDelete: boolean;
};
}
Represents a livestock animal in the system.
interface Animal {
Active: boolean; // Whether animal is active
Battery: number; // Battery level (0-100)
CurrentActivity: number; // Current activity level
CurrentTemperature: number; // Latest ear-pinna temperature reading (°C). NOT core body temp.
ReferenceTemperature?: number | null; // Rolling 7-day per-animal median of CurrentTemperature.
// null while tag is calibrating (<7d of data or <100 valid samples).
// Updated daily. Use (CurrentTemperature - ReferenceTemperature)
// as the meaningful delta for heat/fever signals.
ReferenceTemperatureUpdatedAt?: number; // ms since epoch of last baseline refresh.
ReferenceTemperatureWindowDays?: number; // Window length in days (currently 7).
EartagStart: number; // Eartag start number
Father: string; // Father's identifier
Group: string; // Group assignment
ID: string; // Unique animal identifier
MAC: string; // MAC address of tracking device
Mother: string; // Mother's identifier
Node: string; // Node assignment
NodeWeight: number; // Weight at node
Sex: 'male' | 'female'; // Animal sex
SignalStrength: number; // Signal strength of tracking device
Uid: string; // Owner's user ID
WatchdogWeight: number; // Watchdog weight
t: number; // Timestamp
Suspicious: boolean; // Whether animal shows suspicious behavior
HealthScore?: number; // Health score (0-100)
Diagnosed?: { // Optional diagnosis information
Description: string;
Diagnose: string;
t: number;
};
}
The CurrentTemperature field on Animal is the latest ear-pinna
temperature read from the BioTag sensor, NOT a core body temperature.
Absolute pinna values shift with ambient conditions (ventilation, sun,
tag fit), so the meaningful clinical signal is the deviation from the
animal's own baseline:
delta = CurrentTemperature - ReferenceTemperature
ReferenceTemperature is a rolling 7-day median of that animal's
pinna readings (column c in BigQuery), refreshed once per day. It is
computed in biocv-production.animals.<mac> and written back to the
Firestore animal document, so the same value powers every endpoint that
exposes Animal.
Calibration window. ReferenceTemperature is null (or absent)
while a tag has fewer than 7 days of data or fewer than 100 valid
samples in the window. Render an honest "calibrating" fallback in the
UI rather than substituting a default value.
Suggested deviation bands (starting point, tune per herd):
| Band | delta (°C) | Interpretation |
|---|---|---|
| Green | < 0.3 | Within normal variation |
| Yellow | 0.3 – 0.6 | Watch |
| Red | > 0.6 | Investigate (heat / fever) |
Samples outside [25.0, 42.0] °C are dropped from the baseline as
sensor noise (tag detached, floor reading, etc.).
Represents an event related to an animal.
interface AnimalEvent {
EventType: string; // Type of event
Group: string; // Group assignment
MAC: string; // Animal's MAC address
Scale: string; // Scale identifier
Value: number; // Event value
t: number; // Timestamp
}
Represents a location sample for an animal from BigQuery.
interface AnimalLocationReading {
t: number; // Timestamp (milliseconds since epoch)
rssi: number; // Signal strength in dBm
nodeuid: string; // Node UID that detected the animal
}
Represents a raw BioTag sensor sample for an animal from BigQuery.
interface AnimalSensorReading {
t: number; // Timestamp (milliseconds since epoch)
c: number; // Temperature in Celsius
x: number; // Acceleration X-axis (g-force)
y: number; // Acceleration Y-axis (g-force)
z: number; // Acceleration Z-axis (g-force)
}
Represents raw BioTag sensor analytics over a given time window.
interface AnimalSensorAnalytics {
averageTemperature: number; // Average temperature over time window
averageAccelerationMagnitude: number; // Average acceleration magnitude
temperatureRange: { // Temperature range
min: number;
max: number;
};
accelerationMagnitudeRange: { // Acceleration magnitude range
min: number;
max: number;
};
dataPointsCount: number; // Number of samples analyzed
timeRange: { // Time window
start: number; // Start timestamp (ms since epoch)
end: number; // End timestamp (ms since epoch)
};
}
Represents a medical treatment record.
interface Treatment {
Archived: boolean; // Whether treatment is archived
Comment: string; // Treatment comments
CustomName: string; // Custom treatment name
Diagnose: string; // Diagnosis
ID: string; // Unique treatment identifier (auto-generated)
Mac: string; // Animal's MAC address
Medicine: string; // Medicine used
PhoneHistory: UserPhone[]; // Phone history for notifications
StartDate: string; // Start date (string format)
StartDateSeconds: number; // Start date (Unix timestamp)
TreatmentAmount: number; // Amount of treatment
TreatmentCount: number; // Number of treatments
TreatmentInterval: number; // Treatment interval in hours
Dosis?: number; // Optional dosage
Group?: string; // Optional group assignment
t: number; // Timestamp (auto-generated)
Validated?: boolean; // Whether treatment is validated
}
Validation Rules for POST /users/:userId/treatments:
Mac, Medicine, Diagnose, CustomName, Comment, TreatmentAmount, TreatmentCount, TreatmentInterval, StartDate, StartDateSeconds, Archived, PhoneHistoryID (timestamp-based), t (current timestamp)Dosis, Group, ValidatedTreatmentAmount, TreatmentCount, TreatmentInterval, StartDateSeconds must be non-negative numbersArchived must be booleanPhoneHistory must be an arrayRepresents an artificial insemination record.
interface Insemination {
Archived: boolean; // Whether insemination record is archived
Boar: string; // Boar identification
GeneticLine: string; // Genetic line information
ID: string; // Unique insemination identifier (auto-generated)
MAC: string; // Animal's MAC address
Occupied: boolean; // Whether animal is occupied
StartDate: string; // Insemination date (string format)
StartTime: string; // Insemination time (string format)
Tubes: number; // Number of tubes used
Uid: string; // Owner's user ID
t: number; // Timestamp (auto-generated)
}
Validation Rules for POST /users/:userId/inseminations:
MAC, Boar, GeneticLine, Tubes, StartDate, StartTime, Archived, Occupied, UidID (timestamp-based), t (current timestamp)Tubes must be a non-negative numberArchived and Occupied must be booleansRepresents a birth event record.
interface Birth {
Archived: boolean; // Whether birth record is archived
Comment?: string; // Birth comments (optional)
Dead: number; // Number of dead piglets
ID: string; // Unique birth identifier (auto-generated)
Living: number; // Number of living piglets
MAC: string; // Mother's MAC address
StartDate: string; // Birth date (string format)
StartTime?: string; // Birth time (string format, optional)
Uid: string; // Owner's user ID
t: number; // Timestamp (auto-generated)
// Extended fields (optional)
Mummified?: number; // Number of mummified piglets
Weaned?: number; // Number of weaned piglets
Parity?: number; // Parity number
Assisted?: boolean; // Whether birth was assisted
FarrowingDuration?: number; // Farrowing duration in minutes
Complications?: string; // Complications description
AverageLitterWeight?: number; // Average weight of piglets (kg)
}
Validation Rules for POST /users/:userId/births:
MAC, Living, Dead, StartDate, StartTime, Comment, Archived, UidID (timestamp-based), t (current timestamp)Living and Dead must be non-negative numbersArchived must be booleanRepresents aggregated birth statistics.
interface BirthStatistics {
totalBirths: number; // Total number of births
totalLiving: number; // Total living piglets
totalDead: number; // Total dead piglets
averageLitterSize: number; // Average litter size
survivalRate: number; // Survival rate percentage
}
Represents an insemination event record.
interface Insemination {
Archived: boolean; // Whether insemination record is archived
Boar: string; // Boar identifier (required)
GeneticLine?: string; // Genetic line identifier (optional)
ID: string; // Unique insemination identifier
MAC: string; // Animal's MAC address
Occupied: boolean; // Whether animal is occupied
StartDate: string; // Insemination date (string format)
StartTime?: string; // Insemination time (string format, optional)
Tubes?: number; // Number of tubes used (optional)
Uid?: string; // Owner's user ID (optional)
t: number; // Timestamp
// Extended fields (optional)
serviceOrder?: number; // Service order number (1, 2, 3, etc.)
serviceType?: 'AI' | 'natural'; // Type of service
semenSource?: string; // Source of semen
HeatDetectionDate?: string; // Date heat was detected
ServiceNumber?: number; // Service number in cycle
Parity?: number; // Parity number
Technician?: string; // Technician who performed insemination
SemenBatch?: string; // Semen batch identifier
ExpectedFarrowingDate?: string; // Expected farrowing date
PregnancyCheckDate?: string; // Date of pregnancy check
ReturnToEstrusDate?: string; // Date of return to estrus (if applicable)
BreedingGroup?: string; // Breeding group identifier
ScanningResult?: { // Scanning result (optional)
Confirmed: boolean;
ScanningDate: string;
Notes?: string;
};
}
Represents a general event record for an animal.
interface GeneralEvent {
Archived?: boolean; // Whether event is archived (optional)
MAC: string; // Animal's MAC address
Uid: string; // Owner's user ID
t: number; // Timestamp
ID: string; // Unique event identifier
Diagnose: string; // Diagnosis or event type
Description: string; // Event description
Token?: string; // Associated token (optional)
Comment?: string; // Additional comments (optional, alternative to Description)
}
Represents a pregnancy check record.
interface PregnancyCheck {
t: number | string; // Timestamp (can be number or string)
ID: string; // Unique check identifier
MAC: string; // Animal's MAC address
checkDate: string; // Date of pregnancy check (required)
checkNumber?: number; // Check number in sequence (default: 1)
result: 'pregnant' | 'open' | 'recheck'; // Check result (required)
method?: string; // Method used (default: 'ultrasound')
ServiceTimestamp?: number; // Timestamp of related service
notes?: string; // Additional notes
technician?: string; // Technician who performed check
Archived?: boolean; // Whether check is archived (default: false)
}
Represents a return to estrus event record.
interface ReturnToEstrus {
t: number | string; // Timestamp (can be number or string)
ID: string; // Unique event identifier
MAC: string; // Animal's MAC address
returnDate: string; // Date of return to estrus (required)
returnType: 'regular' | 'irregular'; // Type of return (required)
daysSinceService: number; // Days since last service (required, min: 0)
PreviousServiceTimestamp?: number; // Timestamp of previous service
reasonCode?: string; // Reason code for return
Archived?: boolean; // Whether event is archived (default: false)
}
Represents a weaning record.
interface Weaning {
t: number | string; // Timestamp (can be number or string)
ID: string; // Unique weaning identifier
MAC: string; // Animal's MAC address
weaningDate: string; // Date of weaning (required)
countWeaned: number; // Number of piglets weaned (required, min: 0)
BirthTimestamp?: number; // Timestamp of related birth
weaningAge?: number; // Age at weaning in days (min: 0)
fosterIn?: number; // Number fostered in (min: 0)
fosterOut?: number; // Number fostered out (min: 0)
weaningWeight?: number; // Average weaning weight (min: 0)
Archived?: boolean; // Whether weaning is archived (default: false)
}
Represents an animal movement record between stages or locations.
interface AnimalMovement {
t: number | string; // Timestamp (can be number or string)
ID: string; // Unique movement identifier
MAC: string; // Animal's MAC address
movementDate: string; // Date of movement (required)
fromStage: 'gilt-pool' | 'bred' | 'gestation' | 'farrowing' | 'lactation' | 'weaned' | 'cull'; // Source stage (required)
toStage: 'gilt-pool' | 'bred' | 'gestation' | 'farrowing' | 'lactation' | 'weaned' | 'cull'; // Destination stage (required)
fromLocation?: string; // Source location (optional)
toLocation?: string; // Destination location (optional)
Archived?: boolean; // Whether movement is archived (default: false)
}
Represents a LitterGuard IoT device.
interface LitterGuardData {
MAC: string; // Device MAC address (e.g., "AA:BB:CC:DD:EE:FF")
Name: string; // User-defined device name
LastSeen: any; // FirestoreTimestamp of last data received
Active: boolean; // Device connectivity status
CurrentTemperature: number; // Latest temperature reading (°C)
}
Represents a single sensor reading from a LitterGuard device.
interface SensorReading {
t: number; // Unix timestamp (seconds)
c: number; // Temperature in Celsius
x: number; // Acceleration X-axis (g-force)
y: number; // Acceleration Y-axis (g-force)
z: number; // Acceleration Z-axis (g-force)
}
Represents analytics data for a LitterGuard device.
interface LitterGuardAnalytics {
averageTemperature: number; // Average temperature over time range
averageAccelerationMagnitude: number; // Average acceleration magnitude
temperatureRange: { // Temperature range
min: number;
max: number;
};
activityLevel: 'low' | 'normal' | 'high'; // Activity level classification
unusualActivityDetected: boolean; // Whether unusual activity was detected
dataPointsCount: number; // Number of data points analyzed
timeRange: { // Time range of analysis
start: number; // Start timestamp
end: number; // End timestamp
};
}
Represents summary statistics for all LitterGuard devices.
interface LitterGuardSummary {
totalDevices: number; // Total number of devices
activeDevices: number; // Number of active devices
inactiveDevices: number; // Number of inactive devices
averageTemperature: number; // Average temperature across all devices
devicesWithUnusualActivity: number; // Number of devices with unusual activity
lastDataReceived: number; // Timestamp of last data received
}
Represents an AI prediction result.
interface AIPrediction {
timestamp: string; // When the prediction was made
classificationType: string; // Type of prediction (heat, birth, lameness)
userId: string; // User ID
animal: { // Animal information at time of prediction
id: string; // Animal ID
mac: string; // Animal MAC address
name: string; // Animal name
group: string; // Animal group
weight: number; // Animal weight
userId: string; // Owner user ID
};
results: PredictionResult[]; // Array of prediction results
}
Represents a single prediction result within an AI prediction.
interface PredictionResult {
timestamp: string; // Timestamp of the prediction window
probability: number; // Confidence score (0.0-1.0)
}
Query parameters for AI prediction endpoints.
interface PredictionQueryParams extends QueryParams {
classificationType?: 'heat' | 'birth' | 'lameness'; // Filter by prediction type
startDate?: string; // Start date filter (ISO 8601 format)
endDate?: string; // End date filter (ISO 8601 format)
minProbability?: number; // Minimum probability threshold (0.0-1.0)
maxProbability?: number; // Maximum probability threshold (0.0-1.0)
}
Base response format for all API endpoints.
interface ApiResponse<T = any> {
success: boolean; // Whether the request was successful
data?: T; // Response data (type varies by endpoint)
error?: string; // Error message (if success is false)
message?: string; // Success message (if success is true)
timestamp: string; // Response timestamp (ISO 8601 format)
}
Response format for paginated endpoints.
interface PaginatedResponse<T = any> extends ApiResponse<T[]> {
pagination: { // Pagination information
page: number; // Current page number
limit: number; // Items per page
total: number; // Total number of items
totalPages: number; // Total number of pages
};
}
Base query parameters for most endpoints.
interface QueryParams {
page?: number; // Page number (default: 1)
limit?: number; // Items per page (default: 10, max: 100)
sortBy?: string; // Field to sort by (default: 't')
sortOrder?: 'asc' | 'desc'; // Sort order (default: 'desc')
filter?: Record<string, any>; // Filter object with field-value pairs
}
Query parameters for the raw animal time-series endpoints (/locations and /sensordata).
interface AnimalLocationQueryParams {
startTime?: number; // Start time filter (milliseconds since epoch)
endTime?: number; // End time filter (milliseconds since epoch)
limit?: number; // Maximum number of rows (default: 100, max: 10000)
sortOrder?: 'asc' | 'desc'; // Sort order (default: 'desc')
}
Specialized query parameters for LitterGuard endpoints.
interface LitterGuardQueryParams extends QueryParams {
active?: boolean; // Filter by device status
mac?: string; // Filter by MAC address
name?: string; // Filter by device name
startTime?: number; // Start time filter (Unix timestamp)
endTime?: number; // End time filter (Unix timestamp)
timeRange?: '1h' | '6h' | '24h' | '7d' | '30d'; // Predefined time ranges
limit?: number; // Maximum number of readings
}
JWT token payload structure.
interface TokenPayload {
integratorUID: string; // Integrator UID
type: 'access' | 'refresh'; // Token type
iat: number; // Issued at timestamp
exp: number; // Expiration timestamp
jti?: string; // JWT ID for token tracking
}
Request format for token generation.
interface TokenRequest {
integratorUID: string; // Integrator UID
expiresIn?: number; // Token expiration in seconds (300-86400, default: 3600)
refreshToken?: boolean; // Whether to include refresh token (default: false)
}
Response format for token generation and refresh.
interface TokenResponse {
accessToken: string; // JWT access token
refreshToken?: string; // JWT refresh token (optional)
expiresAt: number; // Token expiration timestamp
tokenType: 'Bearer'; // Token type
integratorUID: string; // Integrator UID
}
Represents an API usage record for tracking.
interface UsageRecord {
timestamp: string; // Request timestamp
endpoint: string; // API endpoint called
method: string; // HTTP method
integratorUID: string; // Integrator UID
responseCode: number; // HTTP response code
responseTime: number; // Response time in milliseconds
dataSize?: number; // Response data size in bytes
userAgent?: string; // User agent string
ipAddress?: string; // Client IP address
}
Most data models have required fields that must be present:
Next: Error Handling - Complete error codes and handling guide
This page is generated from the official LiSA API wiki. If something is wrong or missing, contact us and we will correct it at the source.
Wiki version 158c1a5 · 7/28/2026