Version
The Version API allows you to create and retrieve versions of HTML and JSON source files. Versions are automatically created when you update files through the Source API.
Supported File Types:
- HTML files (
text/html) - JSON files (
application/json)
Note: Other file types (images, PDFs, etc.) do not support versioning.
Create Version
POST /versionsource/{org}/{repo}/{path}
Creates a snapshot version of the current file state.
Parameters
Headers
https://main--docket--da-pilot.aem.live/fragments/api/headers
Path
https://main--docket--da-pilot.aem.page/fragments/api/path
Body (Optional)
Content-Type: application/json
label(optional) - Custom label for this version (e.g., "Before Migration", "Backup")
Examples
Create Version with Label
- curl (bash)
- Javascript
curl -X POST \
'https://admin.da.live/versionsource/geometrixx/outdoors/drafts/article.html' \
--header 'Authorization: Bearer {IMS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{"label": "Before Major Edit"}'
async function createVersion(org, repo, filePath, label) {
const body = label ? JSON.stringify({ label }) : undefined;
const response = await fetch(
`https://admin.da.live/versionsource/${org}/${repo}${filePath}`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${IMS_TOKEN}`,
'Content-Type': 'application/json'
},
body
}
);
if (response.status === 401) {
throw new Error('Authentication failed');
}
if (response.status === 201) {
return { success: true };
}
throw new Error(`Unexpected status: ${response.status}`);
}
// Usage - create version with custom label
await createVersion('geometrixx', 'outdoors', '/drafts/article.html', 'Before Migration');
// Usage - create version without label
await createVersion('geometrixx', 'outdoors', '/data/config.json');
Response
- 201 (markup)
Empty response body
HTTP 201 Created indicates version was created successfully
Behavior Notes:
- Returns 201 with empty body (no GUID or version metadata returned)
- Versions are stored with timestamp, user information, and optional label
- To access the version, use the List Versions endpoint to get the version URL
- Automatic versioning also occurs when updating files via PUT to the Source API
Error Responses:
- 401 Unauthorized - Invalid or missing authentication token (empty body)
List Versions
GET /versionlist/{org}/{repo}/{path}
Returns a list of all versions for a given file, sorted by timestamp.
Parameters
Headers
https://main--docket--da-pilot.aem.live/fragments/api/headers
Path
https://main--docket--da-pilot.aem.page/fragments/api/path
Examples
List Versions
- curl (bash)
- Javascript
curl -X GET \
'https://admin.da.live/versionlist/geometrixx/outdoors/data/config.json' \
--header 'Authorization: Bearer {IMS_TOKEN}'
async function listVersions(org, repo, filePath) {
const response = await fetch(
`https://admin.da.live/versionlist/${org}/${repo}${filePath}`,
{
method: 'GET',
headers: {
'Authorization': `Bearer ${IMS_TOKEN}`,
'Accept': 'application/json'
}
}
);
if (response.status === 401) {
throw new Error('Authentication failed');
}
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return await response.json();
}
// Usage
const versions = await listVersions('geometrixx', 'outdoors', '/data/config.json');
// Sort by timestamp (newest first)
versions.sort((a, b) => b.timestamp - a.timestamp);
// Display version history
versions.forEach((version, index) => {
const date = new Date(version.timestamp);
const label = version.label || 'Auto-saved';
console.log(`${index + 1}. ${label} - ${date.toLocaleString()}`);
console.log(` By: ${version.users[0].email}`);
console.log(` URL: ${version.url}`);
});
Response
- 200 (json)
[
{
"url": "/versionsource/geometrixx/41c8fe93-6920-4353-9fef-4ea3b2d09922/aa449650-b75c-463b-ae57-15902cd21a86.json",
"users": [
{
"email": "[email protected]"
}
],
"timestamp": 1770848960273,
"path": "outdoors/data/config.json",
"label": "Before Migration"
},
{
"url": "/versionsource/geometrixx/41c8fe93-6920-4353-9fef-4ea3b2d09922/adfcc67d-8088-4be3-9578-4dea9f81fc32.json",
"users": [
{
"email": "[email protected]"
}
],
"timestamp": 1770848900000,
"path": "outdoors/data/config.json",
"label": "Collab Parse"
},
{
"url": "/versionsource/geometrixx/7bc4d89a-1234-5678-9abc-def012345678/98765432-abcd-ef01-2345-6789abcdef01.json",
"users": [
{
"email": "[email protected]"
}
],
"timestamp": 1770848000000,
"path": "outdoors/data/config.json"
}
]
Response Fields:
url- Full path to retrieve the version content (use with GET request)users- Array of users who created the version (contains email)timestamp- Unix timestamp in milliseconds when version was createdpath- Relative path within the repository (format:repo/path/to/file)label- Optional label for the version (e.g., "Collab Parse", custom labels)
Common Labels:
Collab Parse- Automatically created during collaborative editingRestore Point- Created before emptying document content- Custom labels - Set via the POST request
Behavior Notes:
- Returns empty array
[]if file has no versions or doesn't exist - Array may not be sorted - sort by timestamp if chronological order is needed
- Only versions with content (
contentLength > 0) are included in the list
Error Responses:
- 401 Unauthorized - Invalid or missing authentication token (empty body)
Get Version Content
GET /versionsource/{org}/{versionGuid}/{fileGuid}.{ext}
Retrieves the content of a specific version using the URL from the version list.
Parameters
Headers
https://main--docket--da-pilot.aem.live/fragments/api/headers
Path
org- Organization nameversionGuid- First GUID from the version URL (file ID)fileGuid- Second GUID from the version URL (version ID)ext- File extension (json, html, etc.)
Examples
Get Version Content
- curl (bash)
- Javascript
# First, get the version URL from the list
curl -X GET \
'https://admin.da.live/versionlist/geometrixx/outdoors/data/config.json' \
--header 'Authorization: Bearer {IMS_TOKEN}'
# Then use the URL from the response
curl -X GET \
'https://admin.da.live/versionsource/geometrixx/41c8fe93-6920-4353-9fef-4ea3b2d09922/aa449650-b75c-463b-ae57-15902cd21a86.json' \
--header 'Authorization: Bearer {IMS_TOKEN}'
async function getVersionContent(org, repo, filePath, versionIndex = 0) {
// 1. List versions to get the version URL
const listResponse = await fetch(
`https://admin.da.live/versionlist/${org}/${repo}${filePath}`,
{
headers: {
'Authorization': `Bearer ${IMS_TOKEN}`,
'Accept': 'application/json'
}
}
);
const versions = await listResponse.json();
if (versions.length === 0) {
throw new Error('No versions found');
}
// 2. Sort by timestamp (newest first) and get the desired version
versions.sort((a, b) => b.timestamp - a.timestamp);
const version = versions[versionIndex];
if (!version) {
throw new Error(`Version ${versionIndex} not found`);
}
// 3. Fetch the version content using the URL
const versionResponse = await fetch(
`https://admin.da.live${version.url}`,
{
headers: {
'Authorization': `Bearer ${IMS_TOKEN}`
}
}
);
if (!versionResponse.ok) {
throw new Error(`Failed to retrieve version: ${versionResponse.status}`);
}
// 4. Return content based on file type
const contentType = versionResponse.headers.get('content-type');
if (contentType?.includes('application/json')) {
return await versionResponse.json();
}
return await versionResponse.text();
}
// Usage - get latest version
const latestVersion = await getVersionContent('geometrixx', 'outdoors', '/data/config.json', 0);
// Usage - get older version (1 = second newest, 2 = third newest, etc.)
const olderVersion = await getVersionContent('geometrixx', 'outdoors', '/data/config.json', 2);
Response
- 200 HTML (markup)
- 200 JSON (json)
<html>
<head><title>Article</title></head>
<body>
<h1>Archived Content</h1>
<p>This is the content from version 2.</p>
</body>
</html>
{
"title": "Site Configuration",
"theme": "dark",
"version": "1.0",
"updated": "2026-02-10"
}
Behavior Notes:
- Returns the raw file content exactly as it was at the time of versioning
- Must use the exact URL from the version list - manual GUID construction is not reliable
- Content-Type header matches the original file type
Error Responses:
- 403 Forbidden - Invalid version GUID or access denied
- 401 Unauthorized - Invalid or missing authentication token
Complete Workflow Example
Create, List, and Restore Versions
- Javascript
// Complete versioning workflow
async function versionWorkflow(org, repo, filePath) {
// 1. Create a labeled version before making changes
await fetch(
`https://admin.da.live/versionsource/${org}/${repo}${filePath}`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${IMS_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ label: 'Before redesign' })
}
);
console.log('Version created');
// 2. Wait for indexing
await new Promise(resolve => setTimeout(resolve, 3000));
// 3. List all versions
const listResponse = await fetch(
`https://admin.da.live/versionlist/${org}/${repo}${filePath}`,
{ headers: { 'Authorization': `Bearer ${IMS_TOKEN}` } }
);
const versions = await listResponse.json();
// Sort by timestamp (newest first)
versions.sort((a, b) => b.timestamp - a.timestamp);
console.log(`Found ${versions.length} versions:`);
versions.forEach((v, i) => {
const date = new Date(v.timestamp).toLocaleString();
const label = v.label || 'Auto-saved';
console.log(` ${i + 1}. ${label} - ${date}`);
});
// 4. Restore an old version (get content from version and update current file)
const oldVersion = versions[1]; // Get second-to-last version
if (oldVersion) {
// Get old version content
const versionResponse = await fetch(
`https://admin.da.live${oldVersion.url}`,
{ headers: { 'Authorization': `Bearer ${IMS_TOKEN}` } }
);
const oldContent = await versionResponse.text();
// Update current file with old content (restore)
const formData = new FormData();
formData.append('data', oldContent);
await fetch(
`https://admin.da.live/source/${org}/${repo}${filePath}`,
{
method: 'POST',
headers: { 'Authorization': `Bearer ${IMS_TOKEN}` },
body: formData
}
);
console.log('Version restored successfully');
}
}
// Usage
await versionWorkflow('geometrixx', 'outdoors', '/drafts/article.html');
Version API Behavior
Automatic Versioning
Versions are automatically created in these scenarios:
- File Updates - When updating HTML or JSON files via PUT to the Source API
- Collaborative Editing - During real-time collaboration (labeled "Collab Parse")
- Before Deletion - When document content is about to be emptied (labeled "Restore Point")
Version Storage
Versions are stored in S3 at: {org}/.da-versions/{fileID}/{versionID}.{ext}
- Each file has a unique
fileID(generated on first creation) - Each version has a unique
versionID(generated on each version creation) - Version metadata includes: users, timestamp, path, and optional label
Best Practices
- Label important versions - Use meaningful labels for manual versions ("Before Migration", "Release 1.0", etc.)
- Wait after creation - Allow 2-3 seconds for version indexing before listing
- Sort versions - The API doesn't guarantee order, always sort by timestamp
- Check content length - Only versions with
contentLength > 0appear in lists - Use version URLs - Don't manually construct version paths, use URLs from the list response