Back to docs
API Reference

Templates & Page Generation

Create a design-ready template page once, then generate dozens of unique pages from it automatically using the Flint API.

What Are Templates?

A template in Flint is a fully designed page that serves as a blueprint for generating new pages at scale. You build the template once — with your brand, layout, sections, and placeholder copy — then call the API with unique content for each page you want to create. Flint's AI populates each new page using your template's design and the content you provide.

Common use cases:

  • Case studies — Generate a unique page for each customer story using the same branded layout
  • Ad landing pages — Spin up keyword-specific or audience-specific pages for paid campaigns
  • Localized pages — Create region or city pages from a single location-page template
  • Product pages — Scale product detail pages from a catalog template
  • Blog-style layouts — Generate article pages programmatically from a post template

The workflow at a glance:

  1. 1.Build or describe a template page in Flint
  2. 2.Call POST /api/v1/agent/tasks with command: "generate_pages", your template's slug, and a list of items — each with a target slug and content
  3. 3.Poll the task until it completes
  4. 4.Review generated pages via their previewUrl and optionally publish them

Creating a Template

There are two ways to create a template page in Flint: visually in the editor, or by describing it in chat.

Via the Flint Editor

Open the Flint editor and create a new page just like any other page on your site. Design the full layout — hero section, body content, testimonials, CTA, footer — using your real brand styles. Add placeholder copy where page-specific content will go (see design tips below).

The template is a real, navigable page in your site. It won't be shown to visitors (since you'll mark it hidden or give it a non-indexed path), but it drives the design of every generated page.

Via Chat

Describe the page you want to Flint's AI in the chat panel. For example: *"Create a case study template with a hero section, a challenge/solution/results layout, a metrics bar, and a CTA. Use our brand colors and fonts."*

The AI generates the page for you. Once you're happy with the design, that page becomes your template — use its slug in subsequent API calls.

Template Design Tips

  • Use descriptive placeholder copy — Write copy that signals what should be replaced, such as [Company Name], [Key Result], [Industry], or [Primary Challenge]. This helps the AI understand the intent of each section and produce accurate output.
  • Keep the structure modular — Divide content into distinct sections (hero, problem, solution, results, CTA). The more clearly delineated each section is, the more accurately the AI can populate it.
  • Avoid hardcoding page-specific details — Don't bake in the name, logo, or metrics of a particular company. Those should come from the context you pass per item in the API request.
  • Test with one page first — Before running a large batch, generate a single page and review the output. Refine your template or context format based on the result.

Slug Convention

Give your template a recognizable path that makes it easy to identify and easy to exclude from sitemaps. Recommended patterns:

  • /case-studies/template
  • /landing/template
  • /locations/template
  • /products/template

Mark the template page as Hidden in the Flint editor so it's excluded from production builds and won't appear to visitors or in search engines.

Generating Pages from a Template (API)

Use the generate_pages command to create new pages from your template. A single API call can generate up to 10 pages simultaneously, each filled with unique content.

Endpoint & Authentication

Endpoint

text
POST https://app.tryflint.com/api/v1/agent/tasks

Authentication

All requests require a Bearer token in the Authorization header:

text
Authorization: Bearer ak_your_api_key_here

API keys are created in your Flint team settings and are scoped to your organization. Any team member with at least member role permissions can create keys.

Request Payload

FieldTypeRequiredDescription
siteIdstringYesUUID of the site
commandstringYesMust be "generate_pages"
templatePageSlugstringYesSlug of the template page (e.g. "/case-studies/template")
itemsarrayYes1-10 items, each with targetPageSlug and context
publishbooleanNoWhen true, triggers a production deployment immediately. Default: false
callbackUrlstringNoHTTPS URL to receive a POST webhook when the task completes

Each item in the items array contains:

  • targetPageSlug — the URL path for the new page (e.g. "/case-studies/acme-corp")
  • context — plain-text content and instructions the AI uses to populate the page. The richer this string, the better the output.

Full Request Example

json
{
  "siteId": "550e8400-e29b-41d4-a716-446655440000",
  "command": "generate_pages",
  "templatePageSlug": "/case-studies/template",
  "items": [
    {
      "targetPageSlug": "/case-studies/acme-corp",
      "context": "Company: Acme Corp. Industry: Manufacturing. Challenge: Manual reporting took 20+ hours/week. Solution: Automated dashboard with real-time KPIs. Results: 3x ROI in 90 days, reporting time cut to 2 hours/week."
    },
    {
      "targetPageSlug": "/case-studies/globex",
      "context": "Company: Globex Inc. Industry: SaaS. Challenge: High churn in onboarding. Solution: Personalized onboarding sequences. Results: 50% reduction in churn, 35% faster time-to-value."
    }
  ],
  "publish": false
}

Response & Polling

The API responds immediately with a taskId and status: "running". Page generation happens asynchronously in the background.

Poll GET /api/v1/agent/tasks/{taskId} every ~5 seconds until the status field becomes completed or failed.

The completed response includes a pagesCreated array. Each entry contains:

  • slug — the URL path of the generated page
  • previewUrl — a live URL to preview the page before publishing
  • editUrl — a direct link to open the page in the Flint editor
  • publishedUrl — the live production URL (populated only when publish: true)

Example completed response:

json
{
  "taskId": "bg-550e8400-...",
  "status": "completed",
  "output": {
    "pagesCreated": [
      {
        "slug": "/case-studies/acme-corp",
        "previewUrl": "https://your-site.vercel.app/case-studies/acme-corp",
        "editUrl": "https://app.tryflint.com/app/edit?siteId=...&page=case-studies/acme-corp",
        "publishedUrl": null
      }
    ],
    "pagesModified": [],
    "pagesDeleted": []
  }
}

Timing Expectations

  • 1-3 pages: approximately 2-4 minutes
  • 4-10 pages: 5-10+ minutes depending on page complexity
  • Recommended batch size: 4-5 items per request for the best balance of speed and reliability

For large content sets, break them into batches of 4-5 and wait for each task to complete before submitting the next.

Publishing & Editing Generated Pages

Once pages are generated, you can preview them, publish them to production, or edit them manually.

Preview Mode (Default)

By default (publish: false), generated pages are created on your staging deployment. Use the previewUrl returned in the task response to review each page before it goes live. Share preview links with your team for feedback without affecting your public site.

Publish Mode

Set publish: true in the request to deploy pages directly to production as soon as generation completes. The publishedUrl field in the response will contain the live URL for each page.

Use this when you've already reviewed the template output and are confident in the generated quality — for example, after a successful test run with a single item.

Editing After Generation

Every generated page includes an editUrl in the task response. Click it to open the page directly in the Flint editor, where you can:

  • Make manual copy adjustments
  • Swap out images or logos
  • Refine styling or section layout
  • Add or remove sections

Edits in the Flint editor are non-destructive — changes don't affect the template or other generated pages.

Using Templates with Integrations

Templates and the generate_pages API are designed to plug into your existing workflows and automation stack.

Webhook Callbacks

Provide a callbackUrl in the request to receive a POST notification when the task finishes — instead of polling.

Requirements:
- Must be a valid HTTPS URL
- Localhost and internal IP addresses are blocked

Flint retries up to 3 times with exponential backoff (starting at 5 seconds) on any non-2xx response. The callback payload includes the task status, the taskId, and the full list of page URLs for each generated page.

See the Agent Tasks API reference for the full callback payload schema.

CI/CD & Automation

Trigger generate_pages from any backend system or automation tool:

  • GitHub Actions — add a workflow step that calls the API after a content update or PR merge
  • Zapier or Make — wire up a Zap or scenario that fires on CRM updates, form submissions, or spreadsheet changes
  • Custom backend — call the API directly from your server; use polling or callbacks to gate downstream steps

Because the API is stateless and async, it fits cleanly into event-driven pipelines.

CRM / Data Source to Pages

Pull records from a CRM (HubSpot, Salesforce), spreadsheet (Airtable, Google Sheets), or database. For each record:

  1. 1.Map the relevant fields — company name, industry, challenge, results — into a context string
  2. 2.Set the targetPageSlug based on a normalized version of the record name
  3. 3.Add the item to the items array
  4. 4.Submit in batches of up to 10

This pattern lets you keep your source of truth in your data layer and generate pages on demand whenever records are added or updated.

AI Agents

AI agents can orchestrate the entire page generation workflow autonomously:

  1. 1.Read from a data source (CRM, spreadsheet, database)
  2. 2.Build the items array dynamically from retrieved records
  3. 3.Call generate_pages with the constructed payload
  4. 4.Poll for task completion
  5. 5.Report results — including preview URLs, edit links, and any errors

This enables fully autonomous page generation pipelines with no manual steps required.

Best Practices & Limits

  • Maximum 10 items per request — for best reliability, keep batches to 4-5 items
  • One write operation at a time per site — wait for the current task to fully complete before submitting the next request. Add a ~30 second buffer after the completed status before starting a new task.
  • Write detailed context strings — the richer and more specific the context, the better the AI populates each page. Include company name, industry, quantified results, and any other relevant details.
  • Handle 429 rate-limit responses — implement exponential backoff on your polling loop. If you hit a rate limit, wait before retrying.
  • Test before batching — run a single-item request first. Inspect the output via previewUrl before scaling to a full batch.
  • Mark templates as Hidden — keep your template pages hidden in Flint so they don't appear in sitemaps or to visitors.

Error Handling & Troubleshooting

Common HTTP errors

StatusErrorCause
400"Site is missing repository information"Site not properly configured — contact support
400"Invalid callback URL"callbackUrl is not a valid HTTPS URL
404"Site not found"Incorrect siteId
429Rate limitedToo many requests — wait and retry with backoff
500"Failed to start task"Internal error — retry after a short delay

Task returns failed status

Check the errorMessage field in the GET response. Common causes include malformed context strings, a template slug that doesn't exist on the site, or an internal generation error. Retry with a corrected payload.

"Another write operation is already in progress"

Only one write operation can run at a time per site. Wait for the previous task to reach completed or failed status, add a ~30 second buffer, then submit the next request.

Output arrays are empty

If pagesCreated, pagesModified, and pagesDeleted are all empty arrays, the task completed without making changes. Verify that:
- The templatePageSlug refers to a page that exists on the site
- The targetPageSlug values are valid URL paths
- The task didn't encounter a silent error (check errorMessage if present)

API Quick Reference

ActionMethodEndpoint
Create taskPOST/api/v1/agent/tasks
Check statusGET/api/v1/agent/tasks/{taskId}

Task statuses: running then either completed or failed

Output arrays: pagesCreated, pagesModified, pagesDeleted

Base URL: https://app.tryflint.com

See the full Agent Tasks API reference for additional commands, prompt-based tasks, and more examples.