Create a task
A task represents an individual unit of work to be done by a Contributor. There’s a 1:1 mapping between a task and the data to be labeled. For example, there’d be 1 task for each image, video, or lidar sequence needing to be labeled. You specify how a task should be labeled by passing task parameters to the relevant task creation endpoint. Every task has a type, which determines the endpoint you create it with and the parameters it accepts. For information on how to create specific task types, see:Task Metadata
Task objects have a metadata parameter. You can use this parameter to attach key-value data to tasks. Metadata is useful for storing additional, structured information on an object - especially information that can help you ingest the task response or keep track of what content this task corresponds to. Metadata is not used by Scale (e.g., to affect how the task is done). Common use-cases for metadata:
- Internal identifiers
- File paths
- Scenario / Run / Case identifiers
- Environment details (time of day, location)
- Sensor information
- Guideline / Taxonomy versions
Retrieve a task
Retrieve a single task by its task ID.Retrieve Multiple Tasks
This is a paginated endpoint that retrieves a list of your tasks. The tasks will be returned in descending order based on created_at time. All time filters expect an ISO 8601-formatted string, like ‘2021-04-25’ or ‘2021-04-25T03:14:15-07:00’ The pagination is based on the limit and next_token parameters, which determine the page size and the current page we are on. The value of next_token is a unique pagination token for each page (nerdy details if you were curious). Make the call again using the returned token to retrieve the next page.The audit result status of the task:
accepted, fixed, commented, or rejected. To specify multiple values, pass a comma-separated string (e.g. customer_review_status=accepted,fixed) or an array (e.g. customer_review_status=accepted&customer_review_status=fixed).The
unique_id of a task. To specify multiple unique IDs, pass a comma-separated string (e.g. unique_id=a1,a2) or an array (e.g. unique_id=a1&unique_id=a2).The tags of a task. To specify multiple tags, pass a comma-separated string (e.g.
tags=t1,t2) or an array (e.g. tags=t1&tags=t2).Cancel Task
You may only cancel pending tasks, and the endpoint will return a 400 error code if you attempt to cancel a completed task. If the task to be canceled has a unique id, specifying**clear_unique_id=true** will remove the unique id. Canceling tasks is idempotent such that calling this endpoint multiple times will still return a 200 success response.
Set Task Metadata
This endpoint sets the**metadata** field on a task.
You may set the **metadata** field on any existing task using valid key-value data.
Updating a task’s **metadata** field is idempotent such that calling this endpoint multiple times will still return a 200 success response.
Update unique_id
Update theunique_id of an existing task.
Delete unique_id
Remove theunique_id from an existing task.
Add Task Tag
With this endpoint, you can include a list of**tags** to be added to a task. If a **tag** is already associated with the task, it will be ignored to avoid duplication. Please note that setting an empty or null string as a **tag** is not allowed. Ensure to provide valid non-empty strings in the **tags** list to update the task’s tags successfully.
Set Task Tag
This endpoint allows you to set a completely new list oftags on a task. This replaces all existing tags on it if the target exists.
Delete Task Tag
With this endpoint, you can remove a list oftags from a task. Tags that aren’t on the task are ignored.
Avoiding Duplicate Tasks
Creating duplicate tasks is an issue every team should be mindful to avoid. Scale AI provides two different mechanisms to prevent duplicate tasks from being created in its task creation endpoints. This allows you to resubmit requests that may have failed in transit or otherwise need to be retried without the risk of creating duplicate tasks.Option 1: The unique_id field
The unique_id field is a field available on every task type Scale provides.
Once a unique_id has been submitted to Scale, any future task creation requests with the same unique_id will fail with a 409 error that also conveniently points to the conflicting task.
Values passed into the unique_id field are permanently associated with the task and will always be returned to you when retrieving tasks from our platform.
You are able to query for tasks directly based on the unique_id field at any point with our Task Retrieval endpoints.
Best Practices:
unique_idshould be thought of as your own customizable id for a task. Ideally, this id can be easy to look up based on the data you have available on your side. A goodunique_idmight be the filename being submitted, or other types of metadata like a scene or run id that you use internally.unique_idis set globally across all projects and task types. If you’d like to enforce uniqueness only within a project or task type, we recommend prepending or appending the project or task type to the unique ID.
Option 2: The Idempotency-Key header
To use this feature, provide a header Idempotency-Key: \<key\>. You, the client, are responsible for ensuring the uniqueness of your chosen keys. We recommend using V4 UUIDs.
The results of requests specifying an idempotency key are saved. If we later receive a matching request with the same idempotency key, the saved response will be returned, and no additional task will be created. Note that this behavior holds even when the response is an error. Keys are removed after 24 hours.
If an incoming request has the same idempotency key as a saved request, but the two requests do not match in parameters or the users associated with the two requests are different, we will return a 409 error.
In rare situations, we may return a 429 error if two matching requests with identical idempotency keys are made simultaneously. In this case, it is safe to retry.
When would I use this instead of the **unique_id** field?Using the header-based approach is useful in retry logic that catches network or other transient failure modes when you would be immediately retrying the exact same request. Specifically, the feature that allows you to seamlessly get the same task response back if the payload didn’t change makes for easier code integrations. You are able to use both options simultaneously as well.
Workflow Support
Because unique IDs are permanently tied to a task, it can be hard to recover if something unexpected happens. We have added two features to help support more robust workflows. Canceling TasksWhen canceling tasks, there is a
clear_unique_id query parameter you can specify on the request. See the Cancel Task endpoint for more details.
Errored TasksSometimes after a task is submitted, it can run into an error, especially in regards to processing attachments. Everywhere you can specify a unique id, you can also specify
clear_unique_id_on_error: true. As the param name suggests, if the task reaches an error status, the unique id will automatically be unset, so you can submit a new task with the same unique ID.
Retrieve Task Quality Scores
Retrieve the audits of a task, newest first, or a single audit by its id. Once an audit has been graded, its task_score holds the task’s quality scores, the same ones the Quality Hub shows. These methods require a team Admin or Manager API key. Requiresscaleapi 2.20.0 or later.
task_score has version and result, which lists up to three scores: standard-annotation-precision, standard-detection-recall and standard-detection-precision. Each score is 1 - numerator / denominator (1 when the denominator is 0), where the numerator counts errors and the denominator counts possible errors. The formula field names the grader fields the two counts come from. Weighted error counts can exceed the possible-error count, so a score can fall below 0.
task_score with version: 4. It has the same result list of name, score, numerator, denominator and formula, but each name is one of the grading kinds configured for your project rather than the three standard scores. Use version to tell the two shapes apart.