Skip to main content

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:

const updatedDraft = await createdDraft.update({
labels: {
property1: "string",
},
annotations: {
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.

const updatedCredential = await credential.update({
labels: {
property1: "string",
},
annotations: {
property2: "string",
},
});

Add labels and annotations to a verifiable presentation

To add labels to the issued verifiable presentation resource, call the presentationUpdateLabels method:

const updatedPresentation = await presentation.presentationUpdateLabels({
labels: {
property1: "string",
},
});

To add annotations to the issued verifiable presentation resource, call the presentationUpdateAnnotations method:

const updatedPresentation = await presentation.presentationUpdateAnnotations({
annotations: {
property1: "string",
},
});

Add labels and annotations to a DIDComm message

To add labels to a DIDComm message, call the DidcommMessageUpdateLabels method:

const updatedDidcommMessage = await client.didcommMessages.didcommMessageUpdateAnnotations(didcommMessageId, {  
labels: {
property1: "string",
},
});

To add annotations to a DIDComm message, call the DidcommMessageUpdateAnnotations method:

const updatedDidcommMessage = await client.didcommMessages.didcommMessageUpdateAnnotations(didcommMessageId, {  
annotations: {
property1: "string",
},
});