DELETE
/
deleteWallets
Delete User Wallets
curl --request DELETE \
  --url http://localhost:2400/deleteWallets \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "walletIds": [
    "65f1a...",
    "65f2b..."
  ]
}'
{
  "success": true,
  "message": "Successfully deleted 2 wallets."
}

Endpoint

DELETE /deleteWallets

Description

Deletes one or more wallets belonging to the authenticated user based on the provided internal wallet IDs (_id). This permanently removes the wallet record, including its address, slot name, and associated private key, from the system.

Authentication

Requires a valid JWT token passed via cookies.

Request Body

ParameterTypeRequiredDescription
walletIdsArray of stringsYesAn array containing the internal IDs (_id) of the wallets to delete.
Example
{
  "walletIds": ["65f1a...", "65f2b..."] 
}

Success Response (200 OK)

Returns a success message indicating how many wallets were deleted.
Example
{
  "success": true,
  "message": "Successfully deleted 2 wallets."
}

Error Response (400 Bad Request)

Indicates that the walletIds array is missing or empty in the request body.
Example
{
  "error": "Wallet IDs are required"
}

Error Response (401 Unauthorized)

Indicates that no valid JWT token was provided or the token is expired.
Example
{
  "error": "No access token provided"
}

Error Response (403 Forbidden)

Indicates an attempt to delete a wallet that does not belong to the authenticated user.
Example
{
  "error": "Forbidden: Wallet does not belong to user or not found",
  "failedWalletId": "65f1a..." // ID of the wallet causing the error
}

Error Response (500 Internal Server Error)

Indicates a server-side error occurred during the deletion process.
Example
{
  "error": "Failed to delete wallet",
  "details": "Database error occurred"
}

Notes

  • This endpoint is handled by the User server (Port 5000).
  • Deletes records from the GeneralWalletData collection.
  • This is a permanent deletion and cannot be undone.
  • The endpoint iterates through the provided walletIds and attempts to delete each one, ensuring the user owns the wallet before deletion.
  • If an error occurs for a specific wallet ID (e.g., not found or forbidden), the process stops, and an error related to that wallet is returned.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Response

200
application/json

Success response indicating wallets were deleted.

The response is of type object.