Task Annotations
Perform 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:
- cURL
- JavaScript (REST)
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"
}
}
]
}'
<!--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';
///////////////////////////////////////////////////////////////////////////////////
// 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
},
"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>