Copy

The Copy API allows you to copy files to a new destination within the same repository.

POST

Parameters

Headers

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

Path

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

Body

Content-Type: multipart/form-data

Examples

Copy a File

  • curl (bash)
  • Javascript
curl -X POST \
  'https://admin.da.live/copy/geometrixx/outdoors/drafts/cmillar/article.html' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'destination=/drafts/cmillar/article-backup.html'
async function copyFile(org, repo, sourcePath, destinationPath) {
  const formData = new FormData();
  formData.append('destination', destinationPath);

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

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

  if (response.status === 500) {
    const error = await response.text();
    throw new Error(`Server error: ${error}`);
  }

  if (response.status === 204) {
    return { success: true };
  }

  throw new Error(`Unexpected status: ${response.status}`);
}

// Usage
await copyFile(
  'geometrixx',
  'outdoors',
  '/drafts/cmillar/article.html',
  '/drafts/cmillar/article-backup.html'
);

Copy Different File Types

  • curl (bash)
# Copy HTML file
curl -X POST \
  'https://admin.da.live/copy/geometrixx/outdoors/drafts/article.html' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'destination=/archive/article.html'

# Copy JSON file
curl -X POST \
  'https://admin.da.live/copy/geometrixx/outdoors/data/config.json' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'destination=/data/config-backup.json'

# Copy image
curl -X POST \
  'https://admin.da.live/copy/geometrixx/outdoors/media/hero.png' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'destination=/media/hero-copy.png'

# Copy PDF
curl -X POST \
  'https://admin.da.live/copy/geometrixx/outdoors/docs/guide.pdf' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'destination=/docs/guide-v2.pdf'

# Copy SVG
curl -X POST \
  'https://admin.da.live/copy/geometrixx/outdoors/assets/logo.svg' \
  --header 'Authorization: Bearer {IMS_TOKEN}' \
  --form 'destination=/assets/logo-backup.svg'

Response

  • 204 (markup)
Empty response body

HTTP 204 No Content indicates successful copy

Behavior Notes:

Error Responses: