Skip to content

entries.delete()

Permanently delete an entry from a feed.

Signature

entries.delete(feedId: string, entryId: string): Promise<void>

Parameters

feedId

  • Type: string
  • Required: Yes
  • Description: The UUID of the feed containing the entry

entryId

  • Type: string
  • Required: Yes
  • Description: The UUID of the entry to delete

Returns

  • Type: Promise<void>

Returns nothing on success. Throws error if deletion fails.

Usage

Basic Example

await grapevine.entries.delete(feedId, entryId);
console.log('Entry deleted successfully');

With Confirmation

async function deleteEntryWithConfirmation(feedId: string, entryId: string) {
  // Get entry details first
  const entry = await grapevine.entries.get(feedId, entryId);
  
  console.log(`About to delete: ${entry.title || 'Untitled entry'}`);
  console.log(`Created: ${new Date(entry.created_at * 1000)}`);
  
  // Confirm deletion (in a real app, get user confirmation)
  const confirmed = true; // await getUserConfirmation();
  
  if (confirmed) {
    await grapevine.entries.delete(feedId, entryId);
    console.log('Entry deleted');
  }
}

Batch Deletion

async function deleteMultipleEntries(feedId: string, entryIds: string[]) {
  const results = await Promise.allSettled(
    entryIds.map(id => grapevine.entries.delete(feedId, id))
  );
  
  let succeeded = 0;
  let failed = 0;
  
  results.forEach((result, index) => {
    if (result.status === 'fulfilled') {
      succeeded++;
      console.log(`✓ Deleted entry ${entryIds[index]}`);
    } else {
      failed++;
      console.error(`✗ Failed to delete ${entryIds[index]}:`, result.reason);
    }
  });
  
  console.log(`Deleted: ${succeeded}, Failed: ${failed}`);
}

Clean Up Old Entries

async function cleanupOldEntries(feedId: string, daysOld: number) {
  // List all entries
  const entries = await grapevine.entries.list(feedId, {
    limit: 100,
    sort: 'created_at',
    order: 'asc'
  });
  
  const cutoffTime = Date.now() / 1000 - (daysOld * 24 * 60 * 60);
  const toDelete = entries.entries.filter(e => e.created_at < cutoffTime);
  
  console.log(`Found ${toDelete.length} entries older than ${daysOld} days`);
  
  for (const entry of toDelete) {
    try {
      await grapevine.entries.delete(feedId, entry.id);
      console.log(`Deleted: ${entry.title || entry.id}`);
    } catch (error) {
      console.error(`Failed to delete ${entry.id}:`, error);
    }
  }
}

Behind the Scenes

This method:

  1. Validates feed and entry ID formats
  2. Gets authentication headers (nonce + signature)
  3. Makes DELETE request to /v1/feeds/{feedId}/entries/{entryId}
  4. Handles 402 payment if required
  5. Removes entry from feed and secure storage references

Error Handling

try {
  await grapevine.entries.delete(feedId, entryId);
  console.log('Entry deleted');
} catch (error) {
  if (error.message.includes('404')) {
    console.error('Entry or feed not found');
  } else if (error.message.includes('403')) {
    console.error('Not authorized - you can only delete entries from your own feeds');
  } else if (error.message.includes('402')) {
    console.error('Payment required for deletion');
  } else {
    console.error('Error:', error.message);
  }
}

Notes

  • Authentication: Required - must be feed owner
  • Permanent: This action cannot be undone
  • Payment: May require x402 micropayment (handled automatically)
  • Ownership: Can only delete entries from feeds you own
  • Private IPFS Storage: Entry content remains on Private IPFS but reference is removed

Related