← Back to Recipes

Deleting your Data

Delete Items to remove user consents from Pluggy.

Steps#

1. Setup the SDK#

Setup the PluggyClient with your application credentials.

2. Select items to be deleted#

Select all the item ids that you have stored from your data storage.

3. Iterate and remove#

Send a request for each itemId that you want to delete. If returns a 404 it means that the item was already deleted.

Code#

import { PluggyClient } from 'pluggy-sdk'
 
const { CLIENT_ID = '', CLIENT_SECRET = '' } = process.env
 
const client = new PluggyClient({
  clientId: CLIENT_ID,
  clientSecret: CLIENT_SECRET,
})
 
const itemIdsToDelete = [
  'f71e99ba-ef78-40e9-9bd1-82e9e13c7e86',
  'f71e99ba-ef78-40e9-9bd1-82e9e13c7e87',
]
 
async function main() {
  for (const itemId of itemIdsToDelete) {
    try {
      await client.deleteItem(itemId)
      console.log(`Item ${itemId} was deleted`)
    } catch (error) {
      console.log(`Issue deleting ${itemId}: ${error}`)
    }
  }
}
 
main()