Skip to main content
The delete method (same name as the API endpoint) permanently removes a source from your project. You must pass the source’s file_id (from list or get build status). The operation is irreversible and removes all associated data including partition nodes and metadata.

Method overview

client.sources.delete()

Method signature

Parameters

Important considerations

Warning: This operation is irreversible.
  • All document content and metadata are permanently removed
  • Associated partition nodes and embeddings are deleted
  • No backup or recovery is available
  • Use the source’s unique file_id from list or get build status
  • Do not rely on file name; only file_id is supported

Response

The method returns a response object with:

Code examples

Basic usage

Async usage

Delete with verification

Verify the source exists (by file_id) before deleting:

Error handling

Advanced Examples

Batch Deletion

Delete multiple files with safety checks:

Async Batch Deletion

Delete multiple files concurrently:

Cleanup Failed Sources

Automatically clean up sources that failed processing:

Document Lifecycle Manager

A complete class for managing document lifecycle:

Archival Tool with Dry Run

Test deletions before executing them:

Error Reference

Best Practices

Pre-deletion verification

Verify the source exists (by file_id) before deleting:

Safety Measures

  • Implement confirmation prompts in interactive applications
  • Log all deletion operations for audit trails
  • Use dry_run patterns to preview deletions before executing
  • Test with non-production data when implementing deletion features

Error Handling

  • Implement retry logic for transient network errors (not for 404/403 errors)
  • Validate file_id (e.g. from list) before deleting
  • Handle batch operations carefully to avoid partial failures

Troubleshooting

Causes: Source doesn’t exist for the given file_id, wrong file_id, or already deleted.Solutions:
  • Use client.sources.list() to get current file_ids before deleting
  • Verify you’re using the correct project/API key
Causes: Invalid token, token revoked, or wrong project accessSolutions:
  • Verify API key format (should start with “grlm_”)
  • Check token status in the Graphor dashboard
  • Ensure token has delete permissions for the project
Causes: Large files, complex cleanup operations, or server loadSolutions:
  • Increase request timeout

Next steps

After deleting a source:

List sources

View remaining sources and their file_ids

Upload

Ingest new files, URLs, GitHub, or YouTube

Reprocess source

Re-process a source with a different partition method

Get elements

Retrieve parsed elements from a source