Delete Annotations
Before using the Python SDK, Node.js SDK, or any of our 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.
Delete Annotation by Input ID and Annotation ID
Below is an example of how to delete a single annotation by input ID and annotation ID.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
#####################################################################
# In this section, we set the user authentication, app ID, input ID,
# and annotation 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 these based on the annotation you want to delete
INPUT_ID = '53d0362a9dfa4e03b2293375e2d0db73'
ANNOTATION_ID = '300b8e39a65e4f33ae4e15e86eaf4a3b'
##########################################################################
# 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)
delete_annotation_response = stub.DeleteAnnotation(
service_pb2.DeleteAnnotationRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
input_id=INPUT_ID,
annotation_id=ANNOTATION_ID
),
metadata=metadata
)
if delete_annotation_response.status.code != status_code_pb2.SUCCESS:
print(delete_annotation_response.status)
raise Exception("Delete annotations failed, status: " + delete_annotation_response.status.description)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input ID,
// and annotation 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 these based on the annotation you want to delete
const INPUT_ID = 'c99f1b557d1d43d1916b46f8ce4a0487';
const ANNOTATION_ID = '244b8a39e51944ffb43bde7f6d33f0a7';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'DELETE',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/inputs/${INPUT_ID}/annotations/${ANNOTATION_ID}`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
///////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input ID,
// and annotation 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 these based on the annotation you want to delete
const INPUT_ID = 'c99f1b557d1d43d1916b46f8ce4a0487';
const ANNOTATION_ID = 'b65d2a9106ba448382a0cee540f7c582';
/////////////////////////////////////////////////////////////////////////////
// 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.DeleteAnnotation(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
input_id: INPUT_ID,
annotation_id: ANNOTATION_ID
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("Delete annotation failed, status: " + response.status.description);
}
}
);
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.BaseResponse;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
/////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input ID,
// and annotation 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 portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these based on the annotation you want to delete
static final String INPUT_ID = "c99f1b557d1d43d1916b46f8ce4a0487";
static final String ANNOTATION_ID = "b65d2a9106ba448382a0cee540f7c582";
///////////////////////////////////////////////////////////////////////////////////
// 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));
BaseResponse deleteAnnotationResponse = stub.deleteAnnotation(
DeleteAnnotationRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setInputId(INPUT_ID)
.setAnnotationId(ANNOTATION_ID)
.build()
);
if (deleteAnnotationResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Delete annotation failed, status: " + deleteAnnotationResponse.getStatus());
}
}
}
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/inputs/YOUR_INPUT_ID_HERE/annotations/YOUR_ANNOTATION_ID_HERE" \
-H "Authorization: Key YOUR_PAT_HERE" \
Bulk Delete Annotations by Input IDs and Annotation IDs
You can delete multiple annotations in one API call. You need to provide a list of input IDs and a list of annotation IDs. The number of input IDs has to match the number of annotation IDs.
Below is an example of how to do that.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
#######################################################################
# In this section, we set the user authentication, app ID, input IDs,
# and annotation 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 based on the annotations you want to bulk delete
INPUT_ID_1 = 'b76fe0adb0294906942f169bb1f6cacf'
INPUT_ID_2 = 'e838fac8da9d40c89f2291a6496593da'
ANNOTATION_ID_1 = '35c37cda9ad8460fae12b2b2b6a23f1d'
ANNOTATION_ID_2 = '63d69000ae3343d0b70b892ea3dcb01d'
##########################################################################
# 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)
delete_annotations_response = stub.DeleteAnnotations(
service_pb2.DeleteAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
input_ids=[INPUT_ID_1, INPUT_ID_2],
ids=[ANNOTATION_ID_1, ANNOTATION_ID_2]
),
metadata=metadata
)
if delete_annotations_response.status.code != status_code_pb2.SUCCESS:
print(delete_annotations_response.status)
raise Exception("Delete annotations failed, status: " + delete_annotations_response.status.description)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs,
// and annotation 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 based on the annotations you want to bulk delete
const INPUT_ID_1 = 'c99f1b557d1d43d1916b46f8ce4a0487';
const INPUT_ID_2 = '7c5f489bcafe43fe8a71c68091cb64ce';
const ANNOTATION_ID_1 = '6793f476f6c24712b447316ae2fc12c1';
const ANNOTATION_ID_2 = 'd703cafff61b45bbb4d8c1d9575420b3';
///////////////////////////////////////////////////////////////////////////////////
// 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
},
"input_ids": [INPUT_ID_1, INPUT_ID_2],
"ids": [ANNOTATION_ID_1, ANNOTATION_ID_2]
});
const requestOptions = {
method: 'DELETE',
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>
//index.js file
///////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs,
// and annotation 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 based on the annotations you want to bulk delete
const INPUT_ID_1 = 'c99f1b557d1d43d1916b46f8ce4a0487';
const INPUT_ID_2 = '7c5f489bcafe43fe8a71c68091cb64ce';
const ANNOTATION_ID_1 = '9bcbdbc381c34a6da64bb3d635e82833';
const ANNOTATION_ID_2 = 'e5f8310fbd824354b657050132311e64';
/////////////////////////////////////////////////////////////////////////////
// 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.DeleteAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
input_ids: [INPUT_ID_1, INPUT_ID_2],
annotation_ids: [ANNOTATION_ID_1, ANNOTATION_ID_2]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("Delete annotations failed, status: " + response.status.description);
}
}
);
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.BaseResponse;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
/////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs,
// and annotation 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 portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these based on the annotations you want to bulk delete
static final String INPUT_ID_1 = "c99f1b557d1d43d1916b46f8ce4a0487";
static final String INPUT_ID_2 = "7c5f489bcafe43fe8a71c68091cb64ce";
static final String ANNOTATION_ID_1 = "9bcbdbc381c34a6da64bb3d635e82833";
static final String ANNOTATION_ID_2 = "e5f8310fbd824354b657050132311e64";
///////////////////////////////////////////////////////////////////////////////////
// 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));
BaseResponse deleteAnnotationsResponse = stub.deleteAnnotations(
DeleteAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addInputIds(INPUT_ID_1)
.addInputIds(INPUT_ID_2)
.addIds(ANNOTATION_ID_1)
.addIds(ANNOTATION_ID_2)
.build()
);
if (deleteAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Delete annotations failed, status: " + deleteAnnotationsResponse.getStatus());
}
}
}
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations" \
-H "Authorization: Key YOUR_PAT_HERE" \
-d '{
"input_ids":["YOUR_INPUT_ID_1_HERE","YOUR_INPUT_ID_2_HERE"],
"ids":["YOUR_ANNOTATION_ID_1_HERE", "YOUR_ANNOTATION_ID_2_HERE"]
}'
Bulk Delete All Annotations by Input IDs
To delete all annotations of a given input, you just need to set their input ID(s). This will delete all annotations for these input(s), EXCEPT the input level annotations, which only get deleted if you delete the inputs themselves.
Below is an example of how to do that.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
##########################################################################
# In this section, we set the user authentication, app ID, and input 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 based on the annotations you want to bulk delete
INPUT_ID_1 = '53d0362a9dfa4e03b2293375e2d0db73'
INPUT_ID_2 = '00f6d742124147ac8ca7788f73736fb9'
##########################################################################
# 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)
delete_annotations_response = stub.DeleteAnnotations(
service_pb2.DeleteAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
input_ids=[INPUT_ID_1, INPUT_ID_2]
),
metadata=metadata
)
if delete_annotations_response.status.code != status_code_pb2.SUCCESS:
print(delete_annotations_response.status)
raise Exception("Delete annotations failed, status: " + delete_annotations_response.status.description)
<!--index.html file-->
<script>
////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input 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 based on the annotations you want to bulk delete
const INPUT_ID_1 = 'b5585a6869d34c04bbcaf631e7cd5816';
const INPUT_ID_2 = 'a8748df4938447e4844b2f505c8eaaef';
///////////////////////////////////////////////////////////////////////////////////
// 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
},
"input_ids": [INPUT_ID_1, INPUT_ID_2]
});
const requestOptions = {
method: 'DELETE',
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>
//index.js file
////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input 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 based on the annotations you want to bulk delete
const INPUT_ID_1 = 'b5585a6869d34c04bbcaf631e7cd5816';
const INPUT_ID_2 = 'a8748df4938447e4844b2f505c8eaaef';
/////////////////////////////////////////////////////////////////////////////
// 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.DeleteAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
input_ids: [INPUT_ID_1, INPUT_ID_2]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("Delete annotations failed, status: " + response.status.description);
}
}
);
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.BaseResponse;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input 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 portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these based on the annotations you want to bulk delete
static final String INPUT_ID_1 = "b5585a6869d34c04bbcaf631e7cd5816";
static final String INPUT_ID_2 = "a8748df4938447e4844b2f505c8eaaef";
///////////////////////////////////////////////////////////////////////////////////
// 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));
BaseResponse deleteAnnotationsResponse = stub.deleteAnnotations(
DeleteAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addInputIds(INPUT_ID_1)
.addInputIds(INPUT_ID_2)
.build()
);
if (deleteAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Delete annotations failed, status: " + deleteAnnotationsResponse.getStatus());
}
}
}
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations" \
-H "Authorization: Key YOUR_PAT_HERE" \
-d '{
"input_ids":["YOUR_INPUT_ID_1_HERE","YOUR_INPUT_ID_2_HERE"]
}'