Skip to content

DELETE - Remove Data

To delete data from a homeserver, use the delete method on the session's storage. Like PUT, this requires an authenticated session.

async fn delete() -> pubky::Result<()> {
    let pubky = Pubky::new()?;
    let keypair = Keypair::random();
    let signer = pubky.signer(keypair);

    // The homeserver's public key
    let homeserver = PublicKey::try_from("o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy")
        .expect("Valid homeserver public key");

    // Sign up to the homeserver
    let session = signer.signup(&homeserver, None).await?;

    // DELETE the content from the homeserver
    session.storage().delete("/pub/example.txt").await?;

    println!("Successfully deleted data");

    Ok(())
}

The DELETE operation:

  • Requires a PubkySession obtained from signing up or signing in
  • Takes a path (not a full URL) relative to your homeserver
  • Removes the data at the specified location
  • All operations are authenticated using your session
  • Only the owner of the data can delete it