What is the best way to automate the periodic deletion of all records in a database that are not connected to a card? (The records are the children the parent cards in the connection)
Great question — and a common use case for maintaining clean and efficient data structures in Pipefy!
If you want to periodically delete all database records that are not connected to any card (i.e., orphaned child records), here’s the best way to automate that.
Recommended Solution: Using Pipefy GraphQL API + Scheduler (Make, n8n, or custom script)
🧠 Why the API is necessary:
Pipefy does not offer a native automation to delete records or filter database items based on whether they're connected or not. But using the GraphQL API, you can:
-
Fetch all records in a database.
-
Check their connections (via
connectedCardsCount
or reverse lookups). -
Delete the ones that have no connections.
️ Step-by-Step (Using Make.com or n8n.io)
1. Create a recurring trigger
-
Run every X days/hours using a scheduler module.
2. Query your database
Use the GraphQL query to list all database records and their connection counts:
{
table_records(table_id: "your_table_id", first: 100) {
edges {
node {
id
title
connected_cards_count
}
}
}
}
If connected_cards_count == 0
, it means the record is not linked to any card.
Alternatively, if you have a reverse connection set up from the parent pipe to the child records, you can also query through that connection field.
3. Filter the unconnected records
Use logic in your automation tool to filter only records with connected_cards_count === 0
.
4. Delete unconnected records
Use the mutation:
mutation {
deleteTableRecord(input: {id: "record_id"}) {
success
}
}
Loop through each orphaned record and delete it.
API Docs: https://developers.pipefy.com/
🔒 Important Notes
-
Only users with permission to delete database records can use this API mutation.
-
Make sure you log or back up deletions if needed for auditability.
-
You might need pagination if your database has more than 100 records — handle
pageInfo.hasNextPage
.
Bonus: Add a Manual "Clean Now" Trigger
You can also expose this as a webhook or manual button for staff to trigger cleanup when needed — without waiting for the next scheduled run.
Thank you for your quick reply!
In Step 2 of your suggested solution, I’m getting an error: “Field 'connected_cards_count' doesn't exist on type 'TableRecordWithCount'”.
Please advise.
Reply
Join us in the Pipefy Community! 🚀
No account yet? Create an account
Login with your Pipefy credentials
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.