Restore version documentation

default discord avatar
7 months ago

I'm looking to implement the version restore function programmatically.

Having gone over the Version documentation here

I am still missing quite a lot of information on how that works, e.g which version it restores to, what exactly is the ID field, etc.

Is there more in-depth documentation on these LocalAPIs?

  • discord user avatar
    Payload Team
    7 months ago

    The endpoints follow your typical REST crud pattern. The typical process would be to list the versions first via

    GET /versions

    then perform a restore with

    POST /versions/:id

    to the specific


    you want to restore. The


    being the unique identifier for the version that you'd like to restore.

    What can I help clarify beyond that?

  • default discord avatar
    7 months ago

    Thank you for that, this is clear. I'm thinking how versions get created, at which point exactly and are the objects in the _versions table (mongo collection) always a version behind or does _versions maintain an exact replica of what is in the main table.

    I ask this because I want to restore to a previous version (exactly one save behind) and so should I select the last version doc or one before that as the last one is a replica of the current one.

  • discord user avatar
    Payload Team
    7 months ago

    The versions endpoint will return previous versions

    and the latest


    The query against the versions endpoint would look something like this:


    . You can also open up your Network tab while browsing around the Versions page in the Admin UI to see this.

    I don't recall if they're strictly ordered on the response, so you could also pass in something like


    to sort the response.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.