Version control

Every time you save an item, a new version is created. You can view a previous version of an item at any time, or you can revert to a previous version.

You don't need to set the version number manually, although you can if you want to. By default, the version number will be automatically incremented each time you save an item.

Examples

The version number increment logic is fairly basic. First, we find the last numeric substring (treating . as a separator). We parse this substring as a number, increment it, then substitute it back into the original version string.

  • "" (empty string) will be incremented to "1".
  • 1 will be incremented to 2.
  • 0.12 will be incremented to 0.13.
  • 0.19 will be incremented to 0.20.
  • 0.1.0 will be incremented to 0.1.1.
  • 0.1.0b will be incremented to 0.1.1b.
  • 4test123 will be incremented to 4test124.

View an item's history

We can view the history of an item in the dashboard by clicking on the button at the top of the item details page.

This will show a list of all previous versions of the item. We can also compare versions to see exactly what changed in each version.

To view an item's history via the API, we can use the Fetch item events endpoint:

cURL
123curl https://api.jsonpad.io/lists/sample-list/items/32d3372a-4d66-42c7-9038-072400d100db/events \
  -H "Content-Type: application/json" \
  -H "x-api-token: <YOUR TOKEN>"

Note that each event returned in the response will have a version field.

View a specific item version

When fetching an item or an item's data, we can specify which version we want to view. If we don't specify a version, the latest version will be fetched.

cURL
123curl https://api.jsonpad.io/lists/sample-list/items/32d3372a-4d66-42c7-9038-072400d100db?version=1 \
  -H "Content-Type: application/json" \
  -H "x-api-token: <YOUR TOKEN>"

Restore an item

Items can be restored to a previous version in the dashboard by clicking on the button next to a version in the item's history page.

When an item is restored, the data, description, readonly and activated fields will be restored to the values they had when the specified version was created.

A new version will be created containing the restored state, and the version number will be incremented.

2024-11-21