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

# updateMarketingAutomation

> Update automation metadata and/or apply step operations. Returns null if no owned automation matches the id. Pass `input`, `operations`, or both.

**Required scopes:** [`marketing_automations_write`](/docs/api-reference/v3/reference/scopes#scope-marketing_automations_write)

## Arguments

<ResponseField name="id" type="ID!" required>
  The automation's `id`, or its `legacyId` from an earlier version of the Redo API.
</ResponseField>

<ResponseField name="input" type={<a href="/docs/api-reference/v3/reference/marketing/update-marketing-automation-input">UpdateMarketingAutomationInput</a>}>
  Metadata fields to change.

  <Expandable title="fields" lazyRender>
    <ResponseField name="description" type="String">
      The merchant's description. Pass null to clear it.
    </ResponseField>

    <ResponseField name="enabled" type="Boolean">
      Whether the automation is running.
    </ResponseField>

    <ResponseField name="name" type="String">
      The merchant-facing name of the automation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="operations" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-step-operation">[MarketingAutomationStepOperation!]</a>}>
  Surgical step edits, applied in order.

  <Expandable title="fields" lazyRender>
    <ResponseField name="insert" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-step-insert-input">MarketingAutomationStepInsertInput</a>}>
      Insert a new step.

      <Expandable title="fields" lazyRender>
        <ResponseField name="abTest" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-ab-test-step-input">MarketingAutomationAbTestStepInput</a>} />

        <ResponseField name="after" type="ID">
          Insert on the outgoing edge of this parent step.
        </ResponseField>

        <ResponseField name="before" type="ID">
          Insert immediately before this child. The child must have exactly one incoming edge.
        </ResponseField>

        <ResponseField name="branch" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-condition-branch">MarketingAutomationConditionBranch</a>}>
          Which condition arm to attach to.
        </ResponseField>

        <ResponseField name="condition" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-condition-step-input">MarketingAutomationConditionStepInput</a>} />

        <ResponseField name="end" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-end-step-input">MarketingAutomationEndStepInput</a>} />

        <ResponseField name="manageCustomerTags" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-manage-customer-tags-step-input">MarketingAutomationManageCustomerTagsStepInput</a>} />

        <ResponseField name="manageStaticSegment" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-manage-static-segment-step-input">MarketingAutomationManageStaticSegmentStepInput</a>} />

        <ResponseField name="sendEmail" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-send-email-step-input">MarketingAutomationSendEmailStepInput</a>}>
          Insertable only when the trigger schema has an Email field (not SMS signup).
        </ResponseField>

        <ResponseField name="sendSms" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-send-sms-step-input">MarketingAutomationSendSmsStepInput</a>}>
          Insertable only when the trigger schema has a Phone field (not email signup, HSA, or extended warranty).
        </ResponseField>

        <ResponseField name="sendWebhook" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-send-webhook-step-input">MarketingAutomationSendWebhookStepInput</a>}>
          Insert requires an http or https destinationUrl and a payload.
        </ResponseField>

        <ResponseField name="startAgentConversation" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-start-agent-conversation-step-input">MarketingAutomationStartAgentConversationStepInput</a>}>
          Start a Commerce Agent conversation. Insertable when Commerce Agent is enabled, the trigger supports it, and the trigger schema has an Email or Phone field. Requires strategyId.
        </ResponseField>

        <ResponseField name="variantId" type="ID">
          Which A/B variant arm to attach to.
        </ResponseField>

        <ResponseField name="wait" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-wait-step-input">MarketingAutomationWaitStepInput</a>} />

        <ResponseField name="waitForEvent" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-wait-for-event-step-input">MarketingAutomationWaitForEventStepInput</a>} />
      </Expandable>
    </ResponseField>

    <ResponseField name="move" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-step-move-input">MarketingAutomationStepMoveInput</a>}>
      Move a step.

      <Expandable title="fields" lazyRender>
        <ResponseField name="after" type="ID">
          Place on the outgoing edge of this parent step.
        </ResponseField>

        <ResponseField name="before" type="ID">
          Place immediately before this child.
        </ResponseField>

        <ResponseField name="branch" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-condition-branch">MarketingAutomationConditionBranch</a>}>
          Which condition arm to attach to.
        </ResponseField>

        <ResponseField name="id" type="ID!" required>
          The step to move.
        </ResponseField>

        <ResponseField name="variantId" type="ID" />
      </Expandable>
    </ResponseField>

    <ResponseField name="remove" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-step-remove-input">MarketingAutomationStepRemoveInput</a>}>
      Remove a step.

      <Expandable title="fields" lazyRender>
        <ResponseField name="id" type="ID!" required>
          The step's id.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="update" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-step-update-input">MarketingAutomationStepUpdateInput</a>}>
      Patch an existing step.

      <Expandable title="fields" lazyRender>
        <ResponseField name="abTest" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-ab-test-step-input">MarketingAutomationAbTestStepInput</a>} />

        <ResponseField name="condition" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-condition-step-input">MarketingAutomationConditionStepInput</a>} />

        <ResponseField name="end" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-end-step-input">MarketingAutomationEndStepInput</a>} />

        <ResponseField name="id" type="ID!" required>
          The step's id.
        </ResponseField>

        <ResponseField name="manageCustomerTags" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-manage-customer-tags-step-input">MarketingAutomationManageCustomerTagsStepInput</a>} />

        <ResponseField name="manageStaticSegment" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-manage-static-segment-step-input">MarketingAutomationManageStaticSegmentStepInput</a>} />

        <ResponseField name="sendEmail" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-send-email-step-input">MarketingAutomationSendEmailStepInput</a>} />

        <ResponseField name="sendSms" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-send-sms-step-input">MarketingAutomationSendSmsStepInput</a>} />

        <ResponseField name="sendWebhook" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-send-webhook-step-input">MarketingAutomationSendWebhookStepInput</a>} />

        <ResponseField name="startAgentConversation" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-start-agent-conversation-step-input">MarketingAutomationStartAgentConversationStepInput</a>} />

        <ResponseField name="trigger" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-trigger-step-input">MarketingAutomationTriggerStepInput</a>}>
          Patch the trigger. Cannot change key or schemaType.
        </ResponseField>

        <ResponseField name="wait" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-wait-step-input">MarketingAutomationWaitStepInput</a>} />

        <ResponseField name="waitForEvent" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-wait-for-event-step-input">MarketingAutomationWaitForEventStepInput</a>} />
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns

<ResponseField name="updateMarketingAutomation" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation">MarketingAutomation</a>}>
  A marketing automation: a flow that sends email or SMS to customers when a trigger fires.

  <Expandable title="fields" lazyRender>
    <ResponseField name="analytics" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-analytics">MarketingAutomationAnalytics!</a>} required>
      Analytics for this marketing automation, grouped by what is being measured.

      <Expandable title="fields" lazyRender>
        <ResponseField name="messaging" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-messaging-analytics">MarketingAutomationMessagingAnalytics!</a>} required>
          Email and SMS performance, read from the analytics warehouse: what was sent, how it was engaged with, and the orders and revenue attributed to it. Covers messages sent by the automation's own send steps; Recover conversations are measured separately and are not included here.

          **Requires:** [`marketing_automations_analytics_read`](/docs/api-reference/v3/reference/scopes#scope-marketing_automations_analytics_read)

          <Expandable title="fields" lazyRender>
            **Arguments**

            <ResponseField name="attributionWindowDays" type="Int">
              How many days after a message an order still counts toward it, 1-30.
            </ResponseField>

            <ResponseField name="endDate" type={<a href="/docs/api-reference/v3/reference/common/date">Date!</a>} required>
              Last day to report on, inclusive, in the store's timezone. The range may span at most 400 days.
            </ResponseField>

            <ResponseField name="startDate" type={<a href="/docs/api-reference/v3/reference/common/date">Date!</a>} required>
              First day to report on, inclusive, in the store's timezone. Must be on or before `endDate`, and the range may span at most 400 days.
            </ResponseField>

            **Fields**

            <ResponseField name="series" type={<a href="/docs/api-reference/v3/reference/marketing/message-analytics-point">[MessageAnalyticsPoint!]!</a>} required>
              One entry per day with activity, oldest first. Quiet days are omitted rather than reported as zero.
            </ResponseField>

            <ResponseField name="totals" type={<a href="/docs/api-reference/v3/reference/marketing/message-analytics-totals">MessageAnalyticsTotals!</a>} required>
              Totals across the whole range. A marketing automation with no activity reports zero counts and null rates.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="category" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-category">MarketingAutomationCategory!</a>} required>
      Which trigger family this marketing automation belongs to.
    </ResponseField>

    <ResponseField name="createdAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime!</a>} required>
      When the automation was created.
    </ResponseField>

    <ResponseField name="description" type="String">
      The merchant's description of what this automation does.
    </ResponseField>

    <ResponseField name="enabled" type="Boolean!" required>
      Whether the automation is currently running.
    </ResponseField>

    <ResponseField name="id" type="ID!" required>
      The id of this automation.
    </ResponseField>

    <ResponseField name="legacyId" type="String!" required>
      The automation's legacy Mongo ObjectId (24-char hex) from before the CockroachDB migration.
    </ResponseField>

    <ResponseField name="name" type="String!" required>
      The merchant-facing name of the automation.
    </ResponseField>

    <ResponseField name="publishedAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime</a>}>
      When the current version was published. Null while it has only ever been a draft.
    </ResponseField>

    <ResponseField name="steps" type={<a href="/docs/api-reference/v3/reference/marketing/marketing-automation-step">[MarketingAutomationStep!]!</a>} required>
      The nodes that make up this automation, including graph edges as step ids. A type this API version does not model field-by-field is returned as MarketingAutomationUnknownStep.
    </ResponseField>

    <ResponseField name="stepsJson" type={<a href="/docs/api-reference/v3/reference/common/json">[JSON!]!</a>} required>
      `steps` with every field selected, as JSON: one element per step, with `__typename`. Null and invalid stored steps are \[]. Webhook header values and OAuth client secrets are omitted. Edits go through operations.
    </ResponseField>

    <ResponseField name="updatedAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime!</a>} required>
      When the automation was last updated.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

```graphql theme={null}
mutation {
  updateMarketingAutomation(id: "...", input: { ... }, operations: { ... }) {
    category
    createdAt
    description
    enabled
    id
    legacyId
    name
    publishedAt
    # ...
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.