{"openapi":"3.1.0","components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"MetricsResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Metric"}},"message":{"type":"string","description":"Response message"},"meta":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"request_id":{"type":"string","description":"Request ID for tracking"},"query_duration_ms":{"type":"number"}}}},"required":["data","message"],"description":"Response containing metrics data"},"Metric":{"type":"object","properties":{"station_id":{"type":"string"},"slot":{"type":["string","null"]},"unit_serial":{"type":"string"},"time_created":{"type":"string"},"tz":{"type":["string","null"]},"mode":{"type":["string","null"]},"tags":{"type":"array","items":{"type":"string"}},"name":{"type":"string"},"value":{"type":"string"},"unit":{"type":"string"},"type":{"type":["string","null"]},"limit_upper":{"type":["string","null"]},"limit_lower":{"type":["string","null"]}},"required":["station_id","slot","unit_serial","time_created","tz","mode","tags","name","value","unit","type","limit_upper","limit_lower"],"description":"Metric data point from a station"},"UnitsResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Unit"}},"message":{"type":"string","description":"Response message"},"meta":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"request_id":{"type":"string","description":"Request ID for tracking"},"query_duration_ms":{"type":"number"}}}},"required":["data","message"],"description":"Response containing units data"},"Unit":{"type":"object","properties":{"station_id":{"type":"string"},"slot":{"type":["string","null"]},"unit_serial":{"type":"string"},"time_created":{"type":"string"},"tz":{"type":["string","null"]},"mode":{"type":["string","null"]},"tags":{"type":"array","items":{"type":"string"}},"unit_type":{"type":["string","null"]},"direction":{"type":"string","enum":["input","output"]},"result":{"type":["string","null"]},"metadata":{"type":"null"}},"required":["station_id","slot","unit_serial","time_created","tz","mode","tags","unit_type","direction","result"],"description":"Unit data point from a station"},"StationSummaryResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/StationSummary"},"message":{"type":"string","description":"Response message"},"meta":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"request_id":{"type":"string","description":"Request ID for tracking"},"query_duration_ms":{"type":"number"}}}},"required":["data","message"],"description":"Response containing station summary statistics"},"StationSummary":{"type":"object","properties":{"unique_units":{"type":"number"},"total_input":{"type":"number"},"unique_input":{"type":"number"},"total_output":{"type":"number"},"unique_output":{"type":"number"},"first_pass":{"type":"number"},"final_pass":{"type":"number"},"first_pass_yield":{"type":"number"},"final_yield":{"type":"number"},"retry_rate":{"type":"number"}},"required":["unique_units","total_input","unique_input","total_output","unique_output","first_pass","final_pass","first_pass_yield","final_yield","retry_rate"],"description":"Station summary statistics including pass rates and yields"},"SitesResponse":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-fA-F]{24}$","description":"24 character hexadecimal ID of the resource"},"name":{"type":"string","example":"California Factory - CAL01"},"description":{"type":"string","example":"Automated Assembly Factory"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-fA-F]{24}$","description":"24 character hexadecimal ID of the resource"},"name":{"type":"string","example":"FATP Line"},"description":{"type":"string","example":"Assembly line"},"elements":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-fA-F]{24}$","description":"24 character hexadecimal ID of the resource"},"name":{"type":"string","example":"Top Assembly 1"},"description":{"type":"string","example":"First of the assembly stations"},"type":{"type":"string","const":"station"}},"required":["id","name","description","type"]},{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-fA-F]{24}$","description":"24 character hexadecimal ID of the resource"},"name":{"type":"string","example":"Testing Group"},"description":{"type":"string","example":"Group of stations"},"stations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-fA-F]{24}$","description":"24 character hexadecimal ID of the resource"},"name":{"type":"string","example":"Top Assembly 1"},"description":{"type":"string","example":"First of the assembly stations"}},"required":["id","name","description"]}},"type":{"type":"string","const":"group"}},"required":["id","name","description","stations","type"]}]}}},"required":["id","name","description","elements"]}}},"required":["id","name","description","lines"]}},"message":{"type":"string","description":"Response message"},"meta":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"request_id":{"type":"string","description":"Request ID for tracking"},"query_duration_ms":{"type":"number"}}}},"required":["data","message"],"description":"Response with an array of sites (may be a single-element array for specific site requests)"}}},"security":[{"bearerAuth":[]}],"info":{"title":"API Reference","description":"Backend API to fetch data from the Autumn Labs platform collected by stations across all the sites a user has access to. Requires a valid JWT token generated from the dashboard in the Authorization header.","version":"1.0.0"},"servers":[{"url":"https://api.autumnlabs.io","description":"Production API"},{"url":"http://localhost:3000","description":"Development Server"},{"url":"https://staging.api.autumnlabs.io","description":"Staging API"}],"paths":{"/metrics":{"get":{"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricsResponse"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"500":{"description":"Server Error - Internal error occurred","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}}},"operationId":"getMetrics","parameters":[{"in":"query","name":"station_ids","schema":{"type":"string","description":"Comma-separated list of station IDs"}},{"in":"query","name":"to","schema":{"type":"string","format":"date-time","default":"2026-10-01T21:09:33.638Z"}},{"in":"query","name":"from","schema":{"type":"string","format":"date-time","default":"2026-09-30T21:09:33.638Z"}},{"in":"query","name":"names","schema":{"type":"array","items":{"type":"string"},"default":[],"description":"The names of the metrics to filter by","example":["temperature","humidity"]}}],"summary":"Metrics","description":"Retrieve metrics data for specified or all accessible stations and optional filters"}},"/units":{"get":{"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnitsResponse"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"500":{"description":"Server Error - Internal error occurred","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}}},"operationId":"getUnits","tags":["units"],"parameters":[{"in":"query","name":"station_ids","schema":{"type":"string","description":"Comma-separated list of station IDs"}},{"in":"query","name":"to","schema":{"type":"string","format":"date-time","default":"2026-10-01T21:09:33.638Z"}},{"in":"query","name":"from","schema":{"type":"string","format":"date-time","default":"2026-09-30T21:09:33.638Z"}},{"in":"query","name":"type","schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}],"default":[],"description":"The unit types to filter by. Can be repeated (?type=sensor&type=actuator) or comma-separated (?type=sensor,actuator)","example":["sensor","actuator"]}},{"in":"query","name":"serial_number","schema":{"type":"string","description":"The serial number of the unit to filter by"}},{"in":"query","name":"direction","schema":{"anyOf":[{"type":"array","items":{"type":"string","enum":["input","output"]}},{"type":"string"}],"default":["output"],"description":"The directions to filter by. Can be repeated (?direction=input&direction=output) or comma-separated (?direction=input,output)","example":["input","output"]}}],"summary":"Units","description":"Retrieve units data for specified or all accessible stations with optional filters"}},"/station/summary":{"get":{"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StationSummaryResponse"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"500":{"description":"Server Error - Internal error occurred","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}}},"operationId":"getStationSummary","parameters":[{"in":"query","name":"station_ids","schema":{"type":"string","example":"507f1f77bcf86cd799439011,507f1f77bcf86cd799439012","description":"Comma-separated list of station IDs"},"required":true},{"in":"query","name":"to","schema":{"type":"string","format":"date-time","default":"2026-10-01T21:09:33.638Z"},"required":false},{"in":"query","name":"from","schema":{"type":"string","format":"date-time","default":"2026-09-30T21:09:33.638Z"},"required":false}],"method":"get","path":"/summary","summary":"Station Summary","description":"Retrieve station summary statistics including pass rates, yields, and retry rates for specified stations","request":{"query":{"_def":{"unknownKeys":"strip","catchall":{"_def":{"typeName":"ZodNever"},"~standard":{"version":1,"vendor":"zod"}},"typeName":"ZodObject","zodOpenApi":{}},"~standard":{"version":1,"vendor":"zod"},"_cached":null}}}},"/sites":{"get":{"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SitesResponse"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}},"500":{"description":"Server Error - Internal error occurred","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}},"required":["code","message"]}},"required":["error"],"description":"Standard error response"}}}}},"operationId":"getSites","parameters":[{"in":"query","name":"id","schema":{"type":"string","pattern":"^[0-9a-fA-F]{24}$","description":"ID of the site. Default is all sites."}}],"summary":"Sites","description":"Get site data with nested structure"}}}}