Deleting a Verification Session
To delete a verification session, you can call the /v1/session/{sessionId}/delete/
endpoint.
- Base URL:
https://verification.didit.me
- Endpoint:
/v1/session/{sessionId}/delete/
- Method:
DELETE
- Authentication:
Client Token (Bearer Token)
The authentication endpoint uses a different base URL than the verification session endpoints. Ensure you use the correct URLs to avoid connectivity issues.
Request
Follow these steps to delete a verification session programmatically:
Step 1: Authenticate
Obtain a valid access_token
by following the Authentication documentation. This token is required in the Authorization
header of your request.
The access_token
is valid for 24 hours. You only need to re-authenticate once it expires.
Step 2: Prepare Request Parameters
Parameter | Type | Required? | Description | Example Value |
---|---|---|---|---|
|
| Yes | The unique identifier of the session to delete. | "11111111-2222-3333-4444-555555555555" |
Step 3: Send the Request
Make a DELETE
request to /v1/session/{session_id}/delete/
with the session ID in the URL path.
Example Request
DELETE /v1/session/11111111-2222-3333-4444-555555555555/delete/ HTTP/1.1
Host: verification.didit.me
Content-Type: application/json
Authorization: Bearer {access_token}
Response
A successful deletion returns a 204 No Content
status code with no response body, indicating that the session was successfully deleted.
Error Handling
Status Code | Error | Description |
---|---|---|
204 | Success | Session successfully deleted. No content is returned. |
401 | Unauthorized | Invalid or missing access_token. |
403 | Forbidden | Not authorized to delete this session. |
404 | Not Found | Session ID not found or invalid. |
Example Error Response
{
"detail": "You do not have permission to perform this action."
}
Session Deletion Use Cases
This endpoint is useful for:
- Data Correction: Removing sessions created with incorrect data
- Privacy Compliance: Facilitating data deletion requests from users
- Test Cleanup: Removing test sessions from your development environment
- Error Remediation: Resolving duplicate or corrupted sessions
Session deletion is permanent and cannot be undone. All associated verification data will be permanently removed.
Code Examples
const deleteSession = async (sessionId) => {
const endpoint = `https://verification.didit.me/v1/session/${sessionId}/delete/`;
const token = await getClientToken();
if (!token) {
console.error('Error fetching client token');
throw new Error('Authentication failed');
}
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token.access_token}`
};
try {
const response = await fetch(endpoint, {
method: 'DELETE',
headers
});
if (response.status === 204) {
return true; // Successfully deleted
}
if (!response.ok) {
const errorData = await response.json();
console.error('Error deleting session:', errorData.detail || errorData.message);
throw new Error(errorData.detail || 'Failed to delete session');
}
} catch (err) {
console.error('Error:', err);
throw err;
}
};