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:

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

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:

Error Responses:

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:

Common Labels:

Behavior Notes:

Error Responses:

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

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:

Error Responses:

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:

Version Storage

Versions are stored in S3 at: {org}/.da-versions/{fileID}/{versionID}.{ext}

Best Practices

  1. Label important versions - Use meaningful labels for manual versions ("Before Migration", "Release 1.0", etc.)
  2. Wait after creation - Allow 2-3 seconds for version indexing before listing
  3. Sort versions - The API doesn't guarantee order, always sort by timestamp
  4. Check content length - Only versions with contentLength > 0 appear in lists
  5. Use version URLs - Don't manually construct version paths, use URLs from the list response