---
id: workflow-update
title: Update a workflow
description: >-
  Pushes a new version of the definition. The body can be the bare definition or
  `{ definition, mode }`, where `mode` controls versioning:
sidebar_label: Update a workflow
hide_title: true
hide_table_of_contents: true
api: >-
  eJztWm1z27gR/is7nM7YnlKyk157rTr94CTOnduL4/FLcjc5N4SIlYgzCPAAUApPo//eWYAUKYmykvRLPsgfEknE2y6effbBEovIsamNRh+i99o8TqSeA8eJUMIJrWz0EEccbWpEQd+jUXRd2gwtMFA4hxkaK7QCPQGXYafjEO4yhLHmFaRMwRj98zEz3UagDSSLzg8x5JojLJMY5hkahIS+J5Bq5YyWtplPqOnoV/WrGkDCSqcTOOY4YaV0JyPQMzRzIxxaP6VkDq0DgzNh/QylkmgtMAUsdWKGwKRgFgotlLPAHAgXg1Awz0SaQcos1rY2Q4CwkBpkDvkQbtkEYVxBPf8IKl2CwhkaMOiXAVbn6DKhpuAyGt6CFDMc+tUrnA+acZMRMDlnVTP6xrShw8q6tnUzT4+1Q3LSZdibZCH4MiHL6Nv9zU+0EgaPWIV1cY1WHTnAT8I6qNDFvuG8AUVrNQhlHTIOTHHfxqAttLJIbZ6fPRtBcn1/lwDX5VgSVLy3y8KicTFYDQymghZZaCucNhXBp4M5j5iitBkNnsNcuEyXDh6VnpMXw8ZoRSNLg4xXYc3DKI50gYbRIJc8GkXN2kdlwZnDKI4KZliODg0BfhEJAnTBXBbFkWI5RqNI8CiODP5eCoM8GjlTYhzZNMOcRaNF5KqCWllnhJpGy83gWIWQwQkaVCmOgIFFM0MzyIXy3uNwnMwnH4fDYXJCIdB185GFVApUbpBm2qLy+3Ms9RyNh6KV5ZQwLH4vEQo0oM2UKfGHN/qEXICfWF5IWuR88lFM3r8Yv58U5fRMRcuHYBla90LzisyhwELl6CMrCilSP87pb5asWWzbrce/YerIkYZc7QRaetpunm8rnJ+/ccar9mm8NdC6/+66iGtHHXkfWZYjcJ2WOSrnf5kJWzIJyAlGYNkM7RBuHRYWiGkY5KwgcFmHBfndaf/xn+CMmE7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wl1JKnaFSlaIYfeCyjDVub+l1rzxv6UQD17ovvdfGUQDRfX1PH8k9I2iuP7wujkk/Pv9ndfKFKY37Q24i8YNmzfY6ruA20WuuqDWUzXbRMdn3yRqvbij9lXXtdrda+7cbF5w+bAg33VvpayfRvsqEM3tjkbg1zcvKKgmmlwx67Q8G55FK2qIrrpXi86vL32FT1uXs64P74PsZ6uA3vRU5xLi4W7x4W7xt3u3uOYch5/caSGZ8LmiDMfyEMJt2c1G3WonfRsJTiW2TFtHDReLMbN4b+RyST//XqKh+02d+PV8yYWlzzwaTZi0m0XRbugc39T8fQLfwCXkXl812VRV/qgpS/q2olTBoyUdbjNkHI23Pjx4GWwc3FH3tuPW65xl3PQ4T1Ms3JNtHzq57Pr+jlJGfSW65kHDiKnoX7/GcFPPZyL/2yKSTE1Ln1+jMKQvxqznp418FKq4fV5YLEKLO/2IarlcOcXRd/LLcvk/fL9iVw==
sidebar_class_name: put api-method
info_path: docs/api/nullplatform-api
custom_edit_url: null
canonical: 'https://docs.nullplatform.com/docs/api/workflow-update'
---
<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Update a workflow"}
>
</Heading>

<MethodEndpoint
  method={"put"}
  path={"/workflows/definitions/{id}"}
  context={"endpoint"}
>

</MethodEndpoint>

Pushes a new version of the definition. The body can be the bare definition or `{ definition, mode }`, where `mode` controls versioning:

- `auto` (default): overwrites the latest revision, unless an active alias points at it, in which case a new revision is created. Safe by default: you never rewrite something that is live.
- `new-revision`: always create a new revision.
- `overwrite`: always rewrite the latest revision.

If the `{id}` in the URL is a key that doesn't exist yet, the workflow is created instead and the response is 201: `PUT` doubles as an upsert, so a git repository of definitions can push them without knowing which ones already exist.

<Heading
  id={"request"}
  as={"h2"}
  className={"openapi-tabs__heading"}
  children={"Request"}
>
</Heading>

<ParamsDetails
  parameters={[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"Workflow reference: a server-minted id (`wf_...`) or the workflow's client-chosen key (lowercase slug, unique per organization).","example":"wf_ifWBbWfpug0n"}]}
>

</ParamsDetails>

<RequestSchema
  title={"Body"}
  body={{"content":{"application/json":{"schema":{"type":"object","properties":{"definition":{"title":"WorkflowDefinition","type":"object","description":"The workflow definition: the same document the visual editor saves. Steps are a map of step id to step; triggers are always rebuilt server-side from steps of type `trigger`, so a client-supplied `triggers` value is discarded.","required":["name","steps"],"properties":{"name":{"type":"string","description":"Human-readable workflow name.","example":"AMI drift scanner"},"key":{"type":"string","description":"Client-chosen slug (`^[a-z0-9][a-z0-9-]{0,62}$`), unique per organization and immutable. Enables GitOps-style upserts via `PUT /workflows/definitions/{key}`.","example":"ami-drift-scanner"},"description":{"type":"string","example":"Scans deployed scopes for outdated AMIs."},"path":{"type":"string","description":"Folder in the workflows tree. Defaults to `/`.","example":"/action-items/ami-drift"},"nrn":{"type":"string","description":"The nullplatform resource name the workflow is scoped to. Defaults to the caller's organization."},"steps":{"type":"object","description":"Map of step id to step definition. Step ids are alphanumeric (no hyphens).","additionalProperties":{"type":"object"}},"connections":{"type":"array","description":"Edges between steps.","items":{"type":"object"}},"variables":{"type":"object","description":"Per-run variables with optional `initialValue`."},"metadata":{"type":"object"},"semanticVersion":{"type":"string","description":"Optional version label stored on the revision.","example":"1.2.0"}},"additionalProperties":true},"mode":{"type":"string","enum":["auto","overwrite","new-revision"],"default":"auto"}}}}}}}
>

</RequestSchema>

<StatusCodes
  id={undefined}
  label={undefined}
  responses={{"200":{"description":"The definition was updated. `mode` says whether the latest revision was overwritten or a new one created.","content":{"application/json":{"schema":{"title":"PublishResult","type":"object","properties":{"workflow":{"title":"Workflow","type":"object","required":["id","name","createdAt","updatedAt"],"properties":{"id":{"type":"string","example":"wf_ifWBbWfpug0n"},"key":{"type":"string","example":"ami-drift-scanner"},"name":{"type":"string","example":"AMI drift scanner"},"description":{"type":"string"},"path":{"type":"string","example":"/action-items/ami-drift"},"organizationId":{"type":"string"},"nrn":{"type":"string"},"metadata":{"type":"object"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"revision":{"title":"Revision","type":"object","required":["workflowId","revision","createdAt"],"properties":{"workflowId":{"type":"string","example":"wf_ifWBbWfpug0n"},"revision":{"type":"integer","description":"Revision number, starting at 1.","example":3},"definition":{"type":"object","nullable":true,"description":"The full definition. `null` in list responses unless `includeDefinition=true`."},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string"},"releaseNotes":{"type":"string"},"semanticVersion":{"type":"string"}}},"latestAlias":{"allOf":[{"title":"Alias","type":"object","required":["workflowId","name","revision","active","updatedAt"],"properties":{"workflowId":{"type":"string","example":"wf_ifWBbWfpug0n"},"name":{"type":"string","example":"live"},"revision":{"type":"integer","example":3},"active":{"type":"boolean","description":"Whether the alias's triggers are activated."},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string"},"metadata":{"type":"object"},"triggerStates":{"type":"object","description":"Map of trigger id to its activation state.","additionalProperties":{"title":"TriggerState","type":"object","properties":{"status":{"type":"string","enum":["pending","live","failed","inactive"]},"activatedAt":{"type":"string","format":"date-time"},"deactivatedAt":{"type":"string","format":"date-time"},"lastError":{"type":"object","properties":{"message":{"type":"string"},"code":{"type":"string"}}},"runtimeMetadata":{"type":"object","description":"Runtime data such as the trigger's `webhookUrl`.","properties":{"webhookUrl":{"type":"string"}},"additionalProperties":true}}}}}}],"description":"The auto-maintained `latest` alias. Can be `null`."},"mode":{"type":"string","description":"How the write was applied (update responses only).","enum":["created","overwritten","new-revision"]},"warnings":{"type":"array","items":{"title":"ConfigWarning","type":"object","description":"Emitted when the definition references a config entry with no value at any visible place.","properties":{"code":{"type":"string","enum":["CONFIG_ENTRY_UNRESOLVED"]},"name":{"type":"string","example":"NP_API_KEY"},"kind":{"type":"string","enum":["secret","var"]}}}}}}}}},"201":{"description":"No workflow matched the key, so one was created (upsert).","content":{"application/json":{"schema":{"title":"PublishResult","type":"object","properties":{"workflow":{"title":"Workflow","type":"object","required":["id","name","createdAt","updatedAt"],"properties":{"id":{"type":"string","example":"wf_ifWBbWfpug0n"},"key":{"type":"string","example":"ami-drift-scanner"},"name":{"type":"string","example":"AMI drift scanner"},"description":{"type":"string"},"path":{"type":"string","example":"/action-items/ami-drift"},"organizationId":{"type":"string"},"nrn":{"type":"string"},"metadata":{"type":"object"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"revision":{"title":"Revision","type":"object","required":["workflowId","revision","createdAt"],"properties":{"workflowId":{"type":"string","example":"wf_ifWBbWfpug0n"},"revision":{"type":"integer","description":"Revision number, starting at 1.","example":3},"definition":{"type":"object","nullable":true,"description":"The full definition. `null` in list responses unless `includeDefinition=true`."},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string"},"releaseNotes":{"type":"string"},"semanticVersion":{"type":"string"}}},"latestAlias":{"allOf":[{"title":"Alias","type":"object","required":["workflowId","name","revision","active","updatedAt"],"properties":{"workflowId":{"type":"string","example":"wf_ifWBbWfpug0n"},"name":{"type":"string","example":"live"},"revision":{"type":"integer","example":3},"active":{"type":"boolean","description":"Whether the alias's triggers are activated."},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string"},"metadata":{"type":"object"},"triggerStates":{"type":"object","description":"Map of trigger id to its activation state.","additionalProperties":{"title":"TriggerState","type":"object","properties":{"status":{"type":"string","enum":["pending","live","failed","inactive"]},"activatedAt":{"type":"string","format":"date-time"},"deactivatedAt":{"type":"string","format":"date-time"},"lastError":{"type":"object","properties":{"message":{"type":"string"},"code":{"type":"string"}}},"runtimeMetadata":{"type":"object","description":"Runtime data such as the trigger's `webhookUrl`.","properties":{"webhookUrl":{"type":"string"}},"additionalProperties":true}}}}}}],"description":"The auto-maintained `latest` alias. Can be `null`."},"mode":{"type":"string","description":"How the write was applied (update responses only).","enum":["created","overwritten","new-revision"]},"warnings":{"type":"array","items":{"title":"ConfigWarning","type":"object","description":"Emitted when the definition references a config entry with no value at any visible place.","properties":{"code":{"type":"string","enum":["CONFIG_ENTRY_UNRESOLVED"]},"name":{"type":"string","example":"NP_API_KEY"},"kind":{"type":"string","enum":["secret","var"]}}}}}}}}},"4XX":{"description":"Client error. The body says what went wrong: an error `type`, a human-readable `detail`, and, on validation failures, one entry per offending field.","content":{"application/problem+json":{"schema":{"title":"Problem","type":"object","description":"The standard error body (RFC 7807 problem details, served as `application/problem+json`).","properties":{"type":{"type":"string","description":"Error type URI, e.g. `https://workflow-system.dev/errors/workflow-not-found`.","example":"https://workflow-system.dev/errors/workflow-not-found"},"title":{"type":"string","example":"Not found"},"status":{"type":"integer","example":404},"detail":{"type":"string","example":"No workflow with id wf_ifWBbWfpug0n exists"},"instance":{"type":"string","example":"/workflows/definitions/wf_ifWBbWfpug0n"},"errors":{"type":"array","description":"Present on validation failures: one entry per offending field.","items":{"type":"object","properties":{"path":{"type":"string","example":"/steps/scan/config"},"message":{"type":"string","example":"must have required property 'code'"}}}}}}}}},"5XX":{"description":"Unexpected server error.","content":{"application/problem+json":{"schema":{"title":"Problem","type":"object","description":"The standard error body (RFC 7807 problem details, served as `application/problem+json`).","properties":{"type":{"type":"string","description":"Error type URI, e.g. `https://workflow-system.dev/errors/workflow-not-found`.","example":"https://workflow-system.dev/errors/workflow-not-found"},"title":{"type":"string","example":"Not found"},"status":{"type":"integer","example":404},"detail":{"type":"string","example":"No workflow with id wf_ifWBbWfpug0n exists"},"instance":{"type":"string","example":"/workflows/definitions/wf_ifWBbWfpug0n"},"errors":{"type":"array","description":"Present on validation failures: one entry per offending field.","items":{"type":"object","properties":{"path":{"type":"string","example":"/steps/scan/config"},"message":{"type":"string","example":"must have required property 'code'"}}}}}}}}}}}
>

</StatusCodes>

