Skip to content

Client Onboarding Templates API

All endpoints require authentication and templates tool permissions. Routes are mounted under /api/admin.

GET /api/admin/onboarding-templates/client

Returns all client onboarding templates with computed stage_count, milestone_count, and clients_using counts.

Permission: templates:view

Response: { templates }


GET /api/admin/onboarding-templates/client/:id

Returns a template with nested stages and milestones, plus a count of clients currently using the template.

Permission: templates:view

Path parameters:

ParamTypeDescription
idstringTemplate ID

Response: { template, stages, clients_using }

Each stage includes a nested milestones array.

Error: 404 if template not found.


POST /api/admin/onboarding-templates/client

Permission: templates:update

Body:

FieldTypeRequiredDescription
namestringYesTemplate name
descriptionstringNoTemplate description

Response: { template } (201)


PATCH /api/admin/onboarding-templates/client/:id

Permission: templates:update

Path parameters:

ParamTypeDescription
idstringTemplate ID

Body (all fields optional):

FieldTypeDescription
namestringTemplate name
descriptionstringDescription
is_defaultbooleanSet as the default template (clears other defaults)
is_activebooleanActive status

Response: { template }


DELETE /api/admin/onboarding-templates/client/:id

If 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:

ParamTypeDescription
idstringTemplate ID

Response: { ok: true } or { ok: true, soft_disabled: true }


POST /api/admin/onboarding-templates/client/:id/duplicate

Creates a copy of the template including all stages and milestones. The copy is named {original name} (Copy).

Permission: templates:update

Path parameters:

ParamTypeDescription
idstringSource template ID

Response: { template } (201)

Error: 404 if source template not found.


PATCH /api/admin/onboarding-templates/client/:id/reorder

Bulk reorder stages and/or milestones within a template. Milestones can also be moved between stages.

Permission: templates:update

Body:

FieldTypeRequiredDescription
stagesarrayNoArray of { id, sort_order }
milestonesarrayNoArray of { id, stage_id, sort_order }

Response: { ok: true }


POST /api/admin/onboarding-templates/client/:id/stages

Permission: templates:update

Body:

FieldTypeRequiredDescription
namestringYesStage name
stage_typestringYesStage type identifier
descriptionstringNoStage description
colorstringNoDisplay color

Response: { stage } (201)


PATCH /api/admin/onboarding-templates/client/:id/stages/:stageId

Permission: templates:update

Body (all fields optional): name, description, stage_type, color, sort_order

Response: { stage }


DELETE /api/admin/onboarding-templates/client/:id/stages/:stageId

Permission: templates:manage

Response: { ok: true }


POST /api/admin/onboarding-templates/client/stages/:stageId/milestones

Permission: templates:update

Body:

FieldTypeRequiredDescription
titlestringYesMilestone title
descriptionstringNoMilestone description
is_requiredbooleanNoWhether milestone is required (default: true)
auto_sourcestring|nullNoAuto-completion trigger (e.g. deal_won, project_created, first_invoice)

Response: { milestone } (201)


PATCH /api/admin/onboarding-templates/client/milestones/:milestoneId

Permission: templates:update

Body (all fields optional): title, description, is_required, auto_source, sort_order

Response: { milestone }


DELETE /api/admin/onboarding-templates/client/milestones/:milestoneId

Permission: templates:manage

Response: { ok: true }