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

# automationDraftUpdate

> Replace an automation's draft with a whole typed definition. Publish it with `automationPublish`. AUTOMATION_REVISION_STALE when the draft changed since `expectedRevision`; AUTOMATION_DEFINITION_INVALID when the definition isn't an automation, or a Function step's code doesn't type-check. Null if the automation doesn't exist.

**Required scopes:** [`automations_write`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-automations_write)

## Arguments

**definition** `[AutomationDefinitionInput!](/docs/api-reference/v3/reference/automations/automation-definition-input)` *required*

The whole new definition; what it leaves out is removed.

**fields**

**edges** `[\[AutomationGraphEdgeInput!\]!](/docs/api-reference/v3/reference/automations/automation-graph-edge-input)` *required*

How runs move between the nodes, at most 1000.

**fields**

**from** `String!` *required*

`"trigger"` or the id of the step the run leaves.

**port** `String!` *required*

The port it leaves by, such as `next` or `true`.

**to** `String!` *required*

The id of the next step.

**entryCondition** `[JSON](/docs/api-reference/v3/reference/common/json)`

An expression a run must meet to start; omitted admits every run.

**name** `String!` *required*

The automation's name.

**rulesVersion** `String`

The checker rules to hold it to. Omitted: a saved automation keeps its own, and a new one gets the newest.

**steps** `[\[AutomationStepInput!\]!](/docs/api-reference/v3/reference/automations/automation-step-input)` *required*

The steps, at most 500.

**fields**

**code** `String`

A `core.function` step's TypeScript code; only that kind takes it.

**config** `[JSON!](/docs/api-reference/v3/reference/common/json)` *required*

The kind's settings, matching the `configJsonSchema` of this kind and version in `automationKinds`.

**description** `String`

A note on the step.

**disabled** `Boolean`

Skip the step when the automation runs.

**id** `String!` *required*

The step's id, unique in the automation.

**kind** `String!` *required*

The step kind, such as `core.wait`.

**kindVersion** `Int!` *required*

The version of the kind the config is written for.

**position** `[AutomationNodePositionInput](/docs/api-reference/v3/reference/automations/automation-node-position-input)`

Where it sits on the canvas.

**title** `String`

The step's name; omitted shows the kind's title.

**trigger** `[AutomationTriggerInput!](/docs/api-reference/v3/reference/automations/automation-trigger-input)` *required*

What starts a run.

**fields**

**config** `[JSON!](/docs/api-reference/v3/reference/common/json)` *required*

The kind's settings, matching the `configJsonSchema` of this kind and version in `automationKinds`.

**description** `String`

A note on the trigger.

**kind** `String!` *required*

The trigger kind, such as `core.schedule`.

**kindVersion** `Int!` *required*

The version of the kind the config is written for.

**position** `[AutomationNodePositionInput](/docs/api-reference/v3/reference/automations/automation-node-position-input)`

Where it sits on the canvas.

**expectedRevision** `String!` *required*

The `Automation.revision` the change was made against, so a concurrent edit isn't overwritten.

**id** `ID!` *required*

The automation's id.

## Returns

**automationDraftUpdate** `[Automation](/docs/api-reference/v3/reference/automations/automation)`

An automation built in Developer › Automations: a trigger and the steps it runs. For email and SMS flows, use MarketingAutomation. Agents create and edit one as script in a workspace (`workspaceCreate`; read `guide/` in `automationCatalog` first). Apps send typed definitions to `automationCreate` and `automationDraftUpdate`.

**fields**

**createdAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the automation was created.

**definition** `[AutomationDefinition!](/docs/api-reference/v3/reference/automations/automation-definition)` *required*

The draft as typed data, Function code inline. To change it, pass a changed copy to `automationDraftUpdate`.

**fields**

**edges** `[\[AutomationGraphEdge!\]!](/docs/api-reference/v3/pagination)` *required*

How runs move between the trigger and the steps.

**fields**

**from** `String!` *required*

`"trigger"` or the id of the step the run leaves.

**port** `String!` *required*

The port it leaves by, such as `next` or `true`.

**to** `String!` *required*

The id of the next step.

**entryCondition** `[JSON](/docs/api-reference/v3/reference/common/json)`

An expression a run must meet to start; null admits every run. Read `guide/expressions` in `automationCatalog`.

**name** `String!` *required*

The automation's name.

**rulesVersion** `String!` *required*

The checker rules the automation is held to. A rule added in a later version only warns until you raise it.

**steps** `[\[AutomationStep!\]!](/docs/api-reference/v3/reference/automations/automation-step)` *required*

The steps, in the order the editor lists them.

**fields**

**code** `String`

A `core.function` step's TypeScript code; null for other kinds.

**config** `[JSON!](/docs/api-reference/v3/reference/common/json)` *required*

The kind's settings. Their shape is the `configJsonSchema` of this kind and version in `automationKinds`.

**description** `String`

A note on the step.

**disabled** `Boolean!` *required*

Skipped when the automation runs: the run continues on the step's default port.

**id** `String!` *required*

The step's id, unique in the automation. Edges and diagnostics refer to it.

**kind** `String!` *required*

The step kind, such as `core.wait`.

**kindVersion** `Int!` *required*

The version of the kind the config is written for.

**position** `[AutomationNodePosition](/docs/api-reference/v3/reference/automations/automation-node-position)`

Where it sits on the canvas; null if never placed.

**title** `String`

The step's name; null shows the kind's title.

**trigger** `[AutomationTrigger!](/docs/api-reference/v3/reference/automations/automation-trigger)` *required*

What starts a run.

**fields**

**config** `[JSON!](/docs/api-reference/v3/reference/common/json)` *required*

The kind's settings. Their shape is the `configJsonSchema` of this kind and version in `automationKinds`.

**description** `String`

A note on the trigger.

**kind** `String!` *required*

The trigger kind, such as `core.schedule`.

**kindVersion** `Int!` *required*

The version of the kind the config is written for.

**position** `[AutomationNodePosition](/docs/api-reference/v3/reference/automations/automation-node-position)`

Where it sits on the canvas; null if never placed.

**enabled** `Boolean!` *required*

Whether the automation runs when its trigger fires. Change it with `automationUpdate`.

**id** `ID!` *required*

The id of this automation.

**name** `String!` *required*

The automation's name.

**publishedVersion** `Int`

The latest published version; null until first published.

**revision** `String!` *required*

The draft's revision. Opaque; pass it to `automationPublish` as `expectedRevision`.

**runs** `[AutomationRunConnection!](/docs/api-reference/v3/pagination)` *required*

Runs, newest first. Runs are deleted 30 days after they finish.

**Requires:** [`automations_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-automations_read)

**fields**

**Arguments**

**after** `String`

Returns runs after this cursor.

**first** `Int`

Returns the first N runs (max 100, default 25).

**status** `[\[AutomationRunStatus!\]](/docs/api-reference/v3/reference/automations/automation-run-status)`

Only runs with one of these statuses.

**Fields**

**edges** `[\[AutomationRunEdge!\]!](/docs/api-reference/v3/pagination)` *required*

The list of edges (each a node plus its pagination `cursor`).

**fields**

**cursor** `String!` *required*

Opaque cursor for this item; pass to `after`/`before` to page from here.

**node** `[AutomationRun!](/docs/api-reference/v3/reference/automations/automation-run)` *required*

The item at this edge.

**nodes** `[\[AutomationRun!\]!](/docs/api-reference/v3/reference/automations/automation-run)` *required*

The nodes in this page, without the edge/cursor wrapper — a convenience over `edges`.

**fields**

**automation** `[Automation!](/docs/api-reference/v3/reference/automations/automation)` *required*

The automation this run belongs to.

**Requires:** [`automations_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-automations_read)

**failure** `[AutomationRunFailure](/docs/api-reference/v3/reference/automations/automation-run-failure)`

Why the run failed; null unless `status` is FAILED.

**finishedAt** `[DateTime](/docs/api-reference/v3/reference/common/date-time)`

When the run finished; null while running or waiting.

**id** `ID!` *required*

The id of this run.

**startedAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the run started.

**status** `[AutomationRunStatus!](/docs/api-reference/v3/reference/automations/automation-run-status)` *required*

Where the run is in its lifecycle.

**steps** `[\[AutomationStepRecord!\]!](/docs/api-reference/v3/reference/automations/automation-step-record)` *required*

The steps the run executed, in order, with their inputs, outputs and effects.

**version** `Int!` *required*

The automation version the run is on. A waiting run that a publish moves to a newer version keeps reporting the old one until it resumes.

**waitingOn** `String`

The event type a WAITING run's await-event step is waiting for; null for a timed wait and for a run that isn't waiting.

**pageInfo** `[PageInfo!](/docs/api-reference/v3/pagination)` *required*

Pagination metadata for the current page.

**fields**

**endCursor** `String`

Cursor of the last edge in this page; pass to `after` to page forward.

**hasNextPage** `Boolean!` *required*

Whether more items exist after this page (drives forward pagination with `first`/`after`).

**hasPreviousPage** `Boolean!` *required*

Whether more items exist before this page (drives backward pagination with `last`/`before`).

**startCursor** `String`

Cursor of the first edge in this page; pass to `before` to page backward.

**script** `String!` *required*

The draft as AutomationScript, Function code inline. To change it, open a workspace with `workspaceCreate`.

**triggerKind** `String!` *required*

The draft's trigger kind.

**updatedAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the automation was last changed.

**versionStrategy** `[AutomationVersionStrategy!](/docs/api-reference/v3/reference/automations/automation-version-strategy)` *required*

Which version runs already in flight continue on.

**versions** `[AutomationVersionConnection!](/docs/api-reference/v3/pagination)` *required*

Published versions, newest first.

**Requires:** [`automations_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-automations_read)

**fields**

**Arguments**

**after** `String`

Returns versions after this cursor.

**first** `Int`

Returns the first N versions (max 100, default 25).

**Fields**

**edges** `[\[AutomationVersionEdge!\]!](/docs/api-reference/v3/pagination)` *required*

The list of edges (each a node plus its pagination `cursor`).

**fields**

**cursor** `String!` *required*

Opaque cursor for this item; pass to `after`/`before` to page from here.

**node** `[AutomationVersion!](/docs/api-reference/v3/reference/automations/automation-version)` *required*

The item at this edge.

**nodes** `[\[AutomationVersion!\]!](/docs/api-reference/v3/reference/automations/automation-version)` *required*

The nodes in this page, without the edge/cursor wrapper — a convenience over `edges`.

**fields**

**createdAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the version was published.

**definition** `[AutomationDefinition!](/docs/api-reference/v3/reference/automations/automation-definition)` *required*

This version as typed data, Function code inline.

**script** `String!` *required*

This version as AutomationScript, Function code inline. Read `guide/script` in `automationCatalog` for the syntax.

**triggerKind** `String!` *required*

The trigger this version runs on.

**version** `Int!` *required*

The version number, from 1.

**pageInfo** `[PageInfo!](/docs/api-reference/v3/pagination)` *required*

Pagination metadata for the current page.

**fields**

**endCursor** `String`

Cursor of the last edge in this page; pass to `after` to page forward.

**hasNextPage** `Boolean!` *required*

Whether more items exist after this page (drives forward pagination with `first`/`after`).

**hasPreviousPage** `Boolean!` *required*

Whether more items exist before this page (drives backward pagination with `last`/`before`).

**startCursor** `String`

Cursor of the first edge in this page; pass to `before` to page backward.

## Example

```graphql theme={null}
mutation {
  automationDraftUpdate(definition: { ... }, expectedRevision: "...", id: "...") {
    createdAt
    enabled
    id
    name
    publishedVersion
    revision
    runs {
      nodes {
        finishedAt
        id
        startedAt
        status
        version
        waitingOn
      }
      pageInfo { hasNextPage endCursor }
    }
    script
    # ...
  }
}
```


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