Managing workflows with the Novu API
Update workflow definitions in Development with the Novu API, then publish them to other environments through CI/CD.
Use the Novu API to keep workflow definitions aligned with your codebase and promote them across environments. The sections below explain the production flow first, then show how to implement each phase.
Workflows are scoped to the environment. The same workflowId in Development and Production refers to two separate workflow records. Update definitions in Development, then sync when you are ready to publish. For more on environments, refer to Publishable assets.
How workflow management works in production
Managing workflows in production is a two-phase process. You update workflow definitions in Development from your application code, then you publish those definitions to Staging and Production through CI/CD.
In a real application you usually manage many workflows (for example, payout-initiated, weekly-digest, and order-shipped). The flow is the same for each one: pick a stable workflowId per workflow, run the update-first helper for every ID in your list, then sync each ID in CI/CD.
Phase 1: Update workflow definitions in Development
Store workflow definitions in your repository (steps, payload schema, and channel content). For each workflowId, call update first, because that is the path you use on almost every run. Create only when update returns 404 (that workflow does not exist yet in Development).
Phase 2: Publish workflows to other environments in CI/CD
When definitions in Development are correct, publish them with Sync a workflow. Run sync from your CI/CD pipeline (for example, after a merge to main) once per workflowId so Staging and Production receive the same set of workflows. Use your Development secret key when calling sync. Pass the target environment identifier from the Novu Dashboard. Each sync copies one workflow from Development into the target environment under the same workflowId.
End-to-end sequence
- Update workflow definitions in Development for each
workflowIdyou manage as code. - Publish each workflow from Development to the target environment (Staging first, then Production, if you use both).
Prerequisites
Install the SDK for your stack and set your secret key from the Novu Dashboard:
Update workflow definitions in Development
This section implements phase 1: updating workflow definitions in Development.
For each workflowId, try update first and create on 404:
- Update the workflow with that
workflowIdand its full definition. - If update returns 404, create a new workflow with the same
workflowId.
Keep a list of every workflowId you manage as code (a constant array, a registry map, or exports from workflow modules) and loop over it in your deploy script or bootstrap job.
For create and update field definitions, refer to Create a workflow and Update a workflow.
Publish workflows with CI/CD
This section implements phase 2: publishing workflows from Development to other environments in CI/CD.
After phase 1 has run for every managed workflowId and Development matches your repository, call Sync a workflow from CI/CD once per ID. Use your Development secret key and the target environment identifier from the Novu Dashboard. Each workflow is copied under the same workflowId in the target environment.
Run sync after workflow definition changes land in your repository (for example, on merge to main). Production and other live environments are updated by syncing from Development, not by editing workflows directly in those environments.
Store these in your CI provider as secrets: NOVU_SECRET_KEY (Development) and NOVU_TARGET_ENVIRONMENT_ID (from the Novu Dashboard).
This job calls Sync a workflow (PUT /v2/workflows/{workflowId}/sync) once per workflowId after phase 1 has updated Development.
For sync request details, refer to Sync a workflow.
Next steps
For individual workflow operations, refer to these guides: