Holder messaging via DIDComm
Example use case
Technical implementation
Prerequisites
Encrypted message dispatch
const axios = require("axios").default;
const API_KEY = ;//Your Truvera API key//
const API_URL = "https://api-testnet.truvera.io";//for production https://api.truvera.io
const WALLET_DID = ;//Holders wallet DID//
const apiClient = axios.create({
baseURL: API_URL,
headers: {
"Content-Type": "application/json",
"User-Agent": "insomnia/9.3.2",
Authorization: `Bearer ${API_KEY}`,
},
});
async function sendYesNoMessage() {
const payload = {
type: "text",
payload: {
senderName: , //Name of the message sender DID//
senderDid: , //Message sender DID//
senderLogo: , //Logo of the message sender DID//
title: "Are you currently speaking with our customer support team?",
question:
"This confirms you initiated the call and helps prevent fraud. Your personal information will not be shared.",
yesText: "Yes",
noText: "No",
expirationDate: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(),
messageId: 'Internal-message-1234'//add a message ID to track the message
},
type: "https://schema.truvera.io/yes-no-payload-V1.json",
senderDid: ,//the message sender DID//
algorithm: "ECDH-1PU+A256KW",
recipientDids: [WALLET_DID],
};
const { data: encryptedMessage } = await apiClient.post(
"/messaging/encrypt",
payload
);
console.log("Message encrypted successfully:", encryptedMessage);
const sendPayload = {
to: WALLET_DID,
message: encryptedMessage.jwe,
};
const { data: sentMessage } = await apiClient.post(
"/messaging/send",
sendPayload
);
console.log("Message sent successfully:", sentMessage);
}
sendYesNoMessage();Response payload from the wallet
Response notification and retrieval
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
offsetinteger · int32OptionalDefault:
How many items to offset by for pagination
0limitinteger · int32 · min: 1 · max: 64OptionalDefault:
How many items to return at one time (max 64)
64tostring · min: 32OptionalExample:
DID as fully qualified, typically. did:cheqd:
did:cheqd:testnet:ac2b9027-ec1a-4ee2-aad1-1e316e7d6f59messageTypestringOptional
Filter messages by type (e.g., 'https://didcomm.org/basicmessage/2.0/basic-message')
Responses
200
A paged array of DIDComm messages
application/json
400
Invalid request parameters
application/json
401
Authentication required
application/json
get
/messaging/messagesAuthorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
messageIdstringRequiredExample:
The unique identifier of the message
msg_1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefPattern: ^[a-f0-9]{64}$Responses
200
The requested DIDComm message
application/json
400
Invalid message ID format
application/json
401
Authentication required
application/json
404
Message not found or not owned by user
application/json
get
/messaging/messages/{messageId}Last updated
Was this helpful?