Notifications & Webhooks
The LearnCloud Network includes a notification system that alerts users of important events such as received credentials, connection requests, and consent requests.
Reading Notifications
Get Notifications (Paginated)
Fetch a paginated list of notifications with optional filters:
const result = await learnCard.invoke.getNotifications(
{ limit: 20, sort: 'REVERSE_CHRONOLOGICAL' },
{ read: false, archived: false } // optional filters
);
console.log(result.notifications); // Array of notifications
console.log(result.hasMore); // Boolean indicating more pages
console.log(result.cursor); // Cursor for next pageOptions:
limit- Number of notifications per pagecursor- Pagination cursor from previous responsesort-'CHRONOLOGICAL'or'REVERSE_CHRONOLOGICAL'
Filters:
type- Filter by notification type (e.g.,'CREDENTIAL_RECEIVED')read- Filter by read status (trueorfalse)archived- Filter by archived status (trueorfalse)actionStatus- Filter by action status ('PENDING','COMPLETED','REJECTED')
Query Notifications
For more flexible querying, use queryNotifications to find notifications matching specific criteria:
Query Fields:
type- Notification type enumfrom.did- Sender's DIDfrom.profileId- Sender's profile IDdata.vcUris- Credential URI(s) associated with the notificationdata.vpUris- Presentation URI(s) associated with the notificationread- Read statusarchived- Archived statusactionStatus- Action status ('PENDING','COMPLETED','REJECTED')
Update Notification
Mark a notification as read, archived, or update its action status:
Mark All Read
Mark all notifications as read:
Architecture
Configuration
Profiles may optionally add a notificationsWebhook url, which will cause the LCN service to send payloads of a specific shape to that URL. These payloads are described here.
Payload Reference
Connection Request
When requesting a connection with a profile, the target profile will receive a notification payload of the following structure:
Where targetProfile and requesterProfile are each LCNProfile objects
Connection Accepted
When accepting a connection request, the profile who requested the connection will receive a notification payload of the following structure:
Where accepterProfile and requesterProfile are each LCNProfile objects
Credential Received
When sending a credential to a profile, the profile who will receive the credential will receive a notification payload of the following structure:
Where senderProfile and receiverProfile are each LCNProfile objects, and uri is a URI that resolves to the credential that was sent.
Boost Received
When sending a boost to a profile, the profile who will receive the boost will receive a notification payload of the following structure:
Where senderProfile and receiverProfile are each LCNProfile objects, and uri is a URI that resolves to the boost that was sent.
Boost Accepted
When accepting a sent boost, the profile who sent the boost will receive a notification payload of the following structure:
Where senderProfile and receiverProfile are each LCNProfile objects, and uri is a URI that resolves to the boost that was sent.
Presentation Received
When sending a presentation to a profile, the profile who will receive the presentation will receive a notification payload of the following structure:
Where senderProfile and receiverProfile are each LCNProfile objects, and uri is a URI that resolves to the presentation that was sent.
Consent Flow Transaction
Consent
When consenting to a Consent Flow Contract, the owner of the contract will receive a notification payload of the following structure:
Where ownerProfile and consenterProfile are each LCNProfile objects, contract is a ConsentFlowContractDetails object, and transaction is a ConsentFlowTransaction object with its action set to 'consent'.
Re-Consent
When a profile consents, withdraws consent, then reconsents to a contract, the owner of the contract will receive a notification payload of the following structure:
Where ownerProfile and consenterProfile are each LCNProfile objects, contract is a ConsentFlowContractDetails object, and transaction is a ConsentFlowTransaction object with its action set to 'consent'.
Updated Terms
When a profile updates its terms to a contract, the owner of the contract will receive a notification payload of the following structure:
Where ownerProfile and consenterProfile are each LCNProfile objects, contract is a ConsentFlowContractDetails object, and transaction is a ConsentFlowTransaction object with its action set to 'update'.
Withdrawn Consent
When a profile withdraws consent to a contract, the owner of the contrct will receive a notification payload of the following structure:
Where ownerProfile and consenterProfile are each LCNProfile objects, contract is a ConsentFlowContractDetails object, and transaction is a ConsentFlowTransaction object with its action set to 'withdraw'.
Last updated
Was this helpful?