API reference
REST API v1
Authenticate with an API key, send images for inspection, read results and metrics, and receive signed webhooks.
Beta API. This reference is a preview of API v1 and may change before general availability. Breaking changes will be announced here at least 30 days ahead.
Overview
The REST API uses JSON over HTTPS. All requests go to the base URL below and must use TLS 1.2 or later.
https://api.inspectraai.ca/v1
Timestamps are ISO 8601 in UTC. IDs are opaque strings with a type prefix. List endpoints use cursor pagination with limit (max 200) and cursor.
Authentication
Create API keys in Workspace settings → API keys (Owner or Admin role). Each key is scoped to one workspace and to a set of permissions: inspect:write, inspections:read, metrics:read. Send the key as a bearer token:
Authorization: Bearer isk_test_••••••••••••••••
Keys prefixed isk_test_ work against a sandbox station with sample data; production keys are issued per workspace. Keys are shown once on creation, can be rotated at any time and are recorded in the audit log. Never put API keys in client-side code or in support messages.
Inspect an image
POST/v1/inspect
Runs the station's active model on one image in the cloud and returns a decision. Use it for integration testing, re-scoring and low-volume stations; high-speed stations decide on the edge device and report inspections asynchronously.
Request
Send multipart/form-data with an image file, or JSON with a base64-encoded image.
| Field | Type | Description |
|---|---|---|
station_id | string, required | Station whose active model is used |
image | file or base64 string, required | JPEG, PNG or TIFF, up to 20 MB |
part_id | string | Your serial number or part reference |
sku | string | Product code, used in analytics breakdowns |
return_heatmap | boolean | Include a heatmap URL for anomaly models (default false) |
POST /v1/inspect
Content-Type: application/json
Authorization: Bearer isk_test_••••••••••••••••
{
"station_id": "stn_2b",
"part_id": "SN-58211",
"sku": "CAP-38-BLU",
"image": "/9j/4AAQSkZJRgABAQ...",
"return_heatmap": true
}
Response 200 OK
{
"id": "insp_01JD8X4Q2M7T",
"station_id": "stn_2b",
"line_id": "line_2",
"part_id": "SN-58211",
"sku": "CAP-38-BLU",
"decision": "fail",
"anomaly_score": 0.87,
"threshold": 0.62,
"defects": [
{
"class": "scratch",
"confidence": 0.94,
"bbox": [1412, 388, 1630, 512],
"area_px": 9874
}
],
"heatmap_url": "https://api.inspectraai.ca/v1/inspections/insp_01JD8X4Q2M7T/heatmap",
"model": { "id": "mdl_anomaly_cap", "version": 7, "precision": "fp16" },
"latency_ms": 41,
"created_at": "2026-11-22T08:14:03.412Z"
}
decision is pass, fail or review (score within the station's review band). bbox is [x1, y1, x2, y2] in image pixels.
List inspections
GET/v1/inspections
Returns inspections from edge devices and cloud calls, newest first.
| Query parameter | Description |
|---|---|
line_id, station_id | Filter by line or station |
decision | pass, fail or review |
defect_class | Only inspections containing this defect class |
from, to | ISO 8601 time range |
limit, cursor | Pagination |
GET /v1/inspections?line_id=line_2&decision=fail&limit=2
{
"data": [
{
"id": "insp_01JD8X4Q2M7T",
"station_id": "stn_2b",
"decision": "fail",
"anomaly_score": 0.87,
"defects": [{ "class": "scratch", "confidence": 0.94 }],
"operator_feedback": null,
"created_at": "2026-11-22T08:14:03.412Z"
},
{
"id": "insp_01JD8X3ZK0QA",
"station_id": "stn_2b",
"decision": "fail",
"anomaly_score": 0.71,
"defects": [{ "class": "dent", "confidence": 0.82 }],
"operator_feedback": { "verdict": "confirmed", "role": "operator" },
"created_at": "2026-11-22T08:13:58.120Z"
}
],
"next_cursor": "c_eyJ0IjoiMjAyNi0xMS0yMlQwODoxMzo1OCJ9"
}
Line metrics
GET/v1/lines/{id}/metrics
Aggregated quality metrics for a line over a time window, optionally bucketed.
| Query parameter | Description |
|---|---|
from, to | Time range (default: current shift) |
bucket | hour, shift or day |
group_by | station, sku or defect_class |
GET /v1/lines/line_2/metrics?from=2026-11-22T00:30:00Z&to=2026-11-22T08:30:00Z
{
"line_id": "line_2",
"from": "2026-11-22T00:30:00Z",
"to": "2026-11-22T08:30:00Z",
"inspected": 28905,
"passed": 27923,
"failed": 982,
"review": 41,
"yield": 0.966,
"first_pass_yield": 0.961,
"defects_per_hour": 122.8,
"pareto": [
{ "class": "scratch", "count": 512, "share": 0.521 },
{ "class": "dent", "count": 201, "share": 0.205 },
{ "class": "misprint", "count": 148, "share": 0.151 },
{ "class": "contamination", "count": 121, "share": 0.123 }
],
"model_versions": ["mdl_anomaly_cap@7"]
}
Values in examples are illustrative sample data.
Webhooks
Register HTTPS endpoints in Workspace settings → Webhooks. Each delivery is a POST with a JSON body and these headers:
Inspectra-Event: inspection.failed
Inspectra-Delivery: dlv_01JD8X4R0B
Inspectra-Signature: t=1795335243,v1=5f2c…e9a1
Verify the signature by computing HMAC-SHA256 over {t}.{raw body} with your endpoint's signing secret and comparing it with v1 in constant time; reject deliveries older than five minutes. Respond with a 2xx within 10 seconds. Failed deliveries are retried with exponential backoff for up to 24 hours.
EVENTinspection.failed
Sent when a part fails inspection on any station you subscribe to.
{
"id": "evt_01JD8X4R0B5Q",
"type": "inspection.failed",
"created_at": "2026-11-22T08:14:03.530Z",
"data": {
"inspection_id": "insp_01JD8X4Q2M7T",
"line_id": "line_2",
"station_id": "stn_2b",
"part_id": "SN-58211",
"sku": "CAP-38-BLU",
"anomaly_score": 0.87,
"defects": [{ "class": "scratch", "confidence": 0.94 }],
"model": { "id": "mdl_anomaly_cap", "version": 7 }
}
}
EVENTmodel.drift_detected
Sent when the drift monitor finds that live images or model confidence on a station have moved away from the training distribution.
{
"id": "evt_01JD9A1C7HXT",
"type": "model.drift_detected",
"created_at": "2026-11-22T11:02:44.000Z",
"data": {
"station_id": "stn_1a",
"model": { "id": "mdl_label_print", "version": 3 },
"signal": "image_brightness",
"baseline": 0.48,
"current": 0.57,
"window": "6h",
"severity": "warning",
"suggested_action": "review_low_confidence_images"
}
}
Drift events never change a model or threshold automatically. They create a review task for the Quality Manager role.
Errors and rate limits
| Status | Meaning |
|---|---|
400 | Invalid request — see error.message and error.field |
401 | Missing or invalid API key |
403 | Key lacks the required permission |
404 | Object not found in this workspace |
413 | Image larger than 20 MB |
429 | Rate limit exceeded — retry after the Retry-After header |
5xx | Server error — safe to retry with backoff |
{
"error": {
"type": "invalid_request",
"message": "station_id is required",
"field": "station_id",
"request_id": "req_01JD8X4QZ9"
}
}
Beta default limits: 10 requests per second per key for POST /v1/inspect and 50 per second for read endpoints.