[Skip to main content](https://docs.clarifai.com/create/labeling/api/tasks/#__docusaurus_skipToContent_fallback)

GPU Shortage?Make the most out of your GPUs with Compute Orchestration. [Learn More](/content/ebook-clarifai-executive-guide-2025/index.html)

On this page

**Group your labeling work into tasks that can be delegated**

* * *

Task is the work that needs to be done for labeling the inputs in an app. It's a powerful way to help your team annotate inputs fast and efficiently.

These are some parameters you can specify when working with tasks:

- **Task type**— It can be:
  - `CONCEPTS_CLASSIFICATION` — Concepts classification tasks annotate [concepts](https://docs.clarifai.com/api-guide/concepts/) for the overall image, frame of video, or section of text.
  - `BOUNDING_BOX_DETECTION` — Bounding box detection tasks annotate rectangular bounding box regions around each concept in an image, frame of video, or section of text.
  - `POLYGON_DETECTION` — Polygon detection tasks annotate free-form regions around concepts in an image, frame of video, or section of text.
  - `TYPE_NOT_SET` — This is the default task type. It should be used when creating an auto-annotation task.
- **Worker** — Task worker includes information about the workers who will work on the task. For manual labeling tasks, the workers can only be users; no limitation on number of workers. For auto-annotation tasks, the worker can be either a model or a workflow; currently only supports 1 worker.
- **Concepts** — List of concept IDs used in the work on the task. The concepts should already be existing in your app.
- **Task worker strategy**— It can be:
  - `DYNAMIC` — Each worker will dynamically get 10 inputs assigned at a time. No inputs are assigned at task creation. It's the recommended way to set a task worker strategy.
  - `PARTITIONED` — The inputs will be partitioned in several partitions. Each worker will label one or more input partitions. All inputs are assigned at task creation.
  - `FULL` — Each worker will label all inputs from the input source. All inputs are assigned at task creation.
- **Input source**— It can be:
  - `ALL_INPUTS` — Use all inputs in the app.
  - `DATASET` — Use inputs from a [dataset](https://docs.clarifai.com/api-guide/data/datasets/).
- **[`sample_ms`](https://docs.clarifai.com/api-guide/predict/video#configuring-fps)** — Used in video model predictions. It specifies the sample delay for video predictions (1 frame per N milliseconds).
- **Review strategy**— It can be:
  - `NONE` — No review is needed.
  - `MANUAL` — Manual review strategy.
  - `CONSENSUS` — Consensus review strategy.
- **Partitioned strategy info**— It can be:
  - `EVENLY` — Each worker will label (approximately) the same number of inputs.
  - `WEIGHTED` — Each worker will have an assigned weight.
- **Workers per input** — The number of workers who will label each input.
- **Auto-annotation config**\- The concepts configurations for setting up an auto-annotation labeling task using a model or a workflow. You can set:
  - `annotation_data_types` — An integer for filtering annotations by their annotation data type. It's a bit-mask field that holds multiple annotation data type values that are combined in an OR fashion. For example, if `annotation_data_types = 34`, then we filter annotations that appear as a mask or a bounding box, because `MASK = 32` and `BOUNDING_BOX = 2`. You can look for the various annotation data types values [here](https://github.com/Clarifai/clarifai-go-grpc/blob/master/proto/clarifai/api/resources.pb.go). For example, `annotation_data_types=1` corresponds to `AnnotationDataType_TAG`.
  - `threshold_range` — It specifies a range of predictions values based on the lower and upper bounds, and it defines whether these bounds are inclusive or exclusive. For example, if you set `is_lower_inclusive = true`, `is_upper_inclusive = true`, `lower = 0.7` and `upper = 1.0`, it is interpreted as the prediction range includes all values from 0.7 to 1.0, including both 0.7 and 1.0.
  - `status_code` — It specifies the [code](https://docs.clarifai.com/api-guide/advanced-topics/status-codes#annotation-related-codes-24xxx) related to the status of the annotation.

info

Before using the [Python SDK](https://docs.clarifai.com/additional-resources/api-overview/python-sdk), [Node.js SDK](https://docs.clarifai.com/additional-resources/api-overview/nodejs-sdk), or any of our [gRPC clients](https://docs.clarifai.com/additional-resources/api-overview/grpc-clients), ensure they are properly installed on your machine. Refer to their respective installation guides for instructions on how to install and initialize them.

## Create [​](https://docs.clarifai.com/create/labeling/api/tasks/\#create "Direct link to Create")

To create a new task in your app, you `POST` the task information to the `v2/task` endpoint.

### Assigned Task [​](https://docs.clarifai.com/create/labeling/api/tasks/\#assigned-task "Direct link to Assigned Task")

A task should be assigned to a list of users. These users will do the labeling work, so they're also called workers. A task may also be assigned to a list of users for review purposes.

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#################################################################################
# In this section, we set the user authentication, app ID, and details for
# assigning a task. Change these strings to run your own example.
#################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to assign your own task
CONCEPT_ID = 'water'
WORKER_USER_ID = 'WORKER_USER_ID_HERE'
REVIEWER_USER_ID = 'REVIEWER_USER_ID_HERE' # User who will review this task
DATASET_ID = 'DATASET_ID_HERE'

##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

post_tasks_response = stub.PostTasks(
    service_pb2.PostTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        tasks=[\
            resources_pb2.Task(\
                type='CONCEPTS_CLASSIFICATION',\
                name='Annotate ' + CONCEPT_ID,\
                worker=resources_pb2.TaskWorker(\
                    strategy='DYNAMIC',\
                    workers=[\
                        resources_pb2.Worker(\
                            user=resources_pb2.User(\
                                id=WORKER_USER_ID\
                            )\
                        )\
                    ]\
                ),\
                concepts=[\
                    resources_pb2.TaskConcept(\
                        concept=resources_pb2.Concept(\
                            id=CONCEPT_ID\
                        )\
                    )\
                ],\
                input_source=resources_pb2.TaskInputSource(\
                    type='DATASET',\
                    id=DATASET_ID\
                ),\
                sample_ms=1000,\
                review=resources_pb2.TaskReview(\
                    strategy='MANUAL',\
                    manual_strategy_info=resources_pb2.TaskReviewManualStrategyInfo(\
                        sample_percentage=0.5\
                    ),\
                    users=[\
                        resources_pb2.User(\
                            id=REVIEWER_USER_ID\
                        )\
                    ]\
                )\
            )\
        ]
    ),
    metadata=metadata
)

if post_tasks_response.status.code != status_code_pb2.SUCCESS:
    print(post_tasks_response.status)
    raise Exception('Post tasks failed, status: ' + post_tasks_response.status.description)
```

```javascript
<!-- index.html file -->

<script>
  ///////////////////////////////////////////////////////////////////////////////
  // In this section, we set the user authentication, app ID, and details for
  // assigning a task. Change these strings to run your own example.
  //////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
  // Your PAT (Personal Access Token) can be found in the Account's Security section
  const PAT = "YOUR_PAT_HERE";
  const APP_ID = "YOUR_APP_ID_HERE";
  // Change these to assign your own task
  const CONCEPT_ID = "water";
  const WORKER_USER_ID = "WORKER_USER_ID_HERE";
  const REVIEWER_USER_ID = "REVIEWER_USER_ID_HERE";
  const DATASET_ID = "DATASET_ID_HERE";

///////////////////////////////////////////////////////////////////////////////////
  // YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
  ///////////////////////////////////////////////////////////////////////////////////

const raw = JSON.stringify({
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    tasks: [\
      {\
        type: "CONCEPTS_CLASSIFICATION",\
        name: "Annotate " + CONCEPT_ID,\
        worker: {\
          strategy: "DYNAMIC",\
          workers: [\
            {\
              user: {\
                id: WORKER_USER_ID,\
              },\
            },\
          ],\
        },\
        concepts: [\
          {\
            concept: {\
              id: CONCEPT_ID,\
            },\
          },\
        ],\
        input_source: {\
          type: "DATASET",\
          id: DATASET_ID\
        },\
        sample_ms: 1000,\
        review: {\
          strategy: "MANUAL",\
          manual_strategy_info: {\
            sample_percentage: 0.5,\
          },\
          users: [{ id: REVIEWER_USER_ID }],\
        },\
      },\
    ],
  });

const requestOptions = {
    method: "POST",
    headers: {
      Accept: "application/json",
      Authorization: "Key " + PAT,
    },
    body: raw,
  };

fetch("https://api.clarifai.com/v2/tasks", requestOptions)
    .then((response) => response.text())
    .then((result) => console.log(result))
    .catch((error) => console.log("error", error));
</script>
```

```javascript
//index.js file

///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details for
// assigning a task. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the portal under Authentification
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change these to assign your own task
const CONCEPT_ID = "water";
const WORKER_USER_ID = "WORKER_USER_ID_HERE";
const REVIEWER_USER_ID = "REVIEWER_USER_ID_HERE"; // User who will review this task
const DATASET_ID = "DATASET_ID_HERE";

/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.PostTasks({
        user_app_id: {
            "user_id": USER_ID,
            "app_id": APP_ID
        },
        tasks: [{\
            type: "CONCEPTS_CLASSIFICATION",\
            name: "Annotate " + CONCEPT_ID,\
            worker: {\
                strategy: "DYNAMIC",\
                workers: [{\
                    user: {\
                        id: WORKER_USER_ID\
                    }\
                }]\
            },\
            concepts: [{\
                concept: {\
                    id: CONCEPT_ID\
                }\
            }],\
            input_source: {\
                type: "DATASET",\
                id: DATASET_ID\
\
            },\
            sample_ms: 1000,\
            review: {\
                strategy: "MANUAL",\
                manual_strategy_info: {\
                    sample_percentage: 0.5\
                },\
                users: [{\
                    id: REVIEWER_USER_ID\
                }]\
            }\
        }]

},
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

if (response.status.code !== 10000) {
            console.error('Post tasks failed, status:', response.status);
            throw new Error("Post tasks failed, status: " + response.status.description);
        }
    }
);
```

```java
package com.clarifai.example;

import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.StatusCode;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;

public class ClarifaiExample {

///////////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and details for
    // assigning a task. Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    // Change these to assign your own task
    static final String CONCEPT_ID = "water";
    static final String WORKER_USER_ID = "WORKER_USER_ID_HERE";
    static final String REVIEWER_USER_ID = "REVIEWER_USER_ID_HERE"; // User who will review this task
    static final String DATASET_ID = "DATASET_ID_HERE";

//////////////////////////////////////////////////////////////////////////////////
    // YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
    //////////////////////////////////////////////////////////////////////////////////

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

MultiTaskResponse postTasksResponse = stub.postTasks(
            PostTasksRequest.newBuilder()
                .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID).build())
                .addTasks(Task.newBuilder()
                    .setType(Task.TaskType.CONCEPTS_CLASSIFICATION)
                    .setName("Annotate " + CONCEPT_ID)
                    .setWorker(TaskWorker.newBuilder()
                        .setStrategy(TaskWorker.TaskWorkerStrategy.DYNAMIC)
                        .addWorkers(Worker.newBuilder()
                            .setUser(User.newBuilder()
                                .setId(WORKER_USER_ID)
                                .build()
                            )
                        )
                        .build()
                    )
                    .addConcepts(TaskConcept.newBuilder()
                        .setConcept(Concept.newBuilder()
                            .setId(CONCEPT_ID)
                            .build()
                        )
                        .build()
                    )
                    .setInputSource(TaskInputSource.newBuilder()
                        .setType(TaskInputSource.TaskInputSourceType.DATASET)
                        .setId(DATASET_ID)
                        .build()
                    )
                    .setSampleMs(1000)
                    .setReview(TaskReview.newBuilder()
                        .setStrategy(TaskReview.TaskReviewStrategy.MANUAL)
                        .setManualStrategyInfo(TaskReviewManualStrategyInfo.newBuilder()
                            .setSamplePercentage((float) 0.5)
                            .build()
                        )
                        .addUsers(User.newBuilder()
                            .setId(REVIEWER_USER_ID)
                            .build()
                        )
                        .build()
                    )
                    .build()
                )
                .build()
        );

if (postTasksResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("Post model outputs failed, status: " + postTasksResponse.getStatus());
        }
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

/////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details for
// assigning a task. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to assign your own task
$CONCEPT_ID = "water";
$WORKER_USER_ID = "WORKER_USER_ID_HERE";
$REVIEWER_USER_ID = "REVIEWER_USER_ID_HERE"; // User who will review this task
$DATASET_ID = "DATASET_ID_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\PostTasksRequest;
use Clarifai\Api\TASK;
use Clarifai\Api\User;
use Clarifai\Api\TaskWorker;
use Clarifai\Api\TaskConcept;
use Clarifai\Api\Concept;
use Clarifai\Api\Worker;
use Clarifai\Api\TaskInputSource;
use Clarifai\Api\TaskReviewManualStrategyInfo;
use Clarifai\Api\TaskReview;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->PostTasks(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new PostTasksRequest([\
            "user_app_id" => $userDataObject,\
            "tasks" => [\
                new Task([\
                    "type" => 1, // integer value 1 for "CONCEPTS_CLASSIFICATION" type. Refer here https://github.com/Clarifai/clarifai-go-grpc/blob/master/proto/clarifai/api/resources.pb.go\
                    "name" => "Annotate " . $CONCEPT_ID,\
                    "worker" => new TaskWorker([\
                        "strategy" => 4, // integer value 4 for "DYNAMIC" strategy\
                        "workers" => [\
                            new Worker([\
                                "user" => new User([\
                                    "id" => $WORKER_USER_ID\
                                ])\
                            ]),\
                        ],\
                    ]),\
                    "concepts" => [\
                        new TaskConcept([\
                            "concept" => new Concept([\
                                "id" => $CONCEPT_ID,\
                            ]),\
                        ]),\
                    ],\
                    "input_source" => new TaskInputSource([\
                        "type" => 3, // integer value 1 for "DATASET" strategy\
                        "id" => $DATASET_ID\
                    ]),\
                    "sample_ms" => 1000,\
                    "review" => new TaskReview([\
                        "strategy" => 2, // integer value 2 for "MANUAL" strategy\
                        "manual_strategy_info" => new TaskReviewManualStrategyInfo(\
                            [\
                                "sample_percentage" => 0.5,\
                            ]\
                        ),\
                        "users" => [\
                            new User([\
                                "id" => $REVIEWER_USER_ID,\
                            ]),\
                        ],\
                    ]),\
                ]),\
            ],\
        ]),
        $metadata
    )
    ->wait();

// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
    throw new Exception("Error: {$status->details}");
}

// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
    throw new Exception(
        "Failure response: " .
            $response->getStatus()->getDescription() .
            " " .
            $response->getStatus()->getDetails()
    );
}

?>
```

```bash
curl -X POST "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
  -d '{
      "tasks": [\
          {\
              "type": "CONCEPTS_CLASSIFICATION",\
              "name": "Annotate CONCEPT_ID_HERE",\
              "worker": {\
                  "strategy": "DYNAMIC",\
                  "workers": [\
                      {\
                          "user": {\
                              "id": "WORKER_USER_ID_HERE"\
                          }\
                      }\
                  ]\
              },\
              "concepts": [\
                  {\
                      "concept": {\
                          "id": "CONCEPT_ID_HERE"\
                      }\
                  }\
              ],\
              "input_source": {\
                  "type": "DATASET",\
                  "id": "DATASET_ID_HERE"\
              },\
              "sample_ms": 1000,\
              "review": {\
                  "strategy": "MANUAL",\
                  "manual_strategy_info": {\
                      "sample_percentage": 0.5\
                  },\
                  "users": [\
                      {\
                          "id": "REVIEWER_USER_ID_HERE"\
                      }\
                  ]\
              }\
          }\
      ]
  }'
```

### Task With Consensus Review [​](https://docs.clarifai.com/create/labeling/api/tasks/\#task-with-consensus-review "Direct link to Task With Consensus Review")

You can also create tasks with `CONSENSUS` review strategy. When enough workers label an input in the same way, it will automatically be approved, with no need for the reviewer to spend time to check. In this way, the reviewer will be able to focus on the inputs where the workers don't agree.

Note that an approval threshold must be set. It is the number of labelers that need to agree in order to automatically approve an annotation.

For example, in case of 3 workers and `approval_threshold` set to 2, if an input is labeled in the same way by 2 workers, they form a majority and the group reaches a consensus.

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#################################################################################
# In this section, we set the user authentication, app ID, and details for
# creating a task. Change these strings to run your own example.
#################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to create your own task with consensus review
CONCEPT_ID = 'water'
USER_ID_1 = 'USER_ID_1_HERE'
USER_ID_2 = 'USER_ID_2_HERE'
USER_ID_3 = 'USER_ID_3_HERE'
USER_ID_4 = 'USER_ID_4_HERE'

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
from google.protobuf.struct_pb2 import Struct

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

params = Struct()
params.update({
    USER_ID_1: 1,
    USER_ID_2: 1,
    USER_ID_3: 1
})

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

post_tasks_response = stub.PostTasks(
    service_pb2.PostTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        tasks=[\
            resources_pb2.Task(\
                type='CONCEPTS_CLASSIFICATION',\
                name='Annotate ' + CONCEPT_ID,\
                worker=resources_pb2.TaskWorker(\
                    strategy='PARTITIONED',\
                    workers=[\
                        resources_pb2.Worker(user=resources_pb2.User(id=USER_ID_1)),\
                        resources_pb2.Worker(user=resources_pb2.User(id=USER_ID_2)),\
                        resources_pb2.Worker(user=resources_pb2.User(id=USER_ID_3))\
                    ],\
                    partitioned_strategy_info=resources_pb2.TaskWorkerPartitionedStrategyInfo(\
                        type='WEIGHTED',\
                        workers_per_input=3,\
                        weights=params\
                    )\
                ),\
                concepts=[\
                    resources_pb2.TaskConcept(\
                        concept=resources_pb2.Concept(id=CONCEPT_ID)\
                    )\
                ],\
                input_source=resources_pb2.TaskInputSource(type='ALL_INPUTS'),\
                sample_ms=1000,\
                review=resources_pb2.TaskReview(\
                    strategy='CONSENSUS',\
                    consensus_strategy_info=resources_pb2.TaskReviewConsensusStrategyInfo(\
                        approval_threshold=2\
                    ),\
                    users=[resources_pb2.User(id=USER_ID_4)]\
                )\
            )\
        ]
    ),
    metadata=metadata
)

```javascript
<!--index.html file-->

<script>
  ///////////////////////////////////////////////////////////////////////////////
  // In this section, we set the user authentication, app ID, and details for
  // creating a task. Change these strings to run your own example.
  //////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
  // Your PAT (Personal Access Token) can be found in the Account's Security section
  const PAT = "YOUR_PAT_HERE";
  const APP_ID = "YOUR_APP_ID_HERE";
  // Change these to create your own task with consensus review
  const CONCEPT_ID = "water";
  const USER_ID_1 = "USER_ID_1_HERE";
  const USER_ID_2 = "USER_ID_2_HERE";
  const USER_ID_3 = "USER_ID_3_HERE";
  const USER_ID_4 = "USER_ID_4_HERE";

const raw = JSON.stringify({
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    tasks: [\
      {\
        type: "CONCEPTS_CLASSIFICATION",\
        name: "Annotate " + CONCEPT_ID,\
        worker: {\
          strategy: "PARTITIONED",\
          workers: [\
            {\
              user: {\
                id: USER_ID_1\
              },\
            },\
            {\
              user: {\
                id: USER_ID_2\
              },\
            },\
            {\
              user: {\
                id: USER_ID_3\
              },\
            }\
          ],\
          partitioned_strategy_info: {\
            type: "WEIGHTED",\
            workers_per_input: 3,\
            weights: {\
              [USER_ID_1]: 1,\
              [USER_ID_2]: 1,\
              [USER_ID_3]: 1,\
            },\
          },\
        },\
        concepts: [\
          {\
            concept: {\
              id: CONCEPT_ID,\
            },\
          },\
        ],\
        input_source: {\
          type: "ALL_INPUTS",\
        },\
        sample_ms: 1000,\
        review: {\
          strategy: "CONSENSUS",\
          consensus_strategy_info: {\
            approval_threshold: 2,\
          },\
          users: [{ id: USER_ID_4 }],\
        },\
      },\
    ],
  });

const requestOptions = {
    method: "POST",
    headers: {
      Accept: "application/json",
      Authorization: "Key " + PAT,
    },
    body: raw,
  };

```javascript
//index.js file

///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details for
// creating a task. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////////////

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.PostTasks(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },

tasks: [\
      {\
        type: "CONCEPTS_CLASSIFICATION",\
        name: "Annotate " + CONCEPT_ID,\
        worker: {\
          strategy: "PARTITIONED",\
          workers: [\
            {\
              user: {\
                id: USER_ID_1\
              },\
            },\
            {\
              user: {\
                id: USER_ID_2\
              },\
            },\
            {\
              user: {\
                id: USER_ID_3\
              },\
            },\
          ],\
          partitioned_strategy_info: {\
            type: "WEIGHTED",\
            workers_per_input: 3,\
            weights: {\
              [USER_ID_1]: 1,\
              [USER_ID_2]: 1,\
              [USER_ID_3]: 1,\
            },\
          },\
        },\
        concepts: [\
          {\
            concept: {\
              id: CONCEPT_ID,\
            },\
          },\
        ],\
        input_source: {\
          type: "ALL_INPUTS",\
        },\
        sample_ms: 1000,\
        review: {\
          strategy: "CONSENSUS",\
          consensus_strategy_info: {\
            approval_threshold: 2,\
          },\
          users: [{ id: USER_ID_4 }],\
        },\
      },\
    ],
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      console.error("Post tasks failed, status:", response.status);
      throw new Error(
        "Post tasks failed, status: " + response.status.description
      );
    }
  }
);
```

```java
package com.clarifai.example;

import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.StatusCode;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;

public class ClarifaiExample {

///////////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and details for
    // creating a task. Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    // Change these to create your own task with consensus review
    static final String CONCEPT_ID = "water";
    static final String USER_ID_1 = "USER_ID_1_HERE";
    static final String USER_ID_2 = "USER_ID_2_HERE";
    static final String USER_ID_3 = "USER_ID_3_HERE";
    static final String USER_ID_4 = "USER_ID_4_HERE";

///////////////////////////////////////////////////////////////////////////////////////
    // YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
    ///////////////////////////////////////////////////////////////////////////////////////

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

Struct.Builder params = Struct.newBuilder()
            .putFields(USER_ID_1, Value.newBuilder().setNumberValue(1).build())
            .putFields(USER_ID_2, Value.newBuilder().setNumberValue(1).build())
            .putFields(USER_ID_3, Value.newBuilder().setNumberValue(1).build());

MultiTaskResponse postTasksResponse = stub.postTasks(
            PostTasksRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID).build())
            .addTasks(Task.newBuilder()
                .setType(Task.TaskType.CONCEPTS_CLASSIFICATION)
                .setName("Annotate " + CONCEPT_ID)
                .setWorker(TaskWorker.newBuilder()
                    .setStrategy(TaskWorker.TaskWorkerStrategy.PARTITIONED)
                    .addWorkers(Worker.newBuilder()
                        .setUser(User.newBuilder()
                            .setId(USER_ID_1)
                            .build()
                        )
                        .setUser(User.newBuilder()
                            .setId(USER_ID_2)
                            .build()
                        )
                        .setUser(User.newBuilder()
                            .setId(USER_ID_3)
                            .build()
                        )
                    )

.setPartitionedStrategyInfo(TaskWorkerPartitionedStrategyInfo.newBuilder()
                        .setType(TaskWorkerPartitionedStrategyInfo.TaskWorkerPartitionedStrategy.WEIGHTED)
                        .setWorkersPerInput(3)
                        .setWeights(params)
                        .build()
                    )
                    .build()
                )
                .addConcepts(TaskConcept.newBuilder()
                    .setConcept(Concept.newBuilder()
                        .setId(CONCEPT_ID)
                        .build()
                    )
                    .build()
                )
                .setInputSource(TaskInputSource.newBuilder()
                    .setType(TaskInputSource.TaskInputSourceType.ALL_INPUTS)
                    .build()
                )
                .setSampleMs(1000)
                .setReview(TaskReview.newBuilder()
                    .setStrategy(TaskReview.TaskReviewStrategy.CONSENSUS)
                    .setConsensusStrategyInfo(TaskReviewConsensusStrategyInfo.newBuilder().setApprovalThreshold(2))
                    .addUsers(User.newBuilder().setId(USER_ID_4))
                    .build()
                )
                .build()
            )
            .build()
        );

if (postTasksResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("Post tasks outputs failed, status: " + postTasksResponse.getStatus());
        }
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

/////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details for
// creating a task. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to create your own task with consensus review
$CONCEPT_ID = "water";
$USER_ID_1 = "USER_ID_1_HERE";
$USER_ID_2 = "USER_ID_2_HERE";
$USER_ID_3 = "USER_ID_3_HERE";
$USER_ID_4 = "USER_ID_4_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\PostTasksRequest;
use Clarifai\Api\TASK;
use Clarifai\Api\User;
use Clarifai\Api\TaskWorker;
use Clarifai\Api\Worker;
use Clarifai\Api\TaskConcept;
use Clarifai\Api\Concept;
use Clarifai\Api\TaskInputSource;
use Clarifai\Api\TaskWorkerPartitionedStrategyInfo;
use Clarifai\Api\TaskReviewConsensusStrategyInfo;
use Clarifai\Api\TaskReview;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
use Google\Protobuf\Struct;
use Google\Protobuf\Value;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// create Struct instance
$params = new Struct();
$params->getFields()[$USER_ID_1] = (new Value())->setNumberValue(1);
$params->getFields()[$USER_ID_2] = (new Value())->setNumberValue(1);
$params->getFields()[$USER_ID_3] = (new Value())->setNumberValue(1);

?>
```

```bash
curl -X POST "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "tasks": [\
      {\
        "type": "CONCEPTS_CLASSIFICATION",\
        "name": "Annotate CONCEPT_ID_HERE",\
        "worker": {\
          "strategy": "PARTITIONED",\
          "workers": [\
            {\
              "user": {\
                "id": "USER_ID_1_HERE"\
              }\
            },\
            {\
              "user": {\
                "id": "USER_ID_2_HERE"\
              }\
            },\
            {\
              "user": {\
                "id": "USER_ID_3_HERE"\
              }\
            }\
          ],\
          "partitioned_strategy_info": {\
            "type": "WEIGHTED",\
            "workers_per_input": 3,\
            "weights": {\
              "USER_ID_1_HERE": 1,\
              "USER_ID_2_HERE": 1,\
              "USER_ID_3_HERE": 1\
            }\
          }\
        },\
        "concepts": [\
          {\
            "concept": {\
              "id": "CONCEPT_ID_HERE"\
            }\
          }\
        ],\
        "input_source": {\
          "type": "ALL_INPUTS"\
        },\
        "sample_ms": 1000,\
        "review": {\
          "strategy": "CONSENSUS",\
          "consensus_strategy_info": {\
            "approval_threshold": 2\
          },\
          "users": [\
            {\
              "id": "USER_ID_4_HERE"\
            }\
          ]\
        }\
      }\
    ]
  }'
```

### Auto-Annotation Task [​](https://docs.clarifai.com/create/labeling/api/tasks/\#auto-annotation-task "Direct link to Auto-Annotation Task")

You can create an auto-annotation task and automatically label the inputs in your dataset. You need to specify a model or a workflow you want to use its predictions to automatically generate annotations or labels for your data.

tip

You can learn how to perform auto-annotation via the UI [here](https://docs.clarifai.com/portal-guide/annotate/auto-annotation).

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
##########################################################################################
# In this section, we set the user authentication, app ID, and auto-annotation details.
# Change these strings to run your own example.
##########################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to create your own auto-annotation task
MODEL_ID = 'MODEL_ID_HERE'
MODEL_VERSION_ID = 'MODEL_VERSION_ID_HERE'
CONCEPT_ID = 'CONCEPT_ID_HERE'
DATASET_ID = 'DATASET_ID_HERE'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

post_tasks_response = stub.PostTasks(
    service_pb2.PostTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        tasks=[\
            resources_pb2.Task(\
                type='TYPE_NOT_SET',\
                name='Auto-Annotate ' + CONCEPT_ID,\
                worker=resources_pb2.TaskWorker(\
                    strategy='FULL',\
                    workers=[\
                        resources_pb2.Worker(\
                            model=resources_pb2.Model(\
                                id=MODEL_ID,\
                                model_version=resources_pb2.ModelVersion(\
                                    id=MODEL_VERSION_ID\
                                )\
                            )\
                        )\
                    ]\
                ),\
                concepts=[\
                    resources_pb2.TaskConcept(\
                        concept=resources_pb2.Concept(\
                            id=CONCEPT_ID\
                        ),\
                        auto_annotation_config=resources_pb2.TaskConceptAutoAnnotationConfig(\
                            annotation_data_types=1,\
                            threshold_range=resources_pb2.ThresholdRange(\
                                is_lower_inclusive=True,\
                                is_upper_inclusive=True,\
                                lower=0.7,\
                                upper=0.999\
                            ),\
                            status_code=24150\
                        )\
                    )\
                ],\
                input_source=resources_pb2.TaskInputSource(\
                    type='DATASET',\
                    id=DATASET_ID\
                ),\
                sample_ms=1000,\
                review=resources_pb2.TaskReview(\
                    strategy='NONE'\
                )\
            )\
        ]
    ),
    metadata=metadata
)

if post_tasks_response.status.code != status_code_pb2.SUCCESS:
    print(post_tasks_response.status)
    raise Exception("Post tasks failed, status: " + post_tasks_response.status.description)
```

```javascript
<script>
    /////////////////////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and auto-annotation details.
    // Change these strings to run your own example.
    ////////////////////////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = "YOUR_PAT_HERE";
    const APP_ID = "YOUR_APP_ID_HERE";
    // Change these to create your own auto-annotation task
    const MODEL_ID = "MODEL_ID_HERE";
    const MODEL_VERSION_ID = "MODEL_VERSION_ID_HERE";
    const CONCEPT_ID = "CONCEPT_ID_HERE";
    const DATASET_ID = "DATASET_ID_HERE";

const raw = JSON.stringify({
        "user_app_id": {
            "user_id": USER_ID,
            "app_id": APP_ID
        },
        "tasks": [\
            {\
                "type": "TYPE_NOT_SET",\
                "name": "Auto-Annotate " + CONCEPT_ID,\
                "worker": {\
                    "strategy": "FULL",\
                    "workers": [\
                        {\
                            "model": {\
                                "id": MODEL_ID,\
                                "model_version": {\
                                    "id": MODEL_VERSION_ID\
                                }\
                            }\
                        }\
                    ]\
                },\
                "concepts": [\
                    {\
                        "concept": {\
                            "id": CONCEPT_ID\
                        },\
                        "auto_annotation_config": {\
                            "annotation_data_types": 1,\
                            "threshold_range": {\
                                "is_lower_inclusive": true,\
                                "is_upper_inclusive": true,\
                                "lower": 0.7,\
                                "upper": 0.999\
                            },\
                            "status_code": 24150\
                        }\
                    }\
                ],\
                "input_source": {\
                    "type": "DATASET",\
                    "id": DATASET_ID\
                },\
                "sample_ms": 1000,\
                "review": {\
                    "strategy": "NONE"\
                }\
            }\
        ]
    });

const requestOptions = {
        method: "POST",
        headers: {
            "Accept": "application/json",
            "Authorization": "Key " + PAT
        },
        body: raw
    };

fetch("https://api.clarifai.com/v2/tasks", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log("error", error));
</script>
```

```javascript
//index.js file

/////////////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and auto-annotation details.
// Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////////////////

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.PostTasks(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID
    },
    tasks: [\
      {\
        type: "TYPE_NOT_SET",\
        name: "Auto-Annotate " + CONCEPT_ID,\
        worker: {\
          strategy: "FULL",\
          workers: [\
            {\
              model: {\
                id: MODEL_ID,\
                model_version: {\
                  id: MODEL_VERSION_ID\
                },\
              },\
            },\
          ],\
        },\
        concepts: [\
          {\
            concept: {\
              id: CONCEPT_ID\
            },\
            auto_annotation_config: {\
              annotation_data_types: 1,\
              threshold_range: {\
                is_lower_inclusive: true,\
                is_upper_inclusive: true,\
                lower: 0.7,\
                upper: 0.999\
              },\
              status_code: 24150\
            },\
          },\
        ],\
        input_source: {\
          type: "DATASET",\
          id: DATASET_ID\
        },\
        sample_ms: 1000,\
        review: {\
          strategy: "NONE"\
        },\
      },\
    ],
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      console.error("Post tasks failed, status:", response.status);
      throw new Error("Post tasks failed, status: " + response.status.description);
    }
  }
);
```

```java
package com.clarifai.example;

public class ClarifaiExample {

////////////////////////////////////////////////////////////////////////////////////////////////////
  // In this section, we set the user authentication, app ID, and auto-annotation details.
  // Change these strings to run your own example.
  //////////////////////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
  // Your PAT (Personal Access Token) can be found in the Account's Security section
  static final String PAT = "YOUR_PAT_HERE";
  static final String APP_ID = "YOUR_APP_ID_HERE";
  // Change these to create your own auto-annotation task
  static final String MODEL_ID = "MODEL_ID_HERE";
  static final String MODEL_VERSION_ID = "MODEL_VERSION_ID_HERE";
  static final String CONCEPT_ID = "CONCEPT_ID_HERE";
  static final String DATASET_ID = "DATASET_ID_HERE";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
      .withCallCredentials(new ClarifaiCallCredentials(PAT));

MultiTaskResponse postTasksResponse = stub.postTasks(
      PostTasksRequest.newBuilder()
        .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
        .addTasks(Task.newBuilder()
          .setType(Task.TaskType.TYPE_NOT_SET)
          .setName("Auto-Annotate " + CONCEPT_ID)
          .setWorker(TaskWorker.newBuilder()
            .setStrategy(TaskWorker.TaskWorkerStrategy.FULL)
            .addWorkers(Worker.newBuilder()
              .setModel(Model.newBuilder()
                .setId(MODEL_ID)
                .setModelVersion(ModelVersion.newBuilder()
                  .setId(MODEL_VERSION_ID)
                  .build()
                )
              )
              .build()
            )
            .build()
          )
          .addConcepts(TaskConcept.newBuilder()
            .setConcept(Concept.newBuilder()
              .setId(CONCEPT_ID)
              .build())
            .setAutoAnnotationConfig(TaskConceptAutoAnnotationConfig.newBuilder()
              .setAnnotationDataTypes(1)
              .setThresholdRange(ThresholdRange.newBuilder()
                .setIsLowerInclusive(true)
                .setIsUpperInclusive(true)
                .setLower((float) 0.7)
                .setUpper((float) 0.999)
                .build())
              .setStatusCodeValue(24150)
              .build()
            )
            .build())
          .setInputSource(TaskInputSource.newBuilder()
            .setType(TaskInputSource.TaskInputSourceType.DATASET)
            .setId(DATASET_ID)
            .build())
          .setSampleMs(1000)
          .setReview(TaskReview.newBuilder()
            .setStrategy(TaskReview.TaskReviewStrategy.NONE)
            .build())
          .build())
        .build()
    );

if (postTasksResponse.getStatus().getCode() != StatusCode.SUCCESS) {
      throw new RuntimeException("Post tasks failed, status: " + postTasksResponse.getStatus());
    }
  }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

///////////////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and auto-annotation details.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to create your own auto-annotation task
$MODEL_ID = "MODEL_ID_HERE";
$MODEL_VERSION_ID = "MODEL_VERSION_ID_HERE";
$CONCEPT_ID = "CONCEPT_ID_HERE";
$DATASET_ID = "DATASET_ID_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\PostTasksRequest;
use Clarifai\Api\TASK;
use Clarifai\Api\TaskWorker;
use Clarifai\Api\Worker;
use Clarifai\Api\TaskConcept;
use Clarifai\Api\TaskConceptAutoAnnotationConfig;
use Clarifai\Api\Concept;
use Clarifai\Api\ThresholdRange;
use Clarifai\Api\Model;
use Clarifai\Api\ModelVersion;
use Clarifai\Api\TaskInputSource;
use Clarifai\Api\TaskReview;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->PostTasks(
    // The request object carries the request along with the request status and other metadata related to the request itself
    new PostTasksRequest([\
        "user_app_id" => $userDataObject,\
        "tasks" => [\
            new Task([\
                "type" => 0, // integer value 0 for "TYPE_NOT_SET" type. Refer here https://github.com/Clarifai/clarifai-go-grpc/blob/master/proto/clarifai/api/resources.pb.go\
                "name" => "Auto-Annotate " . $CONCEPT_ID,\
                "worker" => new TaskWorker([\
                    "strategy" => 3, // integer value 3 for "FULL" strategy\
                    "workers" => [\
                        new Worker([\
                            "model" => new Model([\
                                "id" => $MODEL_ID,\
                                "model_version" => new ModelVersion([\
                                    "id" => $MODEL_VERSION_ID\
                                ])\
                            ])\
                        ])\
                    ]\
                ]),\
                "concepts" => [\
                    new TaskConcept([\
                        "concept" => new Concept([\
                            "id" => $CONCEPT_ID\
                        ]),\
\
                        "auto_annotation_config" => new TaskConceptAutoAnnotationConfig([\
                            "annotation_data_types" => 1,\
                            "threshold_range" => new ThresholdRange([\
                                "is_lower_inclusive" => true,\
                                "is_upper_inclusive" => true,\
                                "lower" => 0.7,\
                                "upper" => 0.999\
                            ]),\
\
                            "status_code" => 24150\
\
                        ])\
                    ])\
                ],\
                "input_source" => new TaskInputSource([\
                    "type" => 3, // integer value 1 for "DATASET" strategy\
                    "id" => $DATASET_ID\
                ]),\
                "sample_ms" => 1000,\
                "review" => new TaskReview([\
                    "strategy" => 1 // integer value 1 for "NONE" strategy\
                ]),\
            ]),\
        ],\
    ]),
    $metadata
)
->wait();

?>
```

```bash
curl -X POST "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
  -d '{
        "tasks": [\
            {\
                "type": "TYPE_NOT_SET",\
                "name": "Auto-Annotate CONCEPT_ID_HERE",\
                "worker": {\
                    "strategy": "FULL",\
                    "workers": [\
                        {\
                            "model": {\
                                "id": "MODEL_ID_HERE",\
                                "model_version": {\
                                    "id": "MODEL_VERSION_ID_HERE"\
                                }\
                            }\
                        }\
                    ]\
                },\
                "concepts": [\
                    {\
                        "concept": {\
                            "id": "CONCEPT_ID_HERE"\
                        },\
                        "auto_annotation_config": {\
                            "annotation_data_types": 1,\
                            "threshold_range": {\
                                "is_lower_inclusive": true,\
                                "is_upper_inclusive": true,\
                                "lower": 0.7,\
                                "upper": 0.999\
                            },\
                            "status_code": 24150\
                        }\
                    }\
                ],\
                "input_source": {\
                    "type": "DATASET",\
                    "id": "DATASET_ID_HERE"\
                },\
                "sample_ms": 1000,\
                "review": {\
                    "strategy": "NONE"\
                }\
            }\
        ]
  }'
```

## Get [​](https://docs.clarifai.com/create/labeling/api/tasks/\#get "Direct link to Get")

### Get Task by ID [​](https://docs.clarifai.com/create/labeling/api/tasks/\#get-task-by-id "Direct link to Get Task by ID")

You can get the details of a single task by its ID, which is automatically generated upon task creation. You can output the API response to obtain this task ID.

Alternatively, you can also locate the task ID within the [Clarifai platform's user interface](https://docs.clarifai.com/portal-guide/annotate/create-a-task#tasks-listing).

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#################################################################################
# In this section, we set the user authentication, app ID, and task ID.
# Change these strings to run your own example.
#################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change this to get a task by its ID
TASK_ID = 'c454edb9446c4de58d4fe3a66c286e55'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

get_tasks_response = stub.GetTask(
    service_pb2.GetTaskRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        task_id=TASK_ID
    ),
    metadata=metadata
)

if get_tasks_response.status.code != status_code_pb2.SUCCESS:
    print(get_tasks_response.status)
    raise Exception(f'Get task failed, status: {get_tasks_response.status.description}')

print(get_tasks_response)
```

```javascript
<!--index.html file-->

<script>
    ///////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and task ID.
    // Change these strings to run your own example.
    //////////////////////////////////////////////////////////////////////////////

const USER_ID = 'YOUR_USER_ID_HERE';
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = 'YOUR_PAT_HERE';
    const APP_ID = 'YOUR_APP_ID_HERE';
    // Change this to get a task by its ID
    const TASK_ID = '77f156b3616f40c887c765f4ccb45c87';

const requestOptions = {
        method: 'GET',
        headers: {
            'Accept': 'application/json',
            'Authorization': 'Key ' + PAT
        }
    };

fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/tasks/${TASK_ID}`, requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

</script>
```

```javascript
//index.js file

///////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and task ID.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change this to get a task by its ID
const TASK_ID = "21980d42ddc4483fa9e59e6678d6af71";

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.GetTask(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    task_id: TASK_ID,
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      throw new Error(
        "Get tasks failed, status: " + response.status.description
      );
    }
    console.log(response);
  }
);
```

```java
package com.clarifai.example;

public class ClarifaiExample {

/////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and task ID.
    // Change these strings to run your own example.
    /////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    // Change this to get a task by its ID
    static final String TASK_ID = "6e71ff53fd7d4e32a1a7026737c25cb4";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

SingleTaskResponse getTaskResponse = stub.getTask(
            GetTaskRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
            .setTaskId(TASK_ID)
            .build()
        );

if (getTaskResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("Get tasks failed, status: " + getTaskResponse.getStatus());
        }

System.out.println(getTaskResponse);
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

//////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and task ID.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change this to get a task by its ID
$TASK_ID = "21980d42ddc4483fa9e59e6678d6af71";

use Clarifai\ClarifaiClient;
use Clarifai\Api\GetTaskRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->GetTask(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new GetTaskRequest([\
            "user_app_id" => $userDataObject,\
            "task_id" => $TASK_ID,\
        ]),
        $metadata
    )
    ->wait();

print $response->serializeToJsonString();

?>
```

```bash
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks/TASK_ID_HERE" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
```

### List All Tasks [​](https://docs.clarifai.com/create/labeling/api/tasks/\#list-all-tasks "Direct link to List All Tasks")

You can get a list of tasks within your app with a `GET` call. This call supports [pagination](https://docs.clarifai.com/api-guide/advanced-topics/pagination/).

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#######################################################################
# In this section, we set the user authentication and app ID.
# Change these strings to run your own example.
#######################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

list_tasks_response = stub.ListTasks(
    service_pb2.ListTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
    ),
    metadata=metadata
)

if list_tasks_response.status.code != status_code_pb2.SUCCESS:
    print(list_tasks_response.status)
    raise Exception(f'Get task failed, status: {list_tasks_response.status.description}')

print(list_tasks_response)
```

```javascript
<!--index.html file-->

<script>
    ///////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication and app ID.
    // Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////

const USER_ID = 'YOUR_USER_ID_HERE';
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = 'YOUR_PAT_HERE';
    const APP_ID = 'YOUR_APP_ID_HERE';

const requestOptions = {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
        'Authorization': 'Key ' + PAT
      }
    };

fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/tasks`, requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));

</script>
```

```javascript
//index.js file

////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.ListTasks(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    }
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      throw new Error(
        "List tasks failed, status: " + response.status.description
      );
    }
    console.log(response);
  }
);
```

```java
package com.clarifai.example;

public class ClarifaiExample {

/////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication and app ID.
    // Change these strings to run your own example.
    /////////////////////////////////////////////////////////////////////////////////

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

MultiTaskResponse listTasksResponse = stub.listTasks(
            ListTasksRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
            .build()
        );

if (listTasksResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("List tasks failed, status: " + listTasksResponse.getStatus());
        }

System.out.println(listTasksResponse);
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

//////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\ListTasksRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListTasks(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new ListTasksRequest([\
            "user_app_id" => $userDataObject\
        ]),
        $metadata
    )
    ->wait();

print $response->serializeToJsonString();

?>
```

```bash
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \

```

### List Tasks Assigned to User [​](https://docs.clarifai.com/create/labeling/api/tasks/\#list-tasks-assigned-to-user "Direct link to List Tasks Assigned to User")

Get only the tasks assigned to a specific user for work.

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#######################################################################
# In this section, we set the user authentication, app ID, and
# worker user ID. Change these strings to run your own example.
#######################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
WORKER_USER_ID = 'WORKER_USER_ID_HERE'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

list_tasks_response = stub.ListTasks(
    service_pb2.ListTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        worker_user_ids=[WORKER_USER_ID]
    ),
    metadata=metadata
)

print(list_tasks_response)
```

```javascript
<!--index.html file-->

<script>
    ///////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and
    // worker user ID. Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////

const USER_ID = 'YOUR_USER_ID_HERE';
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = 'YOUR_PAT_HERE';
    const APP_ID = 'YOUR_APP_ID_HERE';
    const WORKER_USER_ID = 'WORKER_USER_ID_HERE';

const requestOptions = {
        method: 'GET',
        headers: {
            'Accept': 'application/json',
            'Authorization': 'Key ' + PAT
        }
    };

fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/tasks?worker_user_ids=${WORKER_USER_ID}`, requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

</script>
```

```javascript
//index.js file

////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and
// worker user ID. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
const WORKER_USER_ID = "WORKER_USER_ID_HERE";

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.ListTasks(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    worker_user_ids:[WORKER_USER_ID]
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      throw new Error(
        "List tasks failed, status: " + response.status.description
      );
    }
    console.log(response);
  }
);
```

```java
package com.clarifai.example;

public class ClarifaiExample {

///////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and
    // worker user ID. Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    static final String WORKER_USER_ID = "WORKER_USER_ID_HERE";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

MultiTaskResponse listTasksResponse = stub.listTasks(
            ListTasksRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
            .addWorkerUserIds(WORKER_USER_ID)
            .build()
        );

System.out.println(listTasksResponse);
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

//////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and
// worker user ID. Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
$WORKER_USER_ID = "WORKER_USER_ID_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\ListTasksRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListTasks(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new ListTasksRequest([\
            "user_app_id" => $userDataObject,\
            "worker_user_ids" => [$WORKER_USER_ID],\
        ]),
        $metadata
    )
    ->wait();

print $response->serializeToJsonString();

?>
```

```bash
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks?worker_user_ids=WORKER_USER_ID_HERE" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
```

### List Tasks Assigned to User for Review [​](https://docs.clarifai.com/create/labeling/api/tasks/\#list-tasks-assigned-to-user-for-review "Direct link to List Tasks Assigned to User for Review")

Get only the tasks assigned to a specific user for review.

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#######################################################################
# In this section, we set the user authentication, app ID, and
# review user ID. Change these strings to run your own example.
#######################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
REVIEW_USER_ID = 'REVIEW_USER_ID_HERE'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

list_tasks_response = stub.ListTasks(
    service_pb2.ListTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        review_user_ids=[REVIEW_USER_ID]
    ),
    metadata=metadata
)

print(list_tasks_response)
```

```javascript
<!--index.html file-->

<script>
    ///////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and
    // review user ID. Change these strings to run your own example
    ///////////////////////////////////////////////////////////////////

const USER_ID = 'YOUR_USER_ID_HERE';
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = 'YOUR_PAT_HERE';
    const APP_ID = 'YOUR_APP_ID_HERE';
    const REVIEW_USER_ID = 'REVIEW_USER_ID_HERE';

const requestOptions = {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
        'Authorization': 'Key ' + PAT
      }
    };

fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/tasks?review_user_ids=${REVIEW_USER_ID}`, requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));

</script>
```

```javascript
//index.js file

////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and
// review user ID. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
const REVIEW_USER_ID = "REVIEW_USER_ID_HERE";

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.ListTasks(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    review_user_ids: [REVIEW_USER_ID]
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      throw new Error(
        "List tasks failed, status: " + response.status.description
      );
    }
    console.log(response);
  }
);
```

```java
package com.clarifai.example;

public class ClarifaiExample {

///////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and
    // review user ID. Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    static final String REVIEW_USER_ID = "REVIEW_USER_ID_HERE";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

MultiTaskResponse listTasksResponse = stub.listTasks(
            ListTasksRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
            .addReviewUserIds(REVIEW_USER_ID)
            .build()
        );

System.out.println(listTasksResponse);
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

//////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and
// review user ID. Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
$REVIEW_USER_ID = "REVIEW_USER_ID_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\ListTasksRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListTasks(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new ListTasksRequest([\
            "user_app_id" => $userDataObject,\
            "review_user_ids" => [$REVIEW_USER_ID],\
        ]),
        $metadata
    )
    ->wait();

print $response->serializeToJsonString();

?>
```

```bash
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks?review_user_ids=REVIEW_USER_ID_HERE" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
```

## Update [​](https://docs.clarifai.com/create/labeling/api/tasks/\#update "Direct link to Update")

Currently, we only support updating a task by providing all information at once.

### Update Task [​](https://docs.clarifai.com/create/labeling/api/tasks/\#update-task "Direct link to Update Task")

- Python (gRPC)
- JavaScript (REST)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#################################################################################
# In this section, we set the user authentication, app ID, and details for
# updating a task. Change these strings to run your own example.
#################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to update your own task
CONCEPT_ID = 'water'
TASK_ID = 'd0f2fa2b61234d1cb6b66983ea021b5b'
USER_ID_1 = 'USER_ID_1_HERE'
USER_ID_2 = 'USER_ID_2_HERE'
USER_ID_3 = 'USER_ID_3_HERE'
USER_ID_4 = 'USER_ID_4_HERE'

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2, status_pb2
from google.protobuf.struct_pb2 import Struct

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

params = Struct()
params.update({
    USER_ID_1: 1,
    USER_ID_2: 1,
    USER_ID_3: 1
})

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

patch_tasks_response = stub.PatchTasks(
    service_pb2.PatchTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        action="overwrite",
        tasks=[\
            resources_pb2.Task(\
                id=TASK_ID,\
                type='CONCEPTS_CLASSIFICATION',\
                name='Annotate ' + CONCEPT_ID,\
                worker=resources_pb2.TaskWorker(\
                    strategy='PARTITIONED',\
                    users=[\
                        resources_pb2.User(id=USER_ID_1),\
                        resources_pb2.User(id=USER_ID_2),\
                        resources_pb2.User(id=USER_ID_3)\
                    ],\
                    partitioned_strategy_info=resources_pb2.TaskWorkerPartitionedStrategyInfo(\
                        type='WEIGHTED',\
                        workers_per_input=3,\
                        weights=params\
                    )\
                ),\
                concepts=[\
                    resources_pb2.TaskConcept(\
                        concept=resources_pb2.Concept(id=CONCEPT_ID)\
                    )\
                ],\
                input_source=resources_pb2.TaskInputSource(type='ALL_INPUTS'),\
                sample_ms=1000,\
                review=resources_pb2.TaskReview(\
                    strategy='CONSENSUS',\
                    consensus_strategy_info=resources_pb2.TaskReviewConsensusStrategyInfo(\
                        approval_threshold=2\
                    ),\
                    users=[resources_pb2.User(id=USER_ID_4)]\
                ),\
                status=status_pb2.Status(\
                    code='TASK_DONE'\
                )\
            )\
        ]
    ),
    metadata=metadata
)

if patch_tasks_response.status.code != status_code_pb2.SUCCESS:
    print(patch_tasks_response.status)
    raise Exception('Patch tasks failed, status: ' + patch_tasks_response.status.description)
```

```javascript
<!--index.html file-->

<script>
    ///////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and details for
    // updating a task. Change these strings to run your own example.
    //////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = "YOUR_PAT_HERE";
    const APP_ID = "YOUR_APP_ID_HERE";
    // Change these to update your own task
    const TASK_ID = "c454edb9446c4de58d4fe3a66c286e55";
    const CONCEPT_ID = "water";
    const USER_ID_1 = "USER_ID_1_HERE";
    const USER_ID_2 = "USER_ID_2_HERE";
    const USER_ID_3 = "USER_ID_3_HERE";
    const USER_ID_4 = "USER_ID_4_HERE";

const raw = JSON.stringify({
      user_app_id: {
        user_id: USER_ID,
        app_id: APP_ID,
      },
      action: "overwrite",
      tasks: [\
        {\
          id: TASK_ID,\
          type: "CONCEPTS_CLASSIFICATION",\
          name: "Annotate " + CONCEPT_ID,\
          worker: {\
            strategy: "PARTITIONED",\
            users: [{ id: USER_ID_1 }, { id: USER_ID_2 }, { id: USER_ID_3 }],\
            partitioned_strategy_info: {\
              type: "WEIGHTED",\
              workers_per_input: 3,\
              weights: {\
                [USER_ID_1]: 1,\
                [USER_ID_2]: 1,\
                [USER_ID_3]: 1,\
              },\
            },\
          },\
          concept_ids: [CONCEPT_ID],\
          input_source: {\
            type: "ALL_INPUTS",\
          },\
          sample_ms: 1000,\
          review: {\
            strategy: "CONSENSUS",\
            consensus_strategy_info: {\
              approval_threshold: 2,\
            },\
            users: [{ id: USER_ID_4 }],\
          },\
          status: {\
            code: "TASK_DONE",\
          },\
        },\
      ],
    });

const requestOptions = {
      method: "PATCH",
      headers: {
        Accept: "application/json",
        Authorization: "Key " + PAT,
      },
      body: raw,
    };

fetch("https://api.clarifai.com/v2/tasks", requestOptions)
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.log("error", error));
  </script>

```

```java
package com.clarifai.example;

import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.Status;
import com.clarifai.grpc.api.status.StatusCode;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;

public class ClarifaiExample {

///////////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and details for
    // updating a task. Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    // Change these to update your own task
    static final String CONCEPT_ID = "water";
    static final String TASK_ID = "8331bac5db8e445591ce69e351ea67fe";
    static final String USER_ID_1 = "USER_ID_1_HERE";
    static final String USER_ID_2 = "USER_ID_2_HERE";
    static final String USER_ID_3 = "USER_ID_3_HERE";
    static final String USER_ID_4 = "USER_ID_4_HERE";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

MultiTaskResponse patchTasksResponse = stub.patchTasks(
            PatchTasksRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID).build())
            .setAction("overwrite")
            .addTasks(Task.newBuilder()
                .setId(TASK_ID)
                .setType(Task.TaskType.CONCEPTS_CLASSIFICATION)
                .setName("Annotate " + CONCEPT_ID)
                .setWorker(TaskWorker.newBuilder()
                    .setStrategy(TaskWorker.TaskWorkerStrategy.PARTITIONED)
                    .addUsers(User.newBuilder().setId(USER_ID_1))
                    .addUsers(User.newBuilder().setId(USER_ID_2))
                    .addUsers(User.newBuilder().setId(USER_ID_3))
                    .setPartitionedStrategyInfo(TaskWorkerPartitionedStrategyInfo.newBuilder()
                        .setType(TaskWorkerPartitionedStrategyInfo.TaskWorkerPartitionedStrategy.WEIGHTED)
                        .setWorkersPerInput(3)
                        .setWeights(params)
                        .build()
                    )
                    .build()
                )
                .addConcepts(TaskConcept.newBuilder()
                    .setConcept(Concept.newBuilder()
                        .setId(CONCEPT_ID)
                        .build()
                    )
                    .build()
                )
                .setInputSource(TaskInputSource.newBuilder()
                    .setType(TaskInputSource.TaskInputSourceType.ALL_INPUTS)
                    .build()
                )
                .setSampleMs(1000)
                .setReview(TaskReview.newBuilder()
                    .setStrategy(TaskReview.TaskReviewStrategy.CONSENSUS)
                    .setConsensusStrategyInfo(TaskReviewConsensusStrategyInfo.newBuilder().setApprovalThreshold(2))
                    .addUsers(User.newBuilder().setId(USER_ID_4))
                    .build()
                )
                .setStatus(Status.newBuilder().setCode(StatusCode.TASK_DONE))
                .build()
            )
            .build()
        );

if (patchTasksResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("Patch tasks request failed, status: " + patchTasksResponse.getStatus());
        }
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

/////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details for
// updating a task. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to update your own task
$CONCEPT_ID = "water";
$TASK_ID = "8264c89ced3b4e7ebafdaa9f31f2fb59";
$USER_ID_1 = "USER_ID_1_HERE";
$USER_ID_2 = "USER_ID_2_HERE";
$USER_ID_3 = "USER_ID_3_HERE";
$USER_ID_4 = "USER_ID_4_HERE";

use Clarifai\ClarifaiClient;
use Clarifai\Api\PatchTasksRequest;
use Clarifai\Api\TASK;
use Clarifai\Api\User;
use Clarifai\Api\TaskWorker;
use Clarifai\Api\TaskConcept;
use Clarifai\Api\Concept;
use Clarifai\Api\TaskInputSource;
use Clarifai\Api\TaskWorkerPartitionedStrategyInfo;
use Clarifai\Api\TaskReviewConsensusStrategyInfo;
use Clarifai\Api\TaskReview;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\Status\Status;
use Clarifai\Api\UserAppIDSet;
use Google\Protobuf\Struct;
use Google\Protobuf\Value;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->PatchTasks(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new PatchTasksRequest([\
            "user_app_id" => $userDataObject,\
            "action" => "overwrite",\
            "tasks" => [\
                new Task([\
                    "id" => $TASK_ID,\
                    "type" => 1, // integer value 1 for "CONCEPTS_CLASSIFICATION" type\
                    "name" => "Annotate " . $CONCEPT_ID,\
                    "worker" => new TaskWorker([\
                        "strategy" => 2, // integer value 2 for "PARTITIONED" strategy\
                        "users" => [\
                            new User([\
                                "id" => $USER_ID_1\
                            ]),\
                            new User([\
                                "id" => $USER_ID_2\
                            ]),\
                            new User([\
                                "id" => $USER_ID_3\
                            ]),\
                        ],\
                        "partitioned_strategy_info" => new TaskWorkerPartitionedStrategyInfo(\
                            [\
                                "type" => 2, // integer value 2 for "WEIGHTED" strategy\
                                "workers_per_input" => 3,\
                                "weights" => $params\
                            ]\
                        ),\
                    ]),\
                    "concepts" => [\
                        new TaskConcept([\
                            "concept" => new Concept([\
                                "id" => $CONCEPT_ID\
                            ]),\
                        ]),\
                    ],\
                    "input_source" => new TaskInputSource([\
                        "type" => 1, // integer value 1 for "ALL_INPUTS" strategy\
                    ]),\
                    "sample_ms" => 1000,\
                    "review" => new TaskReview([\
                        "strategy" => 3, // integer value 1 for "CONSENSUS" strategy\
                        "consensus_strategy_info" => new TaskReviewConsensusStrategyInfo(\
                            [\
                                "approval_threshold" => 2\
                            ]\
                        ),\
                        "users" => [\
                            new User([\
                                "id" => $USER_ID_4\
                            ]),\
                        ],\
                    ]),\
                    "status" => new Status([\
                        "code" => 54002 // for "TASK_DONE"\
                    ])\
                ]),\
            ],\
        ]),
        $metadata
    )
    ->wait();

?>
```

```bash
curl -X PATCH "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
  -d '{
        "action": "overwrite",
        "tasks": [\
            {\
                "id": "TASK_ID_HERE",\
                "type": "CONCEPTS_CLASSIFICATION",\
                "name": "Annotate CONCEPT_ID_HERE",\
                "worker": {\
                    "strategy": "PARTITIONED",\
                    "users": [\
                        {"id": "USER_ID_1_HERE"},\
                        {"id": "USER_ID_2_HERE"},\
                        {"id": "USER_ID_3_HERE"}\
                    ],\
                    "partitioned_strategy_info": {\
                        "type": "WEIGHTED",\
                        "workers_per_input": 3,\
                        "weights": {\
                            "USER_ID_1_HERE": 1,\
                            "USER_ID_2_HERE": 1,\
                            "USER_ID_3_HERE": 1\
                        }\
                    }\
                },\
                "concept_ids": [\
                    "CONCEPT_ID_HERE"\
                ],\
                "input_source": {\
                    "type": "ALL_INPUTS"\
                },\
                "sample_ms": 1000,\
                "review": {\
                    "strategy": "CONSENSUS",\
                    "consensus_strategy_info": {\
                        "approval_threshold": 2\
                    },\
                    "users": [\
                        {"id": "USER_ID_4_HERE"}\
                    ]\
                },\
                "status": {\
                    "code": "TASK_DONE"\
                }\
            }\
        ]
    }'
```

## Task Annotations [​](https://docs.clarifai.com/create/labeling/api/tasks/\#task-annotations "Direct link to Task Annotations")

In order to keep track of each user's work assigned to a task, all the annotations of this user related to this task should be linked to the task ID.

Therefore, when a user creates an annotation, the task ID should be provided as below:

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
####################################################################################
# In this section, we set the user authentication, app ID, and the details for
# performing task annotations. Change these strings to run your own example.
###################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to perform your own task annotations
INPUT_ID = 'c99f1b557d1d43d1916b46f8ce4a0487'
CONCEPT_ID_1 = 'tree'
CONCEPT_ID_2 = 'water'
TASK_ID = 'c37aed156e474e03bb5246576d9f48fd'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

params = Struct()
params['task_id'] = TASK_ID

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

post_task_annotations_response = stub.PostAnnotations(
    service_pb2.PostAnnotationsRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        annotations=[\
            resources_pb2.Annotation(\
                input_id=INPUT_ID,\
                data=resources_pb2.Data(\
                    concepts=[\
                        resources_pb2.Concept(id=CONCEPT_ID_1, value=1.),  # 1 means true, this concept is present\
                        resources_pb2.Concept(id=CONCEPT_ID_2, value=0.)  # 0 means false, this concept is not present\
                    ]\
                ),\
                annotation_info=params\
            )\
        ]
    ),
    metadata=metadata
)

if post_task_annotations_response.status.code != status_code_pb2.SUCCESS:
    print(post_task_annotations_response.status)
    raise Exception('Post task annotations failed, status: ' + post_task_annotations_response.status.description)
```

```javascript
<!--index.html file-->

<script>
  //////////////////////////////////////////////////////////////////////////////////
  // In this section, we set the user authentication, app ID, and the details for
  // performing task annotations. Change these strings to run your own example.
  /////////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
  // Your PAT (Personal Access Token) can be found in the Account's Security section
  const PAT = "YOUR_PAT_HERE";
  const APP_ID = "YOUR_APP_ID_HERE";
  // Change these to perform your own task annotations
  const INPUT_ID = "c99f1b557d1d43d1916b46f8ce4a0487";
  const CONCEPT_ID_1 = "tree";
  const CONCEPT_ID_2 = "water";
  const TASK_ID = "c37aed156e474e03bb5246576d9f48fd";

const raw = JSON.stringify({
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    annotations: [\
      {\
        input_id: INPUT_ID,\
        data: {\
          concepts: [\
            {\
              id: CONCEPT_ID_1,\
              value: 1,\
            },\
            {\
              id: CONCEPT_ID_2,\
              value: 0,\
            },\
          ],\
        },\
        annotation_info: {\
          task_id: TASK_ID,\
        },\
      },\
    ],
  });

const requestOptions = {
    method: "POST",
    headers: {
      Accept: "application/json",
      Authorization: "Key " + PAT,
    },
    body: raw,
  };

fetch("https://api.clarifai.com/v2/annotations", requestOptions)
    .then((response) => response.text())
    .then((result) => console.log(result))
    .catch((error) => console.log("error", error));
</script>
```

```javascript
//index.js file

////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the details for
// performing task annotations. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change these to perform your own task annotations
const INPUT_ID = "62bb672ccbdd4e5da55b41209d1a0e9f";
const CONCEPT_ID_1 = "tree";
const CONCEPT_ID_2 = "water";
const TASK_ID = "d0f2fa2b61234d1cb6b66983ea021b5b";

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.PostAnnotations(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    annotations: [\
      {\
        input_id: INPUT_ID,\
        data: {\
          concepts: [\
            {\
              id: CONCEPT_ID_1,\
              value: 1,\
            },\
            {\
              id: CONCEPT_ID_2,\
              value: 0,\
            },\
          ],\
        },\
        annotation_info: {\
          task_id: TASK_ID,\
        },\
      },\
    ],
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      throw new Error(
        "Post annotations failed, status: " + response.status.description
      );
    }
  }
);
```

```java
package com.clarifai.example;

import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.StatusCode;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;

public class ClarifaiExample {

//////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and the details for
    // performing task annotations. Change these strings to run your own example.
    //////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    //Your PAT (Personal Access Token) can be found in the portal under Authentication
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    // Change these to perform your own task annotations
    static final String INPUT_ID = "c99f1b557d1d43d1916b46f8ce4a0487";
    static final String CONCEPT_ID_1 = "tree";
    static final String CONCEPT_ID_2 = "water";
    static final String TASK_ID = "c37aed156e474e03bb5246576d9f48fd";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

Struct.Builder params = Struct.newBuilder()
                .putFields("task_id", Value.newBuilder().setStringValue(TASK_ID).build());

MultiAnnotationResponse postAnnotationsResponse = stub.postAnnotations(
            PostAnnotationsRequest.newBuilder()
            .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
            .addAnnotations(
                Annotation.newBuilder()
                .setInputId(INPUT_ID)
                .setData(
                    Data.newBuilder().addConcepts(
                        Concept.newBuilder()
                        .setId(CONCEPT_ID_1)
                        .setValue(1f) // 1 means true, this concept is present
                        .build()
                    ).addConcepts(
                        Concept.newBuilder()
                        .setId(CONCEPT_ID_2)
                        .setValue(0f) // 0 means false, this concept is not present
                        .build()
                    )
                )
                .setAnnotationInfo(params)
                .build()
            ).build()
        );

if (postAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("Post annotations failed, status: " + postAnnotationsResponse.getStatus());
        }

}

}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details for
// performing task annotations. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to perform your own task annotations
$INPUT_ID = "62bb672ccbdd4e5da55b41209d1a0e9f";
$CONCEPT_ID_1 = "tree";
$CONCEPT_ID_2 = "water";
$TASK_ID = "d0f2fa2b61234d1cb6b66983ea021b5b";

use Clarifai\ClarifaiClient;
use Clarifai\Api\PostAnnotationsRequest;
use Clarifai\Api\Annotation;
use Clarifai\Api\Concept;
use Clarifai\Api\Data;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
use Google\Protobuf\Struct;
use Google\Protobuf\Value;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID\
]);

// create Struct instance
$params = new Struct();
$params->getFields()->offsetSet("task_id", (new Value())->setStringValue($TASK_ID));

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->PostAnnotations(
    // The request object carries the request along with the request status and other metadata related to the request itself
    new PostAnnotationsRequest([\
        "user_app_id" => $userDataObject,\
        "annotations" => [\
             new Annotation([\
                "input_id" => $INPUT_ID,\
                "data" => new Data([\
                    "concepts" => [\
                        new Concept(["id" => $CONCEPT_ID_1, "value" => 1.]),\
                        new Concept(["id" => $CONCEPT_ID_2, "value" => 0.])\
                    ]\
                    ]),\
                "annotation_info" => $params\
             ])\
        ]\
    ]),
    $metadata
)->wait();

// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
    throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
    print $response->getStatus()->getDetails();
    throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}

?>
```

```bash
curl -X POST "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
  -d '{
      "annotations": [\
        {\
          "input_id": "INPUT_ID_HERE",\
          "data": {\
            "concepts": [\
              {\
                "id": "tree",\
                "value": 1\
              },\
              {\
                "id": "water",\
                "value": 0\
              }\
            ]\
          },\
          "annotation_info": {\
            "task_id": "TASK_ID_HERE"\
          }\
        }\
      ]
    }'
```

## Delete [​](https://docs.clarifai.com/create/labeling/api/tasks/\#delete "Direct link to Delete")

You can delete a task by specifying its ID. You can also delete multiple tasks by specifying a list of their IDs.

- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL

```python
#################################################################################
# In this section, we set the user authentication, app ID, and task IDs.
# Change these strings to run your own example.
#################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to delete your own tasks
TASK_ID_1 = 'd1f2f891da9844ccafed93a18574b027'
TASK_ID_2 = 'd1f2f891da9844ccafed93a18574b027'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

delete_tasks_response = stub.DeleteTasks(
    service_pb2.DeleteTasksRequest(
        user_app_id=userDataObject,  # The userDataObject is created in the overview and is required when using a PAT
        ids=[TASK_ID_1, TASK_ID_2]

),
    metadata=metadata
)

if delete_tasks_response.status.code != status_code_pb2.SUCCESS:
    print(delete_tasks_response.status)
    raise Exception('Delete tasks failed, status: ' + delete_tasks_response.status.description)
```

```javascript
<!--index.html file-->

<script>
    ///////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and task IDs.
    // Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////

const USER_ID = 'YOUR_USER_ID_HERE';
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    const PAT = 'YOUR_PAT_HERE';
    const APP_ID = 'YOUR_APP_ID_HERE';
    // Change these to delete your own tasks
    const TASK_ID_1 = '66262884195c427595d4bca033b2114e';
    const TASK_ID_2 = '1106ba0327ed44c2b556659a58e77a48';

const raw = JSON.stringify({
        "user_app_id": {
            "user_id": USER_ID,
            "app_id": APP_ID
        },
        "ids": [TASK_ID_1, TASK_ID_2]
    });

const requestOptions = {
        method: 'DELETE',
        headers: {
            'Accept': 'application/json',
            'Authorization': 'Key ' + PAT
        },
        body: raw
    };

fetch("https://api.clarifai.com/v2/tasks", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

</script>
```

```javascript
//index.js file

///////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and task IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////

const USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change these to delete your own tasks
const TASK_ID_1 = "ccb05c3b73344a87bfa2ad18f04d793e";
const TASK_ID_2 = "584d8ef6fe184b0a91197c0590d50953";

const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);

stub.DeleteTasks(
  {
    user_app_id: {
      user_id: USER_ID,
      app_id: APP_ID,
    },
    ids: [TASK_ID_1, TASK_ID_2],
  },
  metadata,
  (err, response) => {
    if (err) {
      throw new Error(err);
    }

if (response.status.code !== 10000) {
      throw new Error(
        "Delete tasks failed, status: " + response.status.description
      );
    }
  }
);
```

```java
package com.clarifai.example;

import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.BaseResponse;
import com.clarifai.grpc.api.status.StatusCode;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;

public class ClarifaiExample {

////////////////////////////////////////////////////////////////////////////////////
    // In this section, we set the user authentication, app ID, and task IDs.
    // Change these strings to run your own example.
    ///////////////////////////////////////////////////////////////////////////////////

static final String USER_ID = "YOUR_USER_ID_HERE";
    // Your PAT (Personal Access Token) can be found in the Account's Security section
    static final String PAT = "YOUR_PAT_HERE";
    static final String APP_ID = "YOUR_APP_ID_HERE";
    // Change these to delete your own tasks
    static final String TASK_ID_1 = "d9dc9104afd84332a6dd95dd71a38d19";
    static final String TASK_ID_2 = "e2aff7156fac416e86fee02a1c1cb2f3";

public static void main(String[] args) {

V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
            .withCallCredentials(new ClarifaiCallCredentials(PAT));

BaseResponse deleteTasksResponse = stub.deleteTasks(
            DeleteTasksRequest.newBuilder()
                .setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
                .addIds(TASK_ID_1)
                .addIds(TASK_ID_2)
                .build()
        );

if (deleteTasksResponse.getStatus().getCode() != StatusCode.SUCCESS) {
            throw new RuntimeException("Delete tasks failed, status: " + deleteTasksResponse.getStatus());
        }
    }
}
```

```php
<?php

require __DIR__ . "/vendor/autoload.php";

/////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and task IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////

$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to delete your own tasks
$TASK_ID_1 = "7aceabee601c4e73b7c1f3ca1e09c1f6";
$TASK_ID_2 = "fa0c0ddcc43944da8cc66504a2b85d76";

use Clarifai\ClarifaiClient;
use Clarifai\Api\DeleteTasksRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;

$client = ClarifaiClient::grpc();

$metadata = ["Authorization" => ["Key " . $PAT]];

$userDataObject = new UserAppIDSet([\
    "user_id" => $USER_ID,\
    "app_id" => $APP_ID,\
]);

// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->DeleteTasks(
        // The request object carries the request along with the request status and other metadata related to the request itself
        new DeleteTasksRequest([\
            "user_app_id" => $userDataObject,\
            "ids" => [$TASK_ID_1, $TASK_ID_2]\
        ]),
        $metadata
    )
    ->wait();

?>
```

```bash
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/tasks" \
  -H "Authorization: Key YOUR_PAT_HERE" \
  -H "Content-Type: application/json" \
  -d '{
        "ids":["TASK_ID_HERE"]
    }'
```

- [Create](https://docs.clarifai.com/create/labeling/api/tasks/#create)
  - [Assigned Task](https://docs.clarifai.com/create/labeling/api/tasks/#assigned-task)
  - [Task With Consensus Review](https://docs.clarifai.com/create/labeling/api/tasks/#task-with-consensus-review)
  - [Auto-Annotation Task](https://docs.clarifai.com/create/labeling/api/tasks/#auto-annotation-task)
- [Get](https://docs.clarifai.com/create/labeling/api/tasks/#get)
  - [Get Task by ID](https://docs.clarifai.com/create/labeling/api/tasks/#get-task-by-id)
  - [List All Tasks](https://docs.clarifai.com/create/labeling/api/tasks/#list-all-tasks)
  - [List Tasks Assigned to User](https://docs.clarifai.com/create/labeling/api/tasks/#list-tasks-assigned-to-user)
  - [List Tasks Assigned to User for Review](https://docs.clarifai.com/create/labeling/api/tasks/#list-tasks-assigned-to-user-for-review)
- [Update](https://docs.clarifai.com/create/labeling/api/tasks/#update)
  - [Update Task](https://docs.clarifai.com/create/labeling/api/tasks/#update-task)
- [Task Annotations](https://docs.clarifai.com/create/labeling/api/tasks/#task-annotations)
- [Delete](https://docs.clarifai.com/create/labeling/api/tasks/#delete)

Build your next AI app, test and tune popular LLMs models, and much more.

[Get started for free](/content/explore/index.html)
