Model data with labels and annotations
Labels and annotations provide a powerful way to organize and model REST resources in the Truvity platform, allowing you to quickly categorize, filter, and retrieve resources based on specific attributes with faceted search.
Add labels and annotations to a draft
To add labels or annotations to a draft resource, call the update method:
- TypeScript
 - Java
 
const updatedDraft = await createdDraft.update({
    labels: {
        property1: "string",
    },
    annotations: {
        property2: "string",
    }
});
var updatedDraft = createdDraft.update(null, Map.of("property1", "string"), Map.of("property2", "string")); 
Add labels and annotations to an issued credential
You can add labels and annotations to an issued credential resource by either calling the update method on the VerifiableCredential instance or by using the CredentialUpdateLabels and CredentialUpdateAnnotations API endpoints directly.
- TypeScript
 - Java
 
const updatedCredential = await credential.update({
    labels: {
        property1: "string",
    },
    annotations: {
        property2: "string",
    },
});
var updatedCredential = credential.update(new UpdatePayload(Map.of("property1", "string"), Map.of("property2", "string")));
Add labels and annotations to a verifiable presentation
To add labels to the issued verifiable presentation resource, call the presentationUpdateLabels method:
- TypeScript
 - Java
 
const updatedPresentation = await presentation.presentationUpdateLabels({
    labels: {
        property1: "string",
    },
});
var updatedPresentation = presentation.presentationUpdateLabels(null, Map.of("property1", "string"));
To add annotations to the issued verifiable presentation resource, call the presentationUpdateAnnotations method:
- TypeScript
 - Java
 
const updatedPresentation = await presentation.presentationUpdateAnnotations({
    annotations: {
        property1: "string",
    },
});
var updatedPresentation = presentation.presentationUpdateAnnotations(null, Map.of("property1", "string"));
Add labels and annotations to a DIDComm message
To add labels to a DIDComm message, call the DidcommMessageUpdateLabels method:
- TypeScript
 - Java
 
const updatedDidcommMessage = await client.didcommMessages.didcommMessageUpdateAnnotations(didcommMessageId, {  
    labels: {  
        property1: "string",  
    },  
}); 
var updatedDidcommMessage = client.didcommMessages()  
                .didcommMessageUpdateLabels(  
                        didcommMessageId,  
                        DidcommMessageUpdateLabelsInput.builder().labels("property1", "string").build());  
To add annotations to a DIDComm message, call the DidcommMessageUpdateAnnotations method:
- TypeScript
 - Java
 
const updatedDidcommMessage = await client.didcommMessages.didcommMessageUpdateAnnotations(didcommMessageId, {  
    annotations: {  
        property1: "string",  
    },  
}); 
var updatedDidcommMessage = client.didcommMessages()
                .didcommMessageUpdateAnnotations(
                        didcommMessageId,
                        DidcommMessageUpdateAnnotationsInput.builder()
                                .annotations("property1", "string")
                                .build());