Edit a Post
This guide explains how to edit a Post content on Lens.
To update a Post on Lens, follow these steps:
Create a new Post Metadata object.
Upload this object to a publicly accessible URI.
Update the Post with the new Metadata object.
See the Lens Metadata Standards guide for more information on creating and hosting Metadata objects.
First, create a new Post Metadata object with the updated details.
It's developer responsability to copy over any existing data that should be retained.
The process is similar to the one in the Create a Post guide, so we will keep this example brief.
Text-only
import { textOnly } from "@lens-protocol/metadata";
const metadata = textOnly({ content: `GM! GM!`,});
Next, upload the Post Metadata object to a public URI.
If the hosting solution used when the Post was created or last updated allows edits, you may want to choose between:
Keeping a history of the file, like a document revision, by uploading it to a new URI.
Erasing the previous version by updating the content at the same URI.
Upload
import { textOnly } from "@lens-protocol/metadata";import { uploadJson } from "./my-upload-lib";
const metadata = textOnly({ content: `GM! GM!`,});
const contentUri = await uploadJson(metadata); // e.g., lens://4f91ca…
If Lens Storage Nodes was used you can edit or delete content as needed. See the Editing Content and Deleting Content guides for more information.
- GraphQL
- React
- TypeScript
Then, you can use the editPost mutation to update the Post content URI.
You MUST be authenticated as Account Owner or Account Manager to make this request.
Finally, handle the result as explained in the Transaction Lifecycle guide.