AI Agent Integration
PageGun is designed for AI agents to create and manage websites autonomously. Every feature is accessible via REST API with structured JSON — the format AI agents work best with.
Why PageGun for AI Agents
- Structured input/output — Pages are JSON configs, not WYSIWYG. AI agents can generate valid page configs natively.
- Full API coverage — Create, update, publish, and manage pages without ever touching a UI.
- Semantic sections — Section types like
hero,features,faqmap directly to content concepts AI understands. - Predictable responses — Consistent JSON responses make error handling straightforward.
Quick Start for Agents
1. Set Up Authentication
export PAGEGUN_API_KEY="pgk_live_your_key"2. Discover Projects
curl -s "https://api.pagegun.com/projects" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" | jq '.data[].{id, name}'3. Create a Page
curl -X POST "https://api.pagegun.com/pages" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"page_name": "AI Generated Landing Page",
"slug": "ai-landing",
"subroute": "pages",
"type": "page",
"project_id": "PROJECT_ID",
"config": {
"sections": [
{
"type": "hero",
"heading": "Built by AI, Loved by Humans",
"description": "This page was created entirely by an AI agent.",
"ctaText": "Learn More",
"ctaHref": "/about"
},
{
"type": "features",
"heading": "Why It Works",
"features": [
{ "title": "Fast", "description": "Pages created in seconds.", "icon": "Zap" },
{ "title": "Consistent", "description": "Every page follows best practices.", "icon": "CheckCircle" },
{ "title": "Scalable", "description": "Create thousands of pages programmatically.", "icon": "TrendingUp" }
]
}
]
}
}'4. Publish
curl -X POST "https://api.pagegun.com/pages/PAGE_ID/publish" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"What AI Agents Can Do
| Task | API Calls | Example |
|---|---|---|
| Create a landing page | POST /pages → POST /pages/:id/publish | Generate pages from product descriptions |
| Manage a blog | POST /pages (type: article) | Auto-publish SEO articles on a schedule |
| Build documentation | POST /pages (type: docs) | Generate docs from code comments |
| Run a directory | POST /pages (type: item) | Curate tool/resource listings |
| Update content | PUT /pages/:id → POST /pages/:id/publish | Refresh outdated content |
| A/B test pages | Create variants, publish/unpublish | Test different headlines or layouts |
Idempotent Operations
Agents running on loops should avoid creating duplicates:
# Check if page exists before creating
EXISTING=$(curl -s "https://api.pagegun.com/pages?project_id=$PROJECT_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
| jq -r ".data[] | select(.slug == \"$SLUG\") | .id")
if [ -n "$EXISTING" ]; then
# Update
curl -X PUT "https://api.pagegun.com/pages/$EXISTING" ...
else
# Create
curl -X POST "https://api.pagegun.com/pages" ...
fiBuilding an Agent Skill
For agents that use skill-based architectures (like OpenClaw), you can create a PageGun skill:
name: pagegun
description: Create and manage pages via PageGun API
tools: [exec, web_fetch]Best Practices
- Store API key securely — Never hardcode in prompts or skill files
- Discover before creating — Always check existing pages to avoid duplicates
- Respect rate limits — 100 req/min; add
sleep 0.7between batch operations - Validate before publishing — Check that required fields exist
- Use meaningful slugs — AI-generated slugs should be readable and SEO-friendly
Related
- Agent Skill Template — Build a PageGun skill for your agent
- Agent Best Practices — Error handling, retries, patterns
- API Reference — Complete endpoint documentation