> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trylath.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Every Lath operation is POST https://platform.trylath.com/<operation name with dots replaced by slashes>, with a JSON body and `Authorization: Bearer <key>`. `email.send` is POST /email/send.
> Branch on `error.code`, never on `error.message`. Every refusal also carries `error.fix`, which names the next step.
> Send an `Idempotency-Key` header on any operation that is not retry-safe, so a retry cannot run it twice.
> A `lath_test_` key emails only the account's own members and sends no SMS; a `lath_live_` key reaches real recipients and is billed.
> The OpenAPI document, generated from the same registry as the routes, is at https://platform.trylath.com/openapi.json.

# email.template.generate

> Drafts an email from a plain-language description and returns it as blocks (the dashboard editor's model) with a subject and the {{variables}} it uses. Pass `existing` to change a draft instead of starting over. Saves nothing: review the draft, then write it with email.template.set. Refuses with ai_not_configured when this deployment has no model key.



## OpenAPI

````yaml /api-reference/openapi.json post /email/template/generate
openapi: 3.1.0
info:
  title: Lath API
  version: 0.1.0
  description: >-
    Every operation is one POST. The same set is reachable over MCP, the SDK and
    the CLI; nothing is dashboard-only.
servers:
  - url: https://platform.trylath.com
    description: This deployment
security: []
paths:
  /email/template/generate:
    post:
      tags:
        - email
      summary: email.template.generate
      description: >-
        Drafts an email from a plain-language description and returns it as
        blocks (the dashboard editor's model) with a subject and the
        {{variables}} it uses. Pass `existing` to change a draft instead of
        starting over. Saves nothing: review the draft, then write it with
        email.template.set. Refuses with ai_not_configured when this deployment
        has no model key.
      operationId: email.template.generate
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            Replays the stored response for the same key and input; refuses
            different input.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $schema: https://json-schema.org/draft/2020-12/schema
              type: object
              properties:
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 2000
                  description: >-
                    What the email should say, in plain language. When
                    `existing` is given, what to change.
                kind:
                  description: What sort of email this is; shapes the draft's structure.
                  type: string
                  enum:
                    - welcome
                    - receipt
                    - announcement
                    - reset
                    - digest
                    - other
                tone:
                  description: How it should sound.
                  type: string
                  enum:
                    - friendly
                    - professional
                    - direct
                    - warm
                existing:
                  description: A draft to refine, as returned by a previous call.
                  type: object
                  properties:
                    subject:
                      type: string
                      maxLength: 998
                    blocks:
                      maxItems: 40
                      type: array
                      items:
                        oneOf:
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: heading
                              text:
                                type: string
                                maxLength: 300
                              level:
                                anyOf:
                                  - type: number
                                    const: 1
                                  - type: number
                                    const: 2
                              align:
                                type: string
                                enum:
                                  - left
                                  - center
                                  - right
                            required:
                              - id
                              - type
                              - text
                              - level
                              - align
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: text
                              text:
                                type: string
                                maxLength: 4000
                              align:
                                type: string
                                enum:
                                  - left
                                  - center
                                  - right
                              tone:
                                type: string
                                enum:
                                  - normal
                                  - muted
                            required:
                              - id
                              - type
                              - text
                              - align
                              - tone
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: button
                              label:
                                type: string
                                maxLength: 120
                              url:
                                type: string
                                maxLength: 2000
                              align:
                                type: string
                                enum:
                                  - left
                                  - center
                                  - right
                            required:
                              - id
                              - type
                              - label
                              - url
                              - align
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: image
                              src:
                                type: string
                                maxLength: 2000
                              alt:
                                type: string
                                maxLength: 300
                              width:
                                type: integer
                                minimum: 40
                                maximum: 600
                              align:
                                type: string
                                enum:
                                  - left
                                  - center
                                  - right
                              href:
                                type: string
                                maxLength: 2000
                            required:
                              - id
                              - type
                              - src
                              - alt
                              - width
                              - align
                              - href
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: code
                              text:
                                type: string
                                maxLength: 120
                              align:
                                type: string
                                enum:
                                  - left
                                  - center
                                  - right
                            required:
                              - id
                              - type
                              - text
                              - align
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: list
                              items:
                                maxItems: 20
                                type: array
                                items:
                                  type: string
                                  maxLength: 500
                              ordered:
                                type: boolean
                            required:
                              - id
                              - type
                              - items
                              - ordered
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: divider
                            required:
                              - id
                              - type
                            additionalProperties: false
                          - type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                const: spacer
                              size:
                                type: string
                                enum:
                                  - sm
                                  - md
                                  - lg
                            required:
                              - id
                              - type
                              - size
                            additionalProperties: false
                  required:
                    - subject
                    - blocks
                  additionalProperties: false
              required:
                - prompt
              additionalProperties: false
      responses:
        '200':
          description: '{ activityId, result }. activityId is empty for reads.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  activityId:
                    type: string
                    description: The activity this call created, or empty for a read.
                  result:
                    $schema: https://json-schema.org/draft/2020-12/schema
                    type: object
                    properties:
                      subject:
                        type: string
                      blocks:
                        type: array
                        items: {}
                        description: >-
                          Blocks: heading, text, button, code, list, divider,
                          spacer. Each has an id and a type.
                      variables:
                        type: array
                        items:
                          type: string
                        description: >-
                          Every {{variable}} the draft uses, which a send must
                          supply.
                    required:
                      - subject
                      - blocks
                      - variables
                    additionalProperties: {}
                required:
                  - activityId
                  - result
        '400':
          description: invalid_input or invalid_json
        '401':
          description: unauthenticated
        '403':
          description: forbidden
        '404':
          description: not_found
        '409':
          description: 'conflict: idempotency_mismatch, email_taken, last_key'
        '413':
          description: body_too_large
        '429':
          description: rate_limited
      security:
        - bearer: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: >-
        A Lath API key: lath_live_… or lath_test_… on a server, lath_live_pk… or
        lath_test_pk… in a browser.

````