Recycle Bin
The Recycle Bin REST API provides endpoints to interact with the Recycle Bin functionality.
Reading or writing recycle bin data requires the Manage Site permission or be the actor of the document that was deleted.
List recycle bin contents
A list of all items in the recycle bin can be retrieved by sending a GET request to the @recyclebin endpoint:
GET /@recyclebin HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.getRecyclebinItems({
token: login.data.token,
});
The server will respond with a list of all recyclebin items in the site:
HTTP/1.1 200 OK
Content-Type: application/json
{
"@id": "http://localhost:8080/@recyclebin",
"items": [
{
"@id": "http://localhost:8080/events/event-3/@recyclebin/455ca717-0c68-43a0-88ac-629a72658675",
"@type": "Event",
"actions": [
{
"purge": "http://localhost:8080/events/event-3/@recyclebin/455ca717-0c68-43a0-88ac-629a72658675"
},
{
"restore": "http://localhost:8080/events/event-3/@recyclebin/455ca717-0c68-43a0-88ac-629a72658675/restore"
}
],
"deleted_by": "admin",
"deletion_date": "2023-04-02T20:10:00.000Z",
"has_children": false,
"id": "event-3",
"language": "en",
"parent_path": "/events",
"path": "/events/event-3",
"recycle_id": "455ca717-0c68-43a0-88ac-629a72658675",
"review_state": "published",
"title": "Event 3"
}
]
}
Get individual item from recycle bin
To retrieve detailed information about a specific item in the recycle bin, including its sub-items, send a GET request to @recyclebin/{item uuid}. The response includes an items list with all flattened descendants.
GET /@recyclebin/455ca717-0c68-43a0-88ac-629a72658675 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.getRecyclebinItem({
token: login.data.token,
params: { id: '455ca717-0c68-43a0-88ac-629a72658675' },
});
The server will respond with the recyclebin item:
HTTP/1.1 200 OK
Content-Type: application/json
{
"@id": "http://localhost:8080/events/event-3/@recyclebin/455ca717-0c68-43a0-88ac-629a72658675",
"@type": "Event",
"actions": [
{
"purge": "http://localhost:8080/events/event-3/@recyclebin/455ca717-0c68-43a0-88ac-629a72658675"
},
{
"restore": "http://localhost:8080/events/event-3/@recyclebin/455ca717-0c68-43a0-88ac-629a72658675/restore"
}
],
"deleted_by": "admin",
"deletion_date": "2023-04-02T20:10:00.000Z",
"has_children": false,
"id": "event-3",
"language": "en",
"parent_path": "/events",
"path": "/events/event-3",
"recycle_id": "455ca717-0c68-43a0-88ac-629a72658675",
"review_state": "published",
"title": "Event 3"
}
Restore an item from the recycle bin
An item can be restored to its original location by issuing a POST to @recyclebin/{item uuid}/restore:
POST /@recyclebin/455ca717-0c68-43a0-88ac-629a72658675/restore HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.restoreRecyclebinItem({
token: login.data.token,
params: { id: '455ca717-0c68-43a0-88ac-629a72658675' },
});
The server will respond with the restored recyclebin item:
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Document Event 3 restored successfully",
"restored_item": {
"@id": "http://localhost:8080/events/event-3",
"@type": "Event",
"id": "event-3",
"title": "Event 3"
},
"status": "success"
}
Restore to a specific location
Pass a target_path in the request body to restore the item to a different folder:
POST /@recyclebin/455ca717-0c68-43a0-88ac-629a72658675/restore HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
{
"target_path": "/news"
}
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.restoreRecyclebinItem({
token: login.data.token,
params: { id: '455ca717-0c68-43a0-88ac-629a72658675' },
data: {
target_path: '/news',
},
});
The server will respond with the restored recyclebin item:
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Document Event 3 restored successfully",
"restored_item": {
"@id": "http://localhost:8080/news/event-3",
"@type": "Event",
"id": "event-3",
"title": "Event 3"
},
"status": "success"
}
Purge a specific item from the recycle bin
To permanently delete a specific item, send a DELETE request to @recyclebin/{item uuid}:
DELETE /@recyclebin/455ca717-0c68-43a0-88ac-629a72658675 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.purgeRecyclebinItem({
token: login.data.token,
params: { id: '455ca717-0c68-43a0-88ac-629a72658675' },
});
The server will respond with an ok message:
HTTP/1.1 204 No Content
Empty the entire recycle bin
To permanently delete all items, send a DELETE request to @recyclebin:
DELETE /@recyclebin HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.purgeRecyclebinItems({
token: login.data.token,
});
The server will respond with an ok message:
HTTP/1.1 204 No Content