Enable Data Mode
Enable Data Mode for a project. Data Mode transforms PageGun into an encrypted headless CMS, storing content as AES-256-GCM encrypted files on a public CDN.
Endpoint
POST /projects/:id/data-mode/enablePath Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The project ID |
Headers
| Name | Required | Description |
|---|---|---|
Authorization | Yes | Bearer $PAGEGUN_API_KEY |
What Happens When You Enable Data Mode
- Encryption key generated — A unique AES-256-GCM encryption key is created for the project
- CDN bucket provisioned — Content storage is set up at
content.pagegun.com/{project_id}/ - Hosting mode updated — Project switches to Data Mode hosting
- Existing pages preserved — All current content remains intact and accessible
Response
{
"data": {
"project_id": "proj_abc123",
"data_mode": {
"enabled": true,
"cdn_base": "https://content.pagegun.com/proj_abc123/"
},
"encryption_key": "your-content-key-here"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
data_mode.enabled | boolean | Always true on success |
data_mode.cdn_base | string | Base URL for CDN-stored content |
encryption_key | string | Save this! Used to decrypt content client-side. Only returned once. |
⚠️ Important: The
encryption_keyis only returned in this response. Store it securely — you'll need it to consume content from the CDN.
Error Responses
| Status | Code | Description |
|---|---|---|
| 404 | not_found | Project not found |
| 409 | already_enabled | Data Mode is already active on this project |
Example
curl -X POST "https://api.pagegun.com/projects/proj_abc123/data-mode/enable" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"JavaScript
const response = await fetch(
'https://api.pagegun.com/projects/proj_abc123/data-mode/enable',
{
method: 'POST',
headers: { 'Authorization': `Bearer ${apiKey}` }
}
);
const { data } = await response.json();
// ⚠️ Save this key securely — it's only returned once
console.log('Encryption key:', data.encryption_key);
console.log('CDN base:', data.data_mode.cdn_base);How Data Mode Works
Data Mode turns PageGun into a headless CMS with encryption:
- You publish pages via the API as normal
- PageGun encrypts the content with AES-256-GCM using your project's encryption key
- Encrypted content is stored on a public CDN (
content.pagegun.com) - Your app fetches the encrypted content and decrypts it client-side using the encryption key
- Result: Your content is stored on fast public infrastructure, but only your app can read it
Architecture
Your App → fetch(CDN URL) → encrypted blob → decrypt(key) → page contentThis gives you the performance of a CDN with the security of encrypted storage.
Use Cases
- Developer docs hosted in your app — Fetch and render docs content inside your own site
- Headless blog — Use PageGun as a CMS, render content in your custom frontend
- Multi-tenant content — Serve encrypted content to different apps/environments
Related
- Disable Data Mode — Turn off Data Mode
- Hosting Modes — Compare Full Host, Rewrite, and Data Mode
- Data Mode Guide — Step-by-step integration guide