---
id: workflow-create
title: Create a workflow
description: >-
  Creates a workflow. The request body is the definition document itself, not
  wrapped in any envelope.
sidebar_label: Create a workflow
hide_title: true
hide_table_of_contents: true
api: >-
  eJztWW1z27gR/is7mM4kmVKSk6a9Vp1+cBzn6raxPX6J78bnhhCxlHABAQYApeg8+u+dBUiJkijJSb+0M8mHRCHxsrt49sHuw0fm+dix4T27M/ZTrswMBOZSSy+NduwhYQJdZmVJ/2dDdmKRe3TAYVaP78PNBMHi5wqdh5ERc5AO/ARbC4EwWVWg9iC9Q5UnoI2HmeVliQKkBq7ngHqKypTY/0X/onth1WYPcJ5b74B7sDiVjpZ8mcBM+knYiVfe9AoutedSo4BUkZE+Ba4kd1Aaqb3UY5ovfZ9WPzd+Qk9spR3M0Q/BWzkeo3VgtJqDxbF0Hi3MJqhhbirgmZdT7hG4jsuGda4wR4s6o7UcZha9A2Nhyq3kI4UUCO5hwqcI2sCUqwppOwpRLjUOIaOAkj+uyjJE4YBrEZyy6EqjHYKSzoeIFlBpgRbSGbda6rFLwZlgXMY1OPRxEM892hm3wvVZwkyJNuxwJtiQNREdhn2RJaw+uTdGzNnwkWVGe9SefvKyVDILcwe/Ojr+R+ayCRacfnnpFbLhEjdvl6fNEubnJb0zo18x82wTRGtHu0LJMLjteIErvNCTqXQVV4BCemPB8Sm6Plx7LB1wi8Ch4CWYHJzHEqQAb8LPv66ONAxTMz53YHFUSeXBoZ2i7TkpEHJrijDF0TJkO6T13DShEHPIlETte66imBDCmrXT+lClAyFdxq1A0a/DKi0KSi3NC4p02IFSqrR0KF6io0CGtxTQGDPnrdTjrZj9vSq47lnkgnC1Ch/Npv3wCy/KcCDH789AWJl7cBnXGi1bJOwTzg/vcRKdzCbGoQanqjE8T/99z3u/HfX+8lD/23t4PEr+9Grxu/RFApWWnyuEEi0YO+Za/hbBTBiWRVF5MrYPpzomw4/SX5Su5/xcIVSlQ0rqqeSQXt7ewKBxyg1aHDR4/ITzRbruIy9kL/jYa/m45sy2r6vZ1xnXD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8Qr1YLHnH0//Zgjqy/wBkj7X7
sidebar_class_name: post api-method
info_path: docs/api/nullplatform-api
custom_edit_url: null
canonical: 'https://docs.nullplatform.com/docs/api/workflow-create'
---
<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Create a workflow"}
>
</Heading>

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

</MethodEndpoint>

Creates a workflow. The request body is the definition document itself, not wrapped in any envelope.

- The workflow starts at revision 1, with the auto-maintained `latest` alias pointing at it.
- Nothing runs yet: triggers only register when you activate an alias.
- Referencing secrets or variables that have no value yet is fine: creation succeeds and the response lists them under `warnings` so you can set them afterwards.

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

<ParamsDetails
  parameters={undefined}
>

</ParamsDetails>

<RequestSchema
  title={"Body"}
  body={{"content":{"application/json":{"schema":{"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}}}}}
>

</RequestSchema>

<StatusCodes
  id={undefined}
  label={undefined}
  responses={{"201":{"description":"The workflow was 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"]}}}}}}}}},"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>

