curl --request POST \
--url https://api.example.com/{collection}/{id}/restore/{v}{
"400": {},
"401": {},
"403": {},
"404": {},
"500": {},
"501": {},
"_id": "<string>",
"_version": 123,
"updated_at": "<string>",
"updated_by": "<string>",
"...": "<any>"
}Restore a document to a previous version
curl --request POST \
--url https://api.example.com/{collection}/{id}/restore/{v}{
"400": {},
"401": {},
"403": {},
"404": {},
"500": {},
"501": {},
"_id": "<string>",
"_version": 123,
"updated_at": "<string>",
"updated_by": "<string>",
"...": "<any>"
}Restores a document to the state it had at a specific version. This creates a new version with the restored data.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/KTS-o7/permission-mongo/llms.txt
Use this file to discover all available pages before exploring further.
POST /{collection}/{id}/restore/{v}
restore action permission on the collection and access to the specific document.
curl -X POST "https://api.example.com/employees/emp_12345/restore/2" \
-H "Authorization: Bearer <token>"
{
"_id": "emp_12345",
"_version": 5,
"name": "John Doe",
"email": "john.doe@example.com",
"department": "Marketing",
"salary": 75000,
"created_at": "2024-01-10T09:15:00Z",
"updated_at": "2024-03-20T16:45:00Z",
"updated_by": "user_admin"
}
Before restore:
Version 1: {name: "John", salary: 70000}
Version 2: {name: "John", salary: 75000}
Version 3: {name: "John Doe", salary: 80000}
Version 4: {name: "John Doe", salary: 85000} <- current
After restoring to version 2:
Version 1: {name: "John", salary: 70000}
Version 2: {name: "John", salary: 75000}
Version 3: {name: "John Doe", salary: 80000}
Version 4: {name: "John Doe", salary: 85000}
Version 5: {name: "John Doe", salary: 85000} <- pre-restore snapshot
Version 6: {name: "John", salary: 75000} <- restored (new current)
_id is always preserved during restore. Only the data fields are restored.
updated_at: Set to the current timestampupdated_by: Set to the user performing the restorerestoredocument_id and restore_versionrestore{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid version number",
"details": {
"version": "abc"
}
}
}
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}
{
"error": {
"code": "FORBIDDEN",
"message": "You don't have permission to restore this document",
"details": {
"action": "restore",
"collection": "employees"
}
}
}
{
"error": {
"code": "VERSION_NOT_FOUND",
"message": "Version not found",
"details": {
"collection": "employees",
"id": "emp_12345",
"version": 99
}
}
}
{
"error": {
"code": "INTERNAL_ERROR",
"message": "Failed to restore document",
"details": {
"error": "database connection lost"
}
}
}
{
"error": {
"code": "VERSIONING_NOT_ENABLED",
"message": "Versioning is not enabled"
}
}
restore action permissionpolicies:
employees:
admin:
actions: [read, create, update, delete, restore]
manager:
actions: [read, update, restore]
when: "user.id == resource.manager_id"
employee:
actions: [read]
when: "user.id == resource._id"