> ## 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.automation.create

> Creates an automation as a draft: an event that enrols a contact, an optional payload filter, and a tree of steps (wait, send, branch on a contact property, consent or event field, property.set). Returns readiness problems (unverified sender, unknown topic, unpublished template, missing legal address) so they can be fixed before email.automation.activate. Nothing runs until activated.



## OpenAPI

````yaml /api-reference/openapi.json post /email/automation/create
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/automation/create:
    post:
      tags:
        - email
      summary: email.automation.create
      description: >-
        Creates an automation as a draft: an event that enrols a contact, an
        optional payload filter, and a tree of steps (wait, send, branch on a
        contact property, consent or event field, property.set). Returns
        readiness problems (unverified sender, unknown topic, unpublished
        template, missing legal address) so they can be fixed before
        email.automation.activate. Nothing runs until activated.
      operationId: email.automation.create
      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:
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                trigger:
                  type: object
                  properties:
                    event:
                      type: string
                      maxLength: 100
                      pattern: ^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$
                      description: >-
                        The event type that enrols a contact. The event
                        payload's contactId names the contact.
                    filter:
                      description: >-
                        Only events whose payload contains these keys and values
                        enrol (jsonb containment).
                      type: object
                      propertyNames:
                        type: string
                      additionalProperties: {}
                  required:
                    - event
                  additionalProperties: false
                steps:
                  minItems: 1
                  maxItems: 50
                  type: array
                  items:
                    $ref: >-
                      #/components/schemas/email_automation_create_input___schema0
                  description: >-
                    A tree of steps: wait {seconds}, send {template, topic,
                    from}, branch {if, then, else}, property.set {key, value}.
                reenter:
                  description: >-
                    May a contact be enrolled again after an earlier run?
                    Default false.
                  type: boolean
              required:
                - name
                - trigger
                - steps
              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:
                      automation:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          name:
                            type: string
                          triggerEvent:
                            type: string
                          triggerFilter:
                            anyOf:
                              - {}
                              - type: 'null'
                          steps:
                            type: array
                            items: {}
                          reenter:
                            type: boolean
                          status:
                            type: string
                            enum:
                              - draft
                              - active
                              - paused
                              - archived
                          createdAt:
                            type: string
                            format: date-time
                            pattern: >-
                              ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
                          updatedAt:
                            type: string
                            format: date-time
                            pattern: >-
                              ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
                        required:
                          - id
                          - name
                          - triggerEvent
                          - triggerFilter
                          - steps
                          - reenter
                          - status
                          - createdAt
                          - updatedAt
                        additionalProperties: {}
                      readiness:
                        type: object
                        properties:
                          ok:
                            type: boolean
                          problems:
                            type: array
                            items:
                              type: object
                              properties:
                                code:
                                  type: string
                                message:
                                  type: string
                                fix:
                                  type: string
                              required:
                                - code
                                - message
                                - fix
                              additionalProperties: {}
                        required:
                          - ok
                          - problems
                        additionalProperties: {}
                    required:
                      - automation
                      - readiness
                    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:
  schemas:
    email_automation_create_input___schema0:
      anyOf:
        - type: object
          properties:
            type:
              type: string
              const: wait
            seconds:
              type: integer
              minimum: 1
              maximum: 7776000
              description: Up to 90 days
          required:
            - type
            - seconds
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: send
            channel:
              default: email
              type: string
              enum:
                - email
                - sms
            template:
              type: string
              minLength: 1
              maxLength: 100
            topic:
              type: string
              minLength: 1
              maxLength: 100
              description: >-
                The consent topic this message belongs to; the contact must have
                granted it on this channel
            from:
              description: >-
                Email only, and required there: an address on a verified sending
                domain. An SMS sends from the deployment's number.
              type: string
              format: email
              pattern: >-
                ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
            subject:
              description: 'Email only: overrides the template subject'
              type: string
              maxLength: 300
            variables:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                type:
                  - string
                  - number
                  - boolean
          required:
            - type
            - template
            - topic
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: property.set
            key:
              type: string
              minLength: 1
              maxLength: 100
            value:
              type:
                - string
                - number
                - boolean
                - 'null'
          required:
            - type
            - key
            - value
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: branch
            if:
              type: object
              properties:
                field:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: >-
                    properties.<key> on the contact, context.<key> from the
                    triggering event, or consent.<topic> (true when granted).
                    Consent is per channel: consent.<topic> and
                    consent.email.<topic> both mean email, and
                    consent.sms.<topic> means text.
                op:
                  type: string
                  enum:
                    - eq
                    - neq
                    - exists
                    - not_exists
                    - gt
                    - lt
                    - contains
                value:
                  description: Omitted for exists/not_exists
                  type:
                    - string
                    - number
                    - boolean
              required:
                - field
                - op
              additionalProperties: false
            then:
              maxItems: 50
              type: array
              items:
                $ref: '#/components/schemas/email_automation_create_input___schema0'
            else:
              maxItems: 50
              type: array
              items:
                $ref: '#/components/schemas/email_automation_create_input___schema0'
          required:
            - type
            - if
            - then
            - else
          additionalProperties: false
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: >-
        A Lath API key: lath_live_sk… or lath_test_sk… on a server,
        lath_live_pk… or lath_test_pk… in a browser.

````