Source

The Source API allows you to create, retrieve, and delete folders, HTML documents, JSON files, and media (images, PDFs, videos, SVG).

GET - Retrieve Content

Retrieve the raw content of a file from a repository. Returns raw file content with appropriate Content-Type header.

Parameters

Headers

https://main--docket--da-pilot.aem.live/fragments/api/headers

Path

https://main--docket--da-pilot.aem.page/fragments/api/path

Examples

Request

  • curl (bash)
  • Javascript
# Get HTML file
curl -X GET \
  'https://admin.da.live/source/geometrixx/outdoors/drafts/cmillar/hello-world.html' \
  --header 'Authorization: Bearer {IMS_TOKEN}'

# Get JSON file
curl -X GET \
  'https://admin.da.live/source/geometrixx/outdoors/data/products.json' \
  --header 'Authorization: Bearer {IMS_TOKEN}'

# Get image
curl -X GET \
  'https://admin.da.live/source/geometrixx/outdoors/media/hero.png' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --output hero.png

# Get PDF
curl -X GET \
  'https://admin.da.live/source/geometrixx/outdoors/docs/guide.pdf' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --output guide.pdf
async function getSource(org, repo, path) {
  const response = await fetch(
    `https://admin.da.live/source/${org}/${repo}/${path}`,
    {
      method: 'GET',
      headers: {
        'Authorization': `Bearer ${IMS_TOKEN}`
      }
    }
  );

  if (response.status === 404) {
    throw new Error('File not found');
  }

  if (response.status === 401) {
    throw new Error('Authentication failed');
  }

  if (!response.ok) {
    throw new Error(`HTTP ${response.status}`);
  }

  return await response.text();
}

// Get HTML file
const html = await getSource('geometrixx', 'outdoors', 'index.html');

// Get JSON file
const json = await getSource('geometrixx', 'outdoors', 'data/products.json');

// Get image as blob
const imageResponse = await fetch(
  'https://admin.da.live/source/geometrixx/outdoors/media/hero.png',
  { headers: { 'Authorization': `Bearer ${IMS_TOKEN}` } }
);
const imageBlob = await imageResponse.blob();

Response

  • 200 (markup)
# HTML file response
<body>
  <header></header>
  <main>
    <div>
      <h1>Hello World</h1>
      <p>This is a test page.</p>
    </div>
  </main>
  <footer></footer>
</body>

# JSON file response
{
  "total": 2,
  "data": [
    {"name": "Product 1", "price": 29.99},
    {"name": "Product 2", "price": 49.99}
  ],
  ":type": "sheet"
}

# Images/PDFs/Media
Returns binary content

404 Not Found: Returns empty body with HTTP 404

401 Unauthorized: Returns empty body with HTTP 401

POST - Create Content

Create a Folder

Requirements: NO file extension in path, NO body data

Parameters

Headers

https://main--docket--da-pilot.aem.live/fragments/api/headers

Path

https://main--docket--da-pilot.aem.page/fragments/api/path

Examples

Request

  • curl (bash)
  • Javascript
curl -X POST \
  'https://admin.da.live/source/geometrixx/outdoors/drafts/cmillar' \
  --header 'Authorization: Bearer {IMS_TOKEN}'
async function createFolder(org, repo, path) {
  const response = await fetch(
    `https://admin.da.live/source/${org}/${repo}/${path}`,
    {
      method: 'POST',
      headers: { 'Authorization': `Bearer ${IMS_TOKEN}` }
    }
  );

  if (!response.ok) {
    throw new Error(`HTTP ${response.status}`);
  }

  return await response.json();
}

// Create folder
const folder = await createFolder('geometrixx', 'outdoors', 'drafts/cmillar');

Response

  • 201 (json)
{
  "source": {
    "editUrl": "https://da.live/geometrixx/outdoors/drafts/cmillar",
    "contentUrl": "https://content.da.live/geometrixx/outdoors/drafts/cmillar"
  },
  "aem": {
    "previewUrl": "https://main--outdoors--geometrixx.aem.page/drafts/cmillar",
    "liveUrl": "https://main--outdoors--geometrixx.aem.live/drafts/cmillar"
  }
}

401 Unauthorized: Returns empty body with HTTP 401

Create Files (HTML, JSON, Images, PDFs)

Requirements: Include file extension (.html, .json, .png), Include file data (multipart/form-data)

Parameters

Headers

https://main--docket--da-pilot.aem.live/fragments/api/headers

Path

https://main--docket--da-pilot.aem.page/fragments/api/path

Body

Use multipart/form-data with a data field

Examples

Request

  • curl (bash)
  • Javascript
# HTML file
curl -X POST \
  'https://admin.da.live/source/geometrixx/outdoors/test.html' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'data=@/path/to/test.html'

# JSON file
curl -X POST \
  'https://admin.da.live/source/geometrixx/outdoors/data.json' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'data=@/path/to/data.json'

# Image/PDF
curl -X POST \
  'https://admin.da.live/source/geometrixx/outdoors/hero.png' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'data=@/path/to/hero.png'
async function createFile(org, repo, path, fileOrContent) {
  const formData = new FormData();

  if (fileOrContent instanceof File) {
    formData.append('data', fileOrContent);
  } else {
    const blob = new Blob([fileOrContent], {
      type: path.endsWith('.json') ? 'application/json' : 'text/html'
    });
    formData.append('data', blob);
  }

  const response = await fetch(
    `https://admin.da.live/source/${org}/${repo}/${path}`,
    {
      method: 'POST',
      headers: { 'Authorization': `Bearer ${IMS_TOKEN}` },
      body: formData
    }
  );

  if (!response.ok) {
    throw new Error(`HTTP ${response.status}`);
  }

  return await response.json();
}

// HTML file
const html = await createFile('geometrixx', 'outdoors', 'test.html',
  '<body><main><h1>Test</h1></main></body>');

// JSON file
const json = await createFile('geometrixx', 'outdoors', 'data.json',
  JSON.stringify({ total: 2, data: [], ":type": "sheet" }));

// Image file
const file = document.querySelector('input[type="file"]').files[0];
const img = await createFile('geometrixx', 'outdoors', 'hero.png', file);

Response

  • 201 (json)
{
  "source": {
    "editUrl": "https://da.live/edit#/geometrixx/outdoors/test",
    "contentUrl": "https://content.da.live/geometrixx/outdoors/test"
  },
  "aem": {
    "previewUrl": "https://main--outdoors--geometrixx.aem.page/test",
    "liveUrl": "https://main--outdoors--geometrixx.aem.live/test"
  }
}

Note: Same response format for HTML, JSON, PNG, PDF, SVG files.

401 Unauthorized: Returns empty body with HTTP 401

DELETE - Remove Content

Delete files or folders. Returns HTTP 204 with empty body on success. DELETE is idempotent - deleting non-existent files returns 204.

Parameters

Headers

https://main--docket--da-pilot.aem.live/fragments/api/headers

Path

https://main--docket--da-pilot.aem.page/fragments/api/path

Examples

Request

  • curl (bash)
  • Javascript
# Delete file
curl -X DELETE \
  'https://admin.da.live/source/geometrixx/outdoors/test.html' \
  --header 'Authorization: Bearer {IMS_TOKEN}'

# Delete folder
curl -X DELETE \
  'https://admin.da.live/source/geometrixx/outdoors/drafts' \
  --header 'Authorization: Bearer {IMS_TOKEN}'
async function deleteSource(org, repo, path) {
  const response = await fetch(
    `https://admin.da.live/source/${org}/${repo}/${path}`,
    {
      method: 'DELETE',
      headers: { 'Authorization': `Bearer ${IMS_TOKEN}` }
    }
  );

  if (!response.ok && response.status !== 204) {
    throw new Error(`HTTP ${response.status}`);
  }

  return true;
}

// Delete file
await deleteSource('geometrixx', 'outdoors', 'test.html');

// Delete folder
await deleteSource('geometrixx', 'outdoors', 'drafts');

204 No Content: Success, empty body

401 Unauthorized: Returns empty body with HTTP 401