---
title: "create nats trigger"
method: POST
path: "/w/{workspace}/nats_triggers/create"
tags: ["nats_trigger"]
---

# create nats trigger

`POST /w/{workspace}/nats_triggers/create`

## Path parameters

- `workspace` string, required

## Request body

- NewNatsTrigger
  - `path` string, required — The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path.
  - `script_path` string, required — Path to the script or flow to execute when a message is received
  - `is_flow` boolean, required — True if script_path points to a flow, false if it points to a script
  - `nats_resource_path` string, required — Path to the NATS resource containing connection configuration
  - `use_jetstream` boolean, required — If true, uses NATS JetStream for durable message delivery
  - `stream_name` string, nullable — JetStream stream name (required when use_jetstream is true)
  - `consumer_name` string, nullable — JetStream consumer name (required when use_jetstream is true)
  - `subjects` string[], required — Array of NATS subjects to subscribe to
  - `mode` 'enabled' | 'disabled' | 'suspended' — job trigger mode
  - `error_handler_path` string — Path to a script or flow to run when the triggered job fails
  - `error_handler_args` ScriptArgs — The arguments to pass to the script or flow
  - `retry` Retry — unresolved $ref
  - `permissioned_as` string — The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
  - `preserve_permissioned_as` boolean — When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
  - `labels` string[]

## Response `201`

nats trigger created

---

[API](https://skmtc.net/windmill/apis/windmill-api.md) · [All operations](https://skmtc.net/windmill/apis/windmill-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/windmill/windmill-api/revisions/096d6a8830b7/schema)
