Templates
Breyta templates reference for reusable prompts, HTTP payloads, SQL, and notification channel definitions.
Quick Answer
Define reusable content in top-level :templates, then reference by :template and supply runtime :data.
Supported Template Types
| Type | Primary use | Typical consumers |
|---|---|---|
:http-request | Reusable HTTP request maps | flow/step :http |
:llm-prompt | Reusable system/user prompt content | flow/step :llm |
:db-query | Reusable SQL text and query shape | flow/step :db |
:notification | Reusable notification channel payloads/config | flow/step :wait (:notify), flow/step :notify |
Definition Shape
{:templates [{:id :welcome
:type :llm-prompt
:system "You are concise."
:prompt "Welcome {{user.name}}"}
{:id :approval-email
:type :notification
:channels {:http {:connection :sendgrid
:path "/v3/mail/send"
:method :post
:json {:subject "{{title}}"
:content [{:type "text/plain"
:value "Approve: {{approval-url}}\nReject: {{rejection-url}}"}]}}}}]}
Usage Patterns
LLM prompt template:
(flow/step :llm :welcome-user
{:connection :ai
:template :welcome
:data {:user {:name "Ada"}}})
HTTP request template:
(flow/step :http :create-order
{:connection :orders-api
:template :create-order
:data {:customer-id "cus_123" :amount 4200}})
DB query template:
{:templates [{:id :recent-orders
:type :db-query
:sql "select * from orders where created_at >= {{from}}"}]}
Wait notification template:
(flow/step :wait :approval
{:key "approval:123"
:timeout "2h"
:notify {:template :approval-email
:data {:title "Order Approval"}}})
Size And Reliability Notes
| Topic | Guidance |
|---|---|
| Payload limits | Core flow payload cap is 150 KB; template/function content is budgeted separately (up to ~2.1 MB total package). |
| When to template | Prefer templates over inline params for repeated payloads, large static bodies, and reviewable content. |
| Notification reuse | Notification templates are primarily for wait/checkpoint :notify, and can be reused by flow/step :notify (:http channels). |
| Large outputs | If step output may exceed inline thresholds, combine templates with :persist. |
| Data contract | Keep variable names stable across template fields and step :data maps. |