Get Started

AI Agents

AI Agent Integration

PageGun's API is designed to be consumed by AI agents and automation tools. This guide covers how to integrate PageGun into your AI-powered workflows.

Overview

AI agents (like OpenClaw, LangChain agents, or custom GPT actions) can use the PageGun API to:

  • Auto-publish documentation from code or markdown files
  • Batch-create pages from structured data
  • Sync content between your codebase and live site
  • Deploy to CDN with a single API call

Use Cases

Auto-Publishing Documentation

An agent monitors your repository and publishes updated docs whenever files change:

Text
Git push → Agent detects changes → Creates/updates pages → Publishes to CDN

Batch Page Creation

Generate dozens of pages from structured data (e.g., API specs, changelog entries):

TypeScript
const pages = [
  { slug: 'getting-started', title: 'Getting Started', content: '...' },
  { slug: 'authentication', title: 'Authentication', content: '...' },
  // ...
]

for (const page of pages) {
  await createOrUpdate(page)
  await publish(page.id)
}

Content Sync

Keep your PageGun site in sync with markdown files in your repo.

Agent Skill Configuration

If your AI agent supports skill/tool definitions, here's a reference configuration:

YAML
name: pagegun
description: Manage website content via PageGun API
base_url: https://api.pagegun.com/v1
auth:
  type: bearer
  token: ${PAGEGUN_API_KEY}

actions:
  - name: create_page
    method: POST
    path: /pages
    params: [page_name, slug, subroute, type, project_id, markdown_content]
  
  - name: update_page
    method: PUT
    path: /pages/{pageId}
    params: [markdown_content, page_name]
  
  - name: publish_page
    method: POST
    path: /pages/publish
    params: [pageId]
  
  - name: list_pages
    method: GET
    path: /pages?project_id={projectId}

Complete Workflow

Here's the full workflow from project creation to content consumption:

Step 1: Create a Project

Terminal
curl -X POST https://api.pagegun.com/v1/projects \
  -H "Authorization: Bearer pgk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-docs", "slug": "my-docs"}'

Step 2: Enable Data Mode (Optional)

Terminal
curl -X PUT https://api.pagegun.com/v1/projects/PROJECT_ID/settings \
  -H "Authorization: Bearer pgk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"data_mode": {"enabled": true}}'

Step 3: Create Pages

Terminal
curl -X POST https://api.pagegun.com/v1/pages \
  -H "Authorization: Bearer pgk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "page_name": "Quick Start",
    "slug": "quick-start",
    "subroute": "docs",
    "type": "docs",
    "project_id": "PROJECT_ID",
    "markdown_content": "# Quick Start\n\nGet up and running in 5 minutes."
  }'

Step 4: Publish

Terminal
curl -X POST https://api.pagegun.com/v1/pages/publish \
  -H "Authorization: Bearer pgk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"pageId": "PAGE_ID"}'

Step 5: Consume (Data Mode)

Terminal
curl https://content.pagegun.com/PROJECT_ID/pages/docs/quick-start/en.enc \
  -o page.enc

# Decrypt with your content key (see Data Mode Guide)

Best Practices

Idempotency

Design your automation to be idempotent — running it twice should produce the same result:

  1. Try POST /pages to create.
  2. If the slug already exists, find the page via GET /pages?project_id=xxx.
  3. Update it with PUT /pages/{id}.

Batch Operations

When creating many pages, add a small delay between requests to stay within rate limits:

TypeScript
for (const page of pages) {
  await createOrUpdate(page)
  await new Promise(r => setTimeout(r, 500)) // 500ms delay
}

Error Handling

Always check the success field in API responses:

TypeScript
const result = await api('POST', '/pages', payload)
if (!result.success) {
  console.error(`Failed: ${result.error?.message}`)
  // Retry or fall back to update
}
© 2026 PageGun. All rights reserved.