Clean up stale entities
When you remove a resource type from your integration mapping or decommission an integration, the associated entities in Port are not automatically deleted. This documentation explains how to properly clean up stale entities to keep your software catalog accurate and up to date.
When cleanup is needed
Cleanup is typically required when you:
- Remove a
kindfrom your integration mapping (for example, removingpull-requestto stop syncing PRs). - Delete an integration entirely.
- Rename a blueprint identifier.
- Change your mapping in a way that orphans previously synced entities.
The 3-step cleanup process
Removing stale entities requires completing these steps in order. Skipping a step or performing them out of sequence can leave orphaned data in your catalog.
Step 1: Remove the mapping
Before deleting any entities, remove the resource mapping from your integration configuration. This prevents the integration from recreating the entities on the next resync.
-
Go to your data sources page.
-
Click on the integration you want to modify.
-
Navigate to the Mapping tab.
-
Remove the entire resource block for the
kindyou no longer want to sync. -
Click Save & Resync.
For example, if you no longer want to sync pull requests, remove this entire block:
- kind: pull-request
selector:
query: "true"
port:
entity:
mappings:
identifier: ".id | tostring"
title: ".title"
blueprint: '"pullRequest"'
properties:
# ... properties
Always remove the mapping before deleting entities. If you delete entities first, the next integration resync will recreate them.
Step 2: Delete the entities
Once the mapping is removed, delete the stale entities. You can do this through the UI or via the API.
- Using the UI
- Using the API
Delete entities one by one
-
Go to the catalog page for the relevant blueprint.
-
On the entity you want to delete click on the
...button. -
Click on Unregister button in the toolbar.
-
Confirm the deletion by clicking on Unregister again.
Delete all entities of a blueprint
If you need to delete all entities of a specific blueprint:
-
Go to the catalog page for the blueprint.
-
Click the
...menu in the top-right corner. -
Select Delete page.
-
Click Delete to confirm the deletion.
Delete a single entity
curl -X DELETE "https://api.getport.io/v1/blueprints/<blueprint_identifier>/entities/<entity_identifier>" \
-H "Authorization: Bearer $PORT_ACCESS_TOKEN"
Delete multiple entities (up to 100)
curl -X POST "https://api.getport.io/v1/blueprints/<blueprint_identifier>/bulk/entities/delete" \
-H "Authorization: Bearer $PORT_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entities": ["entity_id_1", "entity_id_2", "entity_id_3"]
}'
Delete all entities of a blueprint
To delete all entities belonging to a specific blueprint:
curl -X DELETE "https://api.getport.io/v1/blueprints/<blueprint_identifier>/all-entities" \
-H "Authorization: Bearer $PORT_ACCESS_TOKEN"
If the entities have dependent entities (entities that reference them via required relations), add the delete_dependents query parameter:
curl -X DELETE "https://api.getport.io/v1/blueprints/<blueprint_identifier>/all-entities?delete_dependents=true" \
-H "Authorization: Bearer $PORT_ACCESS_TOKEN"
Entity deletion is permanent and cannot be undone. Consider exporting your entities before deleting them if you might need the data later.
Step 3: Delete the blueprint (optional)
If you no longer need the blueprint itself, delete it after all its entities have been removed.
-
Go to the Builder page.
-
Find the blueprint you want to delete.
-
Click the
...menu on the blueprint card. -
Select Delete blueprint.
-
Type DELETE and click on
Deleteto confirm the deletion.
You can only delete a blueprint if:
- It has no remaining entities.
- No other blueprints have required relations pointing to it.
If other blueprints reference this blueprint, update or remove those relations first.
When you delete a blueprint, Port also deletes any associated catalog pages that were automatically created for that blueprint.
Export before deletion
Before deleting entities, you may want to export them for backup or audit purposes.
- Using the UI
- Using the API
-
Go to the catalog page for the blueprint.
-
Click the Export button in the toolbar.
-
Choose your export format (CSV or JSON) to download the file.
Use the search endpoint to retrieve all entities of a blueprint:
curl -X POST "https://api.getport.io/v1/entities/search" \
-H "Authorization: Bearer $PORT_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"combinator": "and",
"rules": [
{
"property": "$blueprint",
"operator": "=",
"value": "<blueprint_identifier>"
}
]
}' > entities_backup.json
Handle dependent entities
When deleting entities that are referenced by other entities through relations, you have two options:
Option 1: Auto-delete dependent entities
Use the delete_dependents parameter to automatically delete entities that depend on the ones you're deleting:
curl -X DELETE "https://api.getport.io/v1/blueprints/<blueprint_identifier>/all-entities?delete_dependents=true" \
-H "Authorization: Bearer $PORT_ACCESS_TOKEN"
Option 2: Update relations first
Manually update or remove the relations in dependent entities before deleting:
- Identify which entities reference the entities you want to delete.
- Update those entities to remove or change the relation values.
- Then delete the original entities.
Mapping configuration options
Port provides configuration options to control automatic entity deletion during integration resyncs.
deleteDependentEntities
When enabled, Port automatically deletes dependent entities when their parent entity is removed during a resync. Add this to your mapping configuration:
deleteDependentEntities: true
resources:
- kind: repository
# ...
entityDeletionThreshold
Controls whether the integration's deletion mechanism is active. Set to 0 to disable automatic deletion or 1 to enable it:
entityDeletionThreshold: 1
resources:
- kind: repository
# ...
For more details on these options, see Configure mapping - Advanced options.
Troubleshooting
Entities reappear after deletion
If entities reappear after you delete them, the integration mapping still includes the resource type. Make sure you:
- Removed the
kindfrom the mapping configuration. - Saved and resynced the integration.
- Then deleted the entities.
Cannot delete blueprint
If you cannot delete a blueprint, check for:
- Remaining entities: Delete all entities of the blueprint first.
- Incoming relations: Other blueprints may have relations pointing to this blueprint. Update or remove those relations first.
Dependent entities blocking deletion
If you receive an error about dependent entities:
- Use the
delete_dependents=trueparameter in your API call. - Or manually remove the relations from dependent entities first.