After creating a verification session and initiating the verification process, you may need to retrieve detailed information about a user's session. VOVE ID provides an endpoint for this purpose. This section outlines how to retrieve user's session information using the GET /sessions/:refId endpoint. This operation is typically triggered after the backend receives a webhook notification via our system.
Endpoint and Request
Endpoint:GET /v2/users/:refId
Headers:
Content-Type: application/json
x-api-key: API_KEY
Path Parameters:
refId: The unique identifier of the session you want to retrieve. This ID is generated and provided when the session is created.
Example Request:
GET /v2/users/3eb8c91c-c866-4fcb-9805-67e8b45c7883 HTTP/1.1Content-Type:application/jsonx-api-key:YOUR_API_KEY
Get User Session
On a successful request, the API will return detailed information about the user's session. An example response might look like this:jsonCopy code
When the verification process is completed or any specific event occurs, VOVE ID will send a webhook notification to your backend.. Upon receiving a webhook, your backend can trigger the retrieval of session information.
Step-by-Step Process:
Set Up Webhook Listener:
Configure your backend to listen for webhook notifications from us.
Ensure that your webhook endpoint can handle POST requests.
Receive Webhook Notification:
When a webhook is received, parse the payload to extract relevant information, such as the refId.
Trigger Session Information Retrieval:
Use the extracted refId to make a GET request to the GET /users/:refId endpoint.
Include the API_KEY in the request header for authentication.
Example Code for Webhook Handling and Session Retrieval:
constexpress=require('express');constaxios=require('axios');constapp=express();app.use(express.json());app.post('/webhook',async (req, res) => {// userId is the same as refId you provided earlier to create the sessionconst { userId } =req.body; // Extract userId from webhook payloadtry {// Retrieve session informationconstsessionInfo=awaitaxios.get(`https://sandbox.voveid.com/sessions/${userId}`, { headers: {'Content-Type':'application/json','x-api-key':'YOUR_API_KEY' } });console.log('Session Information:',sessionInfo.data);// Process the session information as needed// ...res.status(200).send('Webhook received and session information retrieved successfully.'); } catch (error) {console.error('Error retrieving session information:', error);res.status(500).send('Failed to retrieve session information.'); }});// Start the Express serverconstPORT=process.env.PORT||3000;app.listen(PORT, () => {console.log(`Server is running on port ${PORT}`);});
Conclusion
By following the steps outlined in this section, clients can efficiently retrieve and handle user's session information in VOVE ID. This process ensures that all relevant data about the user's verification session is accessible and can be used to make informed decisions or further actions within the client's application.