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

# Create Automation

> Create an automation draft.

## Create request

```json theme={null}
{
  "name": "Post Purchase Journey",
  "description": "Follow up after a completed order.",
  "definition": {
    "trigger": {
      "event_name": "order.completed"
    },
    "steps": [
      {
        "key": "send_receipt",
        "type": "send_email_template",
        "config": {
          "template_version_id": "tpl_ver_email_123",
          "domain_id": "dom_123"
        }
      }
    ],
    "connections": [
      {
        "from": "trigger",
        "to": "send_receipt",
        "branch": "next"
      }
    ]
  },
  "editor_layout": {
    "viewport": {
      "x": 0,
      "y": 0,
      "zoom": 1
    },
    "nodes": [
      {
        "id": "trigger",
        "position": {
          "x": 120,
          "y": 180
        }
      }
    ]
  }
}
```


## OpenAPI

````yaml api-reference/openapi.json POST /automations
openapi: 3.0.1
info:
  title: Sendrealm API
  description: >-
    API for email, push, audience resources, domains, campaign drafts,
    templates, events, topics, and automations
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.sendrealm.com
security:
  - bearerAuth: []
paths:
  /automations:
    post:
      summary: Create an automation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                description:
                  type: string
                  nullable: true
                definition:
                  type: object
                  additionalProperties:
                    $ref: '#/components/schemas/JsonValue'
                editor_layout:
                  type: object
                  additionalProperties:
                    $ref: '#/components/schemas/JsonValue'
      responses:
        '201':
          description: Automation created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AutomationSummaryResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  schemas:
    JsonValue:
      oneOf:
        - type: string
          nullable: true
        - type: number
        - type: boolean
        - type: object
          additionalProperties:
            $ref: '#/components/schemas/JsonValue'
        - type: array
          items:
            $ref: '#/components/schemas/JsonValue'
    AutomationSummaryResponse:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: integer
          description: HTTP response status code
        data:
          $ref: '#/components/schemas/AutomationSummary'
    AutomationSummary:
      allOf:
        - $ref: '#/components/schemas/Automation'
        - type: object
          required:
            - current_draft_version
            - current_published_version
          properties:
            current_draft_version:
              type: object
              nullable: true
              allOf:
                - $ref: '#/components/schemas/AutomationVersion'
            current_published_version:
              type: object
              nullable: true
              allOf:
                - $ref: '#/components/schemas/AutomationVersion'
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: integer
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details:
              $ref: '#/components/schemas/JsonValue'
            issues:
              type: array
              items:
                $ref: '#/components/schemas/ValidationIssue'
    Automation:
      type: object
      required:
        - id
        - name
        - description
        - status
        - current_draft_version_id
        - current_published_version_id
        - created_at
        - updated_at
        - deleted_at
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: string
          nullable: true
        status:
          type: string
        current_draft_version_id:
          type: string
          format: uuid
          nullable: true
        current_published_version_id:
          type: string
          format: uuid
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        deleted_at:
          type: string
          format: date-time
          nullable: true
    AutomationVersion:
      type: object
      required:
        - id
        - version_number
        - state
        - definition
        - editor_layout
        - published_at
        - restored_from_version_id
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        version_number:
          type: integer
        state:
          type: string
        definition:
          $ref: '#/components/schemas/JsonObject'
        editor_layout:
          $ref: '#/components/schemas/JsonObject'
        published_at:
          type: string
          format: date-time
          nullable: true
        restored_from_version_id:
          type: string
          format: uuid
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ValidationIssue:
      type: object
      required:
        - code
        - path
        - message
      properties:
        code:
          type: string
        path:
          type: string
          nullable: true
        message:
          type: string
    JsonObject:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/JsonValue'
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Resource conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````