Calafai Docs

Templates API Reference

Templates API Reference

Engagement templates allow tenants to save reusable engagement configurations. The platform ships with five system templates (brand_digital_presence, business_transformation, go_to_market, product_strategy, research_deep_dive), and tenants can create their own.

Base URL: /api/templates

Authentication: All endpoints require authentication (cookie session or Bearer API key).


List Templates

GET /api/templates

Returns all templates visible to the authenticated tenant. This includes system templates (isSystem: true, tenantId: null) and any templates created by the tenant.

Response

{
  "templates": [
    {
      "id": "clxyz123abc",
      "name": "Brand Digital Presence",
      "slug": "brand_digital_presence",
      "description": "Comprehensive brand audit and digital presence strategy",
      "brief": "Analyze the client's current brand positioning...",
      "budget": 5.0,
      "tasks": [
        {
          "id": "brand_audit",
          "name": "Brand Audit",
          "agent": "research_intelligence_analyst",
          "description": "..."
        }
      ],
      "options": {},
      "isSystem": true,
      "tenantId": null,
      "createdAt": "2025-01-15T10:30:00.000Z"
    }
  ]
}

Example

curl -X GET https://app.groundtruth.ai/api/templates \
  -H "Authorization: Bearer gt_live_abc123..."

Create Template

POST /api/templates

Creates a new tenant-specific template. Requires write access (read_write API key scope or member+ role via session).

Request Body

FieldTypeRequiredDescription
namestringYesTemplate display name
descriptionstringYesShort description of the template
briefstringYesDefault engagement brief text
budgetnumberNoDefault budget in USD (default: 5.0)
tasksarrayNoArray of task configuration objects
optionsobjectNoAdditional template options

The slug is auto-generated from the name field (lowercased, spaces replaced with underscores, special characters removed).

Response

Status: 201 Created

{
  "template": {
    "id": "clxyz456def",
    "name": "Custom Research Template",
    "slug": "custom_research_template",
    "description": "A tailored research engagement template",
    "brief": "Conduct deep research into...",
    "budget": 3.5,
    "tasks": [],
    "options": {},
    "isSystem": false,
    "tenantId": "clxyz789ghi",
    "createdAt": "2025-06-01T14:00:00.000Z"
  }
}

Example

curl -X POST https://app.groundtruth.ai/api/templates \
  -H "Authorization: Bearer gt_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Custom Research Template",
    "description": "A tailored research engagement template",
    "brief": "Conduct deep research into the competitive landscape...",
    "budget": 3.5,
    "tasks": [
      {
        "id": "competitive_analysis",
        "name": "Competitive Analysis",
        "agent": "research_intelligence_analyst",
        "description": "Analyze top 10 competitors in the space"
      }
    ]
  }'

Get Template

GET /api/templates/:id

Returns a single template by ID. The template must be either a system template or belong to the authenticated tenant.

Path Parameters

ParameterTypeDescription
idstringTemplate ID

Response

{
  "template": {
    "id": "clxyz123abc",
    "name": "Brand Digital Presence",
    "slug": "brand_digital_presence",
    "description": "Comprehensive brand audit and digital presence strategy",
    "brief": "Analyze the client's current brand positioning...",
    "budget": 5.0,
    "tasks": [...],
    "options": {},
    "isSystem": true,
    "tenantId": null,
    "createdAt": "2025-01-15T10:30:00.000Z"
  }
}

Example

curl -X GET https://app.groundtruth.ai/api/templates/clxyz123abc \
  -H "Authorization: Bearer gt_live_abc123..."

Errors

StatusDescription
404Template not found or not accessible to the tenant

Delete Template

DELETE /api/templates/:id

Deletes a tenant-specific template. Requires write access. System templates cannot be deleted.

Path Parameters

ParameterTypeDescription
idstringTemplate ID

Response

{
  "success": true
}

Example

curl -X DELETE https://app.groundtruth.ai/api/templates/clxyz456def \
  -H "Authorization: Bearer gt_live_abc123..."

Errors

StatusDescription
403Cannot delete system templates
404Template not found or not accessible to the tenant

On this page