# AI Templates

Reusable AI-driven message templates. Templates render personalized content for a given contact and sender profile, optionally calling an LLM to generate the body.


## List AI Templates

 - [GET /flows/api/ai-templates](https://api.grinfi.io/openapi/ai-templates/listaitemplates.md): List all AI templates (reusable AI-driven message snippets) for the team.

## Create an AI Template

 - [POST /flows/api/ai-templates](https://api.grinfi.io/openapi/ai-templates/createaitemplate.md): Create a reusable message template. Templates are referenced from flow nodes by their uuid (the template_uuid field on linkedin_send_message, email_send_message, etc.).

is_public is required — sending the request without it currently returns a 500 instead of a validation error, so always include it (1 = shared with the team, 0 = private). name and type are also required; everything else is optional and defaults to empty.

## Get an AI Template

 - [GET /flows/api/ai-templates/{uuid}](https://api.grinfi.io/openapi/ai-templates/getaitemplate.md): Retrieve a single AI template by UUID, including its prompt and LLM config.

## Update an AI Template

 - [PUT /flows/api/ai-templates/{uuid}](https://api.grinfi.io/openapi/ai-templates/updateaitemplate.md): Update fields on an existing AI template.

## Delete an AI Template

 - [DELETE /flows/api/ai-templates/{uuid}](https://api.grinfi.io/openapi/ai-templates/deleteaitemplate.md): Delete an AI template. Returns 204; the deletion takes effect (the template disappears from the web app).

Known issue: deletion appears to be a soft-delete that the API read path does not filter — after deleting, the template still resolves on GET /flows/api/ai-templates/{uuid} and still appears in List AI Templates, even though it is gone from the UI (verified 2026-07-05). Treat a template as deleted once you receive the 204; don't rely on List/GET to confirm removal. See KNOWN_ISSUES.md.

## Render an AI Template

 - [POST /flows/api/ai-templates/render](https://api.grinfi.io/openapi/ai-templates/renderaitemplate.md): Render a template for a specific contact and sender profile. The simplest usage is to pass an existing template uuid along with lead_uuid and sender_profile_uuid — the saved template configuration is used.

For ad-hoc rendering without a saved template, pass the full set of fields (subject, body, type, llm_uuid, llm_config, prompt, enable_validation, enable_fallback, settings).

