N
Novu•10mo ago
rajat

Is there an API to bulk-delete workflows?

I have tests that create workflows and it would be great for to bulk-delete them in the cases where my cleanup step does not run successfully
7 Replies
Tomer Barnea
Tomer Barnea•10mo ago
@Pawan Jain can you help here?
Pawan Jain
Pawan Jain•10mo ago
hi @rajat5885 If you are using in-app notifications, then we have useRemoveAllNotifications hook to bulk delete all in-app messages together https://docs.novu.co/notification-center/react/api-reference#useremoveallnotifications Currently, we don't have a similar endpoint for other channel messages (notifications)
rajat
rajat•10mo ago
hey Pawan - I'm referring to workflows (previously known as notification templates.) Not notifications themselves
sumitsaurabh927
sumitsaurabh927•10mo ago
Hey @rajat5885 the only way I could see of bulk deleting workflows is to loop over this somehow:
import fetch from 'node-fetch';

const response = await fetch('https://api.novu.co/v1/workflows/:workflowId', {
method: 'DELETE',

});

const data = await response.json();
import fetch from 'node-fetch';

const response = await fetch('https://api.novu.co/v1/workflows/:workflowId', {
method: 'DELETE',

});

const data = await response.json();
Pawan Jain
Pawan Jain•10mo ago
Hi @rajat5885 Sorry I misunderstood your question We currently don't have bulk deletion api for workflows Only way is to delete them one by one 🙂
todd
todd•10mo ago
If you are interested in various solutions to this problem, go take a look at the novu-dotnet library. In particular, the Sync library mirrors environments and has to deal with deletions. Also the integration tests clean up after themselves. https://github.com/novuhq/novu-dotnet/blob/main/src/Novu.Tests/AcceptanceTests/SyncEnvironmentTests.cs
rajat
rajat•10mo ago
thanks! this is helpful