← TutorialsCDN & Media Hosting

CDN API Integration

Upload, list, and delete assets using REST API and API keys.

10 min

Use your CDN API key to upload and manage media programmatically.

Steps

  1. Create an API key in Dashboard → CDN → API Keys.
  2. Copy the key immediately — it is shown only once.
  3. Use the endpoints below with the X-API-Key header.

Code examples

// Upload file via CDN API
const formData = new FormData();
formData.append('file', fileInput.files[0]);

const res = await fetch('/api/cdn/upload', {
  method: 'POST',
  headers: { 'X-API-Key': 'qscdn_your_api_key' },
  body: formData,
});
const data = await res.json();
console.log(data.asset.cdnUrl);