Template Management API
What is this
REST endpoints to manage page templates (document templates) and project templates globally, as well as to assign templates to specific projects.
Route prefixes:
/api/templates/doc/…— Global CRUD for document templates (admin only)/api/templates/project/…— Global CRUD for project templates (admin only)/api/projects/:projectId/templates— Template assignment per project (manager)
How it works
Document templates define the structured layout of a content type: which fields it requires, which JSON-LD schema it emits, and how the AI should extract content into it. Project templates define a project type: which document templates are available and which plan limits apply based on the tier.
Global write operations require platform administrator access. Project-level assignment requires the manager or admin role within the project.
The same operations are available as MCP tools — create-doc-template, update-doc-template, assign-project-template, among others — for administrator users working within Claude or Cursor.
When to use it
- Create a new content type for your project (e.g., a property listing or a team member template)
- Assign or remove templates from a specific project
- List templates to understand what is available before creating pages
- Soft-delete a template that should no longer be used (soft-deletion preserves existing pages)
Parameters / fields / inputs
Document template — key fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Human-readable template name. |
card_template_id | string | Yes | Reference to the card rendering template. |
fields | array | Yes | Field definitions. Each has name, type (string/number/boolean/date/array), optional required, schema_org, instructions. |
description | string | No | Description of the template’s purpose. |
slug_instructions | string | No | Guide for URL slug generation. |
schema_org_type | string | No | Schema.org type for JSON-LD (e.g., TechArticle, RealEstateListing). |
default_sitemap_priority | number | No | Default sitemap_priority for pages using this template (0.0–1.0). |
default_sitemap_changefreq | string | No | Default change frequency. One of: always, hourly, daily, weekly, monthly, yearly, never. |
Endpoint catalog:
| Method | Route | Auth | Purpose |
|---|---|---|---|
| GET | /api/templates/doc | Admin | List all document templates |
| GET | /api/templates/doc/:id | Admin | Get a document template |
| POST | /api/templates/doc | Admin | Create document template |
| PATCH | /api/templates/doc/:id | Admin | Partial update |
| DELETE | /api/templates/doc/:id | Admin | Soft delete (status=disabled) |
| GET | /api/projects/:projectId/templates | Manager | List assigned templates (resolved) |
| POST | /api/projects/:projectId/templates/:templateId | Manager | Add template to project |
| DELETE | /api/projects/:projectId/templates/:templateId | Manager | Remove template from project |
Example
List all active document templates:
curl https://api.comstack.ai/api/templates/doc \ -H "Authorization: Bearer <firebase-id-token>"Assign a template to a project:
curl -X POST https://api.comstack.ai/api/projects/your-project-id/templates/property-listing-v1 \ -H "Authorization: Bearer <firebase-id-token>"Common errors
401 Unauthorized — Firebase ID token is missing or expired.
403 Forbidden — Not a platform administrator (global CRUD) or not a manager (project assignment).
404 Not found — The template or project ID does not exist.
409 Conflict (creation) — A template with that ID already exists.
409 Conflict (soft-delete) — The template is assigned to one or more projects. Remove the assignments first.
409 Conflict (project assignment) — The template is already assigned to this project.
400 (referential integrity) — available_doc_templates references a template that does not exist or is disabled.
Related
- MCP Server —
create-doc-template,assign-project-templateand related MCP tools - API Overview — Full index of endpoints
- Authentication — Role requirements