API Reference
TimeDetect API (1.0)
Download OpenAPI specification:Download
The API has three main processes:
- Uploading approved time registrations: Validates and processes registration data for the machine learning models to train on.
- Model training: Prepares a hierarchy of machine learning models for each dataset.
- Prediction: Generate predictions with the machine learning models to and highlight anomalies.
Get Presigned URL
Obtain a presigned URL to upload data to the platform. This URL allows you to make a PUT request with the data in the request body. Depending on the optional 'type' query parameter, the uploaded data can either trigger a prediction job or be stored for general use.
The URL is valid for 60 minutes. The user must specify the Tenant-ID, which is required in the request header.
- Use 'prediction' as the type to trigger processing that initiates a prediction job with the uploaded data.
- Use 'raw_data' as the type for standard data uploads. This is the default behavior if the type parameter is not specified.
Authorizations:
query Parameters
type | string Default: "raw_data" Enum: "prediction" "raw_data" Determines the type of data the presigned URL will be used for. "prediction" indicates prediction data; "raw_data" indicates that it will be used as training data. Defaults to "raw_data" if not provided. |
header Parameters
tenantId required | string The ID of the tenant. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 429
- 500
{- "url": "string",
- "jobId": "string",
- "message": "string"
}
Get Job Status
Get the status for a validation, training, or prediction job. Use the job ID that was returned when the job was created. If the job runs with multiple datasets, the status for each dataset's process is returned.
Authorizations:
header Parameters
tenantId required | string The ID of the tenant. |
jobId required | string The ID of the job to check the status for. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 404
- 429
- 500
{- "status": "inProgress",
- "datasetsStatus": [
- {
- "datasetId": "string",
- "status": "string",
- "message": "string"
}
], - "message": "string"
}
Upload Raw Data
This endpoint is for uploading data to a presigned URL. Unlike the ther endpoints, this does not use the base API URL. Obtain the presigned URL by calling GET /presigned_url and use it as is for this PUT request.
By sending a PUT request to the presigned url (generated by calling GET /presigned_url), the validation process is triggered.
For a dataset with with 4000 registrations, the job usually takes less than 2 minutes to complete, while for a dataset with 55'000 registrations, it typically takes less than 10 minutes.
Do not send the authentication token, the authentication is handled through the presigned url. This process validates the data and prepares it for model training. The status of the validation process can be fetched by calling GET /status.
Important: Ensure that the header of your PUT request is empty. It should not contain a "Content-Type" or any other headers. This is crucial for the request to be processed correctly.
Note: The request body and response schemas can be found by expanding the arrows in the sections below.
Request Body schema: raw/jsonrequired
The body needs to contain the necessary data about registrations.
required | Array of objects (Raw Data Upload Request Dataset) non-empty Datasets containing raw data for training. |
object Details for the webhook endpoint to call when a job finishes. |
Responses
Callbacks
Request samples
- Payload
{- "datasets": [
- {
- "datasetId": "5de7cd24-9dd3-4526-a782-55c670a47eba",
- "customerId": "acadd548-c4e5-4017-b89c-c0ef75143752",
- "registrations": [
- {
- "registrationId": "1e24162a-3bad-4a58-865c-a1994c75942d",
- "date": "2024-08-26",
- "employeeId": "cf5ee029-0747-45c1-94e3-ea7a2ae3129c",
- "projectId": "high_rise_project",
- "departmentId": "construction",
- "workCategory": "roofing",
- "startTime": 6.5,
- "endTime": 16,
- "workDuration": 9,
- "breakDuration": 0.5,
- "publicHoliday": false,
- "numericals": [
- {
- "name": "overtime",
- "value": 1
}
]
}
]
}
],
}
Callback payload samples
{- "status": "success",
- "jobId": "7720a8c02c664d80a69ed2141b731ee3"
}
Get Job Status
Get the status for a validation, training, or prediction job. Use the job ID that was returned when the job was created. If the job runs with multiple datasets, the status for each dataset's process is returned.
Authorizations:
header Parameters
tenantId required | string The ID of the tenant. |
jobId required | string The ID of the job to check the status for. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 404
- 429
- 500
{- "status": "inProgress",
- "datasetsStatus": [
- {
- "datasetId": "string",
- "status": "string",
- "message": "string"
}
], - "message": "string"
}
Start Trainer
This endpoint will do 1 out of 2 things, depending on the boolean rebuildModels field:
If rebuildModels = True:
If rebuildModels = False:
A full retrain for a dataset with 50 employees takes less than 2 minutes to complete, while for 500 employees it takes less than 10 minutes.
Note: The response schemas can be found by expanding the arrows in the sections below.
Authorizations:
header Parameters
tenantId required | string Tenant ID |
Request Body schema: application/jsonrequired
The body contains confuguration to be used to initiate training procedure for each specified dataset ID
required | Array of objects (Start Trainer Request Dataset Ids) List with objects containing the parameters for each dataset. |
object Details for the webhook endpoint to call when a job finishes. |
Responses
Callbacks
Request samples
- Payload
{- "parameters": [
- {
- "datasetId": "6d1943e0-46b2-4265-8283-499a735f427e",
- "customerId": "fad5e0e4-2c4f-41cc-84f0-123973913f14",
- "rebuildModels": true
}
],
}
Response samples
- 202
- 400
- 401
- 403
- 413
- 429
- 500
{- "jobId": "string",
- "message": "string"
}
Callback payload samples
{- "status": "success",
- "jobId": "7720a8c02c664d80a69ed2141b731ee3"
}
Get Job Status
Get the status for a validation, training, or prediction job. Use the job ID that was returned when the job was created. If the job runs with multiple datasets, the status for each dataset's process is returned.
Authorizations:
header Parameters
tenantId required | string The ID of the tenant. |
jobId required | string The ID of the job to check the status for. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 404
- 429
- 500
{- "status": "inProgress",
- "datasetsStatus": [
- {
- "datasetId": "string",
- "status": "string",
- "message": "string"
}
], - "message": "string"
}
Create Prediction
Starts the prediction procedure which computes and stores predictions for each DatasetId included in the request body. For 300 registrations the predictions job usually takes less than 2 minutes to complete, while for 5'000 registrations, it typically takes less than 12 minutes.
The status of the prediction procedure can be fetched by calling GET /status with the provided jobId. The predictions can be fetched by calling GET /results, also with the provided jobId.
A prediction will be made for each registration sent in, but the registrations will not be used to update the models. To update the models, upload data through the PUT /[presigned_url] endpoint and explicitly update the models by calling the POST /start_trainer endpoint.
Request Size Limitation: To ensure successful processing, it is recommended to limit the number of registrations in your prediction request. This is due to a hard limit of 6MB in the prediction requetst body. As a guideline, limit your prediction requests to approximately 12,000 registrations. This helps in avoiding response size issues and ensures smoother retrieval of results.
Note: The request body and response schemas can be found by expanding the arrows in the sections below.
Authorizations:
header Parameters
tenantId required | string Tenant ID |
Request Body schema: application/jsonrequired
The data should be sent as a list of registrations per dataset.
required | Array of objects (Create Prediction Request Dataset Parameters) Prediction parameters for each dataset. |
object Details for the webhook endpoint to call when a job finishes. |
Responses
Callbacks
Request samples
- Payload
{- "parameters": [
- {
- "datasetId": "cc3fa933-80fe-4b18-a9c8-66fe0fbf85a2",
- "customerId": "87082b90-097b-4115-aec2-7330918fe6aa",
- "registrations": [
- {
- "registrationId": "1e24162a-3bad-4a58-865c-a1994c75942d",
- "date": "2024-08-26",
- "employeeId": "cf5ee029-0747-45c1-94e3-ea7a2ae3129c",
- "projectId": "high_rise_project",
- "departmentId": "construction",
- "workCategory": "roofing",
- "startTime": 6.5,
- "endTime": 16,
- "workDuration": 9,
- "breakDuration": 0.5,
- "publicHoliday": false,
- "numericals": [
- {
- "name": "overtime",
- "value": 1
}
]
}
], - "aggregateForEmployeeIds": [
- "6bbc1322-af64-44c9-bfbc-abc8183d7618",
- "8c2c136f-07c1-496f-b2e5-1d5dfe4ca443",
- "9c421927-069e-4d31-a6da-368011132501",
- "f14ee0f7-af97-4095-91c6-55ba4641ad8b"
]
}
],
}
Response samples
- 202
- 400
- 401
- 403
- 413
- 429
- 500
{- "jobId": "string",
- "message": "string"
}
Callback payload samples
{- "status": "success",
- "jobId": "7720a8c02c664d80a69ed2141b731ee3"
}
To be overwritten by summary in the trainer's path file
To be overwritten by description in the trainer's path file
Authorizations:
header Parameters
tenantId required | string Tenant ID |
Responses
Response samples
- 400
- 401
- 403
- 404
- 413
- 429
- 500
{- "error": "string",
- "code": "CLIENT_ID_MISSING",
- "message": "string",
- "details": "string",
- "timestamp": "string",
- "error_uuid": "string"
}
Get Prediction Results
Anomaly scoring is a critical aspect of this schema, as indicated by the "anomalyScore" field, which quantifies how unusual a registration is. The "significantFields" field explains why a registration was deemed an anomaly by highlighting which specific features were influenced in the anomaly-score. The weekday is derived from the date and is returned as a significant field in certain cases, such as for weekends.
Note: The response schemas can be found by expanding the arrows in the sections below.
Important: If the initial prediction request contained a large number of registrations, especially those spanning wide date ranges, the results might exceed the 6MB response size. In such cases, a 500 error will be returned. To avoid this, it is recommended to adhere to the guideline of limiting prediction requests to approximately 4,000 registrations. This precaution helps in ensuring that the response size remains within manageable limits, thereby preventing potential errors during result retrieval.
Authorizations:
header Parameters
tenantId required | string Tenant ID |
jobId required | string The unique ID of the job |
page | integer >= 1 Default: 1 The page number |
Responses
Response samples
- 200
- 400
- 401
- 403
- 404
- 429
- 500
{- "message": "string",
- "page": 1,
- "pages": 1,
- "results": [
- {
- "datasetId": "730c3bea-0b2c-4813-ba1d-9713136f14b1",
- "severityThresholds": {
- "lowMid": 5,
- "midHigh": 20
}, - "predictions": [
- {
- "registrationId": "f29d051a-e766-43c1-9ff7-066624bfa148",
- "date": "2024-08-27",
- "employeeId": "67f0bb7b-8975-4bea-a707-3e83bc97ebe0",
- "anomalyScore": 31,
- "significantFields": [
- {
- "field": "startTime",
- "significance": 31,
- "direction": 1
}
], - "aggregated": false,
- "missing": false,
- "relatedRegistrationIds": [
- "7818ddc9-2623-4407-a49e-630f5e5faf80"
], - "subModelId": "58c72d26-4489-4100-928c-0aad8b4e82bb"
}
]
}
]
}
Get Data
This endpoint returns list of dataset IDs that have been uploaded for the given tenant.
Authorizations:
header Parameters
tenantId required | string The ID of the tenant. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 413
- 429
- 500
{- "countOfDatasets": 1,
- "datasetIds": [
- "dataset-1"
]
}
Get Data for Dataset
This endpoint allows you to get information about specific dataset.
Authorizations:
path Parameters
datasetId required | string The dataset ID to delete data for. |
header Parameters
tenantId required | string The ID of the tenant. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 413
- 429
- 500
{- "startDate": "2022-04-01",
- "endDate": "2022-04-08",
- "intervalGranularity": "D",
- "numberOfIntervalsWithRecords": 5,
- "numberOfIntervalsWithoutRecords": 3,
- "numberOfIntervalsTotal": 8
}
Delete Data
Delete uploaded data for a specific dataset ID.
Authorizations:
path Parameters
datasetId required | string The dataset ID to delete data for. |
query Parameters
fromDate | string Earliest data point to be deleted. If not specified, all data until the "toDate" will be deleted. |
toDate | string The latest data point to be deleted. If not specified, all data from the "fromDate" will be deleted. |
header Parameters
tenantId required | string The ID of the tenant. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 413
- 429
- 500
{- "message": "string"
}
Upload Feedback
This endpoint allows users to upload feedback for predictions made by the AI model. The feedback helps improve the model by providing insights into the accuracy of its predictions.
Authorizations:
header Parameters
tenantId required | string Tenant ID |
Request Body schema: application/jsonrequired
The body should contain the datasets for which feedback is being provided, including the dataset ID, job ID, and feedback for each prediction.
required | Array of objects | ||||||
Array
|
Responses
Request samples
- Payload
{- "datasets": [
- {
- "datasetId": "52af4e6a-ee74-43a7-b5b6-c7508539a56b",
- "jobId": "3a57dd18-299b-4129-a95f-00941c6f3909",
- "predictions": [
- {
- "predictionId": "46878c8f-69fb-4727-83f3-694ffe28eda9",
- "feedback": "FALSE_POSITIVE"
}
]
}
]
}
Response samples
- 200
- 400
- 401
- 403
- 404
- 413
- 429
- 500
{- "message": "Feedback successfully uploaded"
}
Get Subscriptions
This endpoint provides an overview of the subscriptions for a tenant, with optional filtering by dataset ID and subscription IDs.
Authorizations:
query Parameters
datasetId | string Optional dataset ID to filter subscriptions. |
subscriptionIds | string Optional comma-separated list of subscription IDs to filter within the dataset. |
header Parameters
tenantId required | string The ID of the tenant. |
Responses
Response samples
- 200
- 400
- 401
- 403
- 413
- 429
- 500
{- "countOfDatasets": 0,
- "countOfSubscriptionIds": 0,
- "subscriptionObjects": [
- {
- "datasetId": "string",
- "countOfSubscriptionIds": 0,
- "subscriptionIds": [
- "string"
]
}
]
}
Unsubscribe
Unsubscribe for a list of subscription objects.
Authorizations:
header Parameters
tenantId required | string The ID of the tenant. |
Request Body schema: application/jsonrequired
The dataset IDs and optionally subscription IDs to unsubscribe.
required | Array of objects (Subscription Object) List of subscription objects. | ||||
Array
|
Responses
Request samples
- Payload
{- "subscriptionObjects": [
- {
- "datasetId": "string",
- "subscriptionIds": [
- "string"
]
}
]
}
Response samples
- 200
- 400
- 401
- 403
- 413
- 429
- 500
{- "countOfUnsubscribedDatasets": 0,
- "countOfUnsubscribedSubscriptionIds": 0,
- "unsubscribedSubscriptionObjects": [
- {
- "datasetId": "string",
- "countOfSubscriptionIds": 0,
- "subscriptionIds": [
- "string"
]
}
]
}