Session Events
The Issuer2 Service provides a Server-Sent Events (SSE) endpoint for monitoring credential issuance sessions in real-time. This allows you to track the progress of credential offers as they are claimed by wallets.
SSE Endpoint
Connect to the SSE endpoint to receive real-time updates for a specific issuance session.
Endpoint: GET /v2/{target}/issuer-service-api/issuance-session/{issuance-session}/events
Path Parameters
target– The resource identifier for the issuer2 service ({organizationID}.{tenantID}.{issuerServiceID})issuance-session– The offer ID returned when creating a credential offer
Example Connection
curl -N \
'https://{orgID}.enterprise-sandbox.waltid.dev/v2/{target}/issuer-service-api/issuance-session/{offerId}/events' \
-H 'Authorization: Bearer {yourToken}' \
-H 'Accept: text/event-stream'
Event Types
The following events are emitted during the issuance process:
| Event Type | Description | When Triggered |
|---|---|---|
resolved_credential_offer | Wallet resolved the credential offer | Wallet fetches the offer details |
requested_token | Wallet requested an access token | Wallet exchanges code for token |
sdjwt_issue | SD-JWT credential was issued | SD-JWT VC credential delivered |
jwt_issue | JWT credential was issued | W3C JWT credential delivered |
generated_mdoc | mDoc credential was generated | mDL/mDoc credential delivered |
issuance_status | Session status changed | Status updates (completed, expired, etc.) |
Event Format
Events are delivered in the standard SSE format:
event: {eventType}
data: {jsonPayload}
Example Events
Credential Offer Resolved:
event: resolved_credential_offer
data: {"offerId":"abc123","timestamp":1704067200000,"credentialOffer":{...}}
Token Requested:
event: requested_token
data: {"offerId":"abc123","timestamp":1704067210000,"tokenRequest":{...}}
SD-JWT Credential Issued:
event: sdjwt_issue
data: {"offerId":"abc123","timestamp":1704067220000,"sdjwt":"eyJ..."}
JWT Credential Issued:
event: jwt_issue
data: {"offerId":"abc123","timestamp":1704067220000,"jwt":"eyJ..."}
mDoc Generated:
event: generated_mdoc
data: {"offerId":"abc123","timestamp":1704067220000,"mdoc":"a26..."}
Usage Example
JavaScript/Browser
const eventSource = new EventSource(
'https://myorg.enterprise-sandbox.waltid.dev/v2/waltid.tenant1.issuer1/issuer-service-api/issuance-session/abc123/events',
{
headers: {
'Authorization': 'Bearer your-token'
}
}
);
eventSource.addEventListener('resolved_credential_offer', (event) => {
const data = JSON.parse(event.data);
console.log('Offer resolved:', data);
});
eventSource.addEventListener('jwt_issue', (event) => {
const data = JSON.parse(event.data);
console.log('Credential issued:', data);
});
eventSource.addEventListener('issuance_status', (event) => {
const data = JSON.parse(event.data);
console.log('Status update:', data);
if (data.status === 'COMPLETED') {
eventSource.close();
}
});
eventSource.onerror = (error) => {
console.error('SSE error:', error);
eventSource.close();
};
Node.js
const EventSource = require('eventsource');
const url = 'https://myorg.enterprise-sandbox.waltid.dev/v2/waltid.tenant1.issuer1/issuer-service-api/issuance-session/abc123/events';
const eventSource = new EventSource(url, {
headers: {
'Authorization': 'Bearer your-token'
}
});
eventSource.onmessage = (event) => {
console.log('Event:', event.data);
};
eventSource.onerror = (error) => {
console.error('Error:', error);
};
Best Practices
- Handle Reconnection – SSE connections may drop; implement reconnection logic
- Set Timeouts – Close connections after expected session duration
- Use Webhooks for Production – For server-to-server communication, webhooks are more reliable than SSE
- Monitor Multiple Sessions – Open separate SSE connections for each session you want to monitor
Alternative: Webhook Notifications
For server-side applications, consider using webhook notifications instead of SSE. Webhooks are:
- More reliable for long-running processes
- Easier to integrate with backend systems
- Not affected by connection timeouts
Configure webhooks in your credential profile or as a runtime override when creating offers.
