Client Onboarding Templates API
All endpoints require authentication and templates tool permissions. Routes are mounted under /api/admin.
Templates
Section titled “Templates”List Templates
Section titled “List Templates”GET /api/admin/onboarding-templates/clientReturns all client onboarding templates with computed stage_count, milestone_count, and clients_using counts.
Permission: templates:view
Response: { templates }
Get Template Detail
Section titled “Get Template Detail”GET /api/admin/onboarding-templates/client/:idReturns a template with nested stages and milestones, plus a count of clients currently using the template.
Permission: templates:view
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Response: { template, stages, clients_using }
Each stage includes a nested milestones array.
Error: 404 if template not found.
Create Template
Section titled “Create Template”POST /api/admin/onboarding-templates/clientPermission: templates:update
Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
description | string | No | Template description |
Response: { template } (201)
Update Template
Section titled “Update Template”PATCH /api/admin/onboarding-templates/client/:idPermission: templates:update
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Body (all fields optional):
| Field | Type | Description |
|---|---|---|
name | string | Template name |
description | string | Description |
is_default | boolean | Set as the default template (clears other defaults) |
is_active | boolean | Active status |
Response: { template }
Delete Template
Section titled “Delete Template”DELETE /api/admin/onboarding-templates/client/:idIf the template is in use by clients, it is soft-disabled (is_active = 0). Otherwise, it is hard-deleted (cascading to stages and milestones).
Permission: templates:manage
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Response: { ok: true } or { ok: true, soft_disabled: true }
Duplicate Template
Section titled “Duplicate Template”POST /api/admin/onboarding-templates/client/:id/duplicateCreates a copy of the template including all stages and milestones. The copy is named {original name} (Copy).
Permission: templates:update
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Source template ID |
Response: { template } (201)
Error: 404 if source template not found.
Reorder Stages and Milestones
Section titled “Reorder Stages and Milestones”PATCH /api/admin/onboarding-templates/client/:id/reorderBulk reorder stages and/or milestones within a template. Milestones can also be moved between stages.
Permission: templates:update
Body:
| Field | Type | Required | Description |
|---|---|---|---|
stages | array | No | Array of { id, sort_order } |
milestones | array | No | Array of { id, stage_id, sort_order } |
Response: { ok: true }
Stages
Section titled “Stages”Create Stage
Section titled “Create Stage”POST /api/admin/onboarding-templates/client/:id/stagesPermission: templates:update
Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Stage name |
stage_type | string | Yes | Stage type identifier |
description | string | No | Stage description |
color | string | No | Display color |
Response: { stage } (201)
Update Stage
Section titled “Update Stage”PATCH /api/admin/onboarding-templates/client/:id/stages/:stageIdPermission: templates:update
Body (all fields optional): name, description, stage_type, color, sort_order
Response: { stage }
Delete Stage
Section titled “Delete Stage”DELETE /api/admin/onboarding-templates/client/:id/stages/:stageIdPermission: templates:manage
Response: { ok: true }
Milestones
Section titled “Milestones”Create Milestone
Section titled “Create Milestone”POST /api/admin/onboarding-templates/client/stages/:stageId/milestonesPermission: templates:update
Body:
| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Milestone title |
description | string | No | Milestone description |
is_required | boolean | No | Whether milestone is required (default: true) |
auto_source | string|null | No | Auto-completion trigger (e.g. deal_won, project_created, first_invoice) |
Response: { milestone } (201)
Update Milestone
Section titled “Update Milestone”PATCH /api/admin/onboarding-templates/client/milestones/:milestoneIdPermission: templates:update
Body (all fields optional): title, description, is_required, auto_source, sort_order
Response: { milestone }
Delete Milestone
Section titled “Delete Milestone”DELETE /api/admin/onboarding-templates/client/milestones/:milestoneIdPermission: templates:manage
Response: { ok: true }