Get Started

API Reference

Publishing

Publishing deploys a page snapshot to PageGun's global CDN (Cloudflare R2). Once published, the page is publicly accessible at its configured URL.

How Publishing Works

When you publish a page, PageGun:

  1. Takes a snapshot of the current page content
  2. Uploads to CDN — The rendered page is stored on Cloudflare R2
  3. Updates the page index — The project's page manifest is regenerated
  4. Enables Data Mode encryption — If Data Mode is active, content is encrypted before upload

Pages start as drafts. They're only visible publicly after being explicitly published.

Text
Draft → Publish → Live on CDN
                ↕
              Unpublish → Removed from CDN

Publish a Page

HTTP
POST /v1/pages/publish

Publishes a page to CDN, making it publicly accessible.

Request Body

NameTypeRequiredDescription
pageIdstringYesID of the page to publish

Request

Terminal
curl -X POST https://api.pagegun.com/v1/pages/publish \
  -H "Authorization: Bearer pgk_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{"pageId": "DgTgGtE9"}'
TypeScript
const response = await fetch("https://api.pagegun.com/v1/pages/publish", {
  method: "POST",
  headers: {
    Authorization: "Bearer pgk_live_xxxxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ pageId: "DgTgGtE9" }),
});

const { data } = await response.json();

Response

JSON
{
  "success": true,
  "data": {
    "page_id": "DgTgGtE9",
    "status": "published",
    "published_at": "2024-03-15T14:30:00Z"
  }
}

Unpublish a Page

HTTP
POST /v1/pages/unpublish

Removes a page from CDN. The page content is preserved but no longer publicly accessible.

Request Body

NameTypeRequiredDescription
pageIdstringYesID of the page to unpublish

Request

Terminal
curl -X POST https://api.pagegun.com/v1/pages/unpublish \
  -H "Authorization: Bearer pgk_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{"pageId": "DgTgGtE9"}'
TypeScript
const response = await fetch("https://api.pagegun.com/v1/pages/unpublish", {
  method: "POST",
  headers: {
    Authorization: "Bearer pgk_live_xxxxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ pageId: "DgTgGtE9" }),
});

const { data } = await response.json();

Response

JSON
{
  "success": true,
  "data": {
    "page_id": "DgTgGtE9",
    "status": "unpublished"
  }
}

Complete Workflow Example

Here's a full example: create a page, add content, and publish it.

TypeScript
const API_KEY = "pgk_live_xxxxx";
const BASE_URL = "https://api.pagegun.com/v1";

async function api(method: string, path: string, body?: object) {
  const response = await fetch(`${BASE_URL}${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  return response.json();
}

// 1. Create a page
const { data: page } = await api("POST", "/pages", {
  project_id: "MgdGoare",
  page_name: "Changelog",
  slug: "changelog",
  type: "doc",
  markdown_content: "# Changelog\n\n## v1.0.0\n\n- Initial release",
});

console.log(`Created page: ${page.id}`);

// 2. Publish it
await api("POST", "/pages/publish", { pageId: page.id });

console.log("Page is now live!");

// 3. Update content later
await api("PUT", `/pages/${page.id}`, {
  markdown_content: "# Changelog\n\n## v1.1.0\n\n- New feature\n\n## v1.0.0\n\n- Initial release",
});

// 4. Republish with updated content
await api("POST", "/pages/publish", { pageId: page.id });

console.log("Updated page republished!");
© 2026 PageGun. All rights reserved.