Import tasks

Import data as labeling tasks in bulk using this API endpoint. You can use this API endpoint to import multiple tasks. One POST request is limited at 250K tasks and 200 MB. **Note:** Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*. For example, if the label configuration has a *$text* variable, then each item in a data object must include a "text" field. <br> ## POST requests <hr style="opacity:0.3"> There are three possible ways to import tasks with this endpoint: ### 1. **POST with data** Send JSON tasks as POST data. Only JSON is supported for POSTing files directly. Update this example to specify your authorization token and Label Studio instance host, then run the following from the command line. ```bash curl -H 'Content-Type: application/json' -H 'Authorization: Token abc123' \ -X POST 'http://localhost:8000/api/projects/1/import' --data '[{"text": "Some text 1"}, {"text": "Some text 2"}]' ``` ### 2. **POST with files** Send tasks as files. You can attach multiple files with different names. - **JSON**: text files in JavaScript object notation format - **CSV**: text files with tables in Comma Separated Values format - **TSV**: text files with tables in Tab Separated Value format - **TXT**: simple text files are similar to CSV with one column and no header, supported for projects with one source only Update this example to specify your authorization token, Label Studio instance host, and file name and path, then run the following from the command line: ```bash curl -H 'Authorization: Token abc123' \ -X POST 'http://localhost:8000/api/projects/1/import' -F 'file=@path/to/my_file.csv' ``` ### 3. **POST with URL** You can also provide a URL to a file with labeling tasks. Supported file formats are the same as in option 2. ```bash curl -H 'Content-Type: application/json' -H 'Authorization: Token abc123' \ -X POST 'http://localhost:8000/api/projects/1/import' \ --data '[{"url": "http://example.com/test1.csv"}, {"url": "http://example.com/test2.csv"}]' ``` <br>

Authentication

AuthorizationToken

Header authentication of the form Token <token>

Path Parameters

idintegerRequired
A unique integer value identifying this project.

Query Parameters

commit_to_projectbooleanOptionalDefaults to true
Set to "true" to immediately commit tasks to the project.
preannotated_from_fieldsstringOptional

List of fields to preannotate from the task data. For example, if you provide a list of {"text": "text", "prediction": "label"} items in the request, the system will create a task with the text field and a prediction with the label field when preannoted_from_fields=["prediction"].

return_task_idsbooleanOptionalDefaults to false
Set to "true" to return task IDs in the response.

Request

This endpoint expects a list of objects.
dataanyRequired
annotationslist of objectsOptional
cancelled_annotationsintegerOptional-2147483648-2147483647
Number of total cancelled annotations for the current task
comment_authorslist of integersOptional
Users who wrote comments
comment_countintegerOptional-2147483648-2147483647
Number of comments in the task including all annotations
file_uploadintegerOptional
Uploaded file used as data source for this task
inner_idlongOptional
Internal task ID in the project, starts with 1
last_comment_updated_atdatetimeOptional
When the last comment was updated
metaanyOptional
overlapintegerOptional-2147483648-2147483647
Number of distinct annotators that processed the current task
precomputed_agreementdoubleOptional
Average agreement score for the task
predictionslist of objectsOptional
total_annotationsintegerOptional-2147483648-2147483647
Number of total annotations for the current task except cancelled annotations
total_predictionsintegerOptional-2147483648-2147483647
Number of total predictions for the current task
unresolved_comment_countintegerOptional-2147483648-2147483647
Number of unresolved comments in the task including all annotations
updated_byintegerOptional
Last annotator or reviewer who updated this task

Response

Tasks successfully imported
annotation_countinteger or null
Number of annotations added
could_be_tasks_listboolean or null

Whether uploaded files can contain lists of tasks, like CSV/TSV files

data_columnslist of strings or null
The list of found data columns
durationdouble or null
Time in seconds to create
file_upload_idslist of integers or null
Database IDs of uploaded files
found_formatslist of strings or null
The list of found file formats
predictions_countinteger or null
Number of predictions added
task_countinteger or null
Number of tasks added

Errors