Skip to content

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:

FieldTypeRequiredDescription
namestringYesHuman-readable template name.
card_template_idstringYesReference to the card rendering template.
fieldsarrayYesField definitions. Each has name, type (string/number/boolean/date/array), optional required, schema_org, instructions.
descriptionstringNoDescription of the template’s purpose.
slug_instructionsstringNoGuide for URL slug generation.
schema_org_typestringNoSchema.org type for JSON-LD (e.g., TechArticle, RealEstateListing).
default_sitemap_prioritynumberNoDefault sitemap_priority for pages using this template (0.0–1.0).
default_sitemap_changefreqstringNoDefault change frequency. One of: always, hourly, daily, weekly, monthly, yearly, never.

Endpoint catalog:

MethodRouteAuthPurpose
GET/api/templates/docAdminList all document templates
GET/api/templates/doc/:idAdminGet a document template
POST/api/templates/docAdminCreate document template
PATCH/api/templates/doc/:idAdminPartial update
DELETE/api/templates/doc/:idAdminSoft delete (status=disabled)
GET/api/projects/:projectId/templatesManagerList assigned templates (resolved)
POST/api/projects/:projectId/templates/:templateIdManagerAdd template to project
DELETE/api/projects/:projectId/templates/:templateIdManagerRemove template from project

Example

List all active document templates:

Terminal window
curl https://api.comstack.ai/api/templates/doc \
-H "Authorization: Bearer <firebase-id-token>"

Assign a template to a project:

Terminal window
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.

Last updated: