# Error on trying to publish a new workflow using Terraform and Dynatrace API

**URL:** <https://community.dynatrace.com/t/error-on-trying-to-publish-a-new-workflow-using-terraform-and-dynatrace-api/57015>\
**Category:** Automations\
**Tags:** terraform, workflows, dynatrace-api\
**Created:** [September 24, 2026, 2:42pm UTC](https://community.dynatrace.com/t/error-on-trying-to-publish-a-new-workflow-using-terraform-and-dynatrace-api/57015 "2026-09-24T14:42:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cometa](https://avatars.discourse-cdn.com/v4/letter/c/3be4f8/32.png) [@cometa](https://community.dynatrace.com/u/cometa)\
**Post date:** [September 24, 2026, 2:42pm UTC](https://community.dynatrace.com/t/error-on-trying-to-publish-a-new-workflow-using-terraform-and-dynatrace-api/57015/1 "2026-09-24T14:42:51Z")

</div>

I am trying to publish a manually exported working Dynatrace JSON workflow as a Terraform file in a Github pipeline and it fails to be published via Dynatrace POST https://{environmentid}.apps.dynatrace.com/platform/automation/v1/workflows?adminAccess=true

The Terraform config:

```markup
# dynatrace_automation_workflow.this["Custom workflow"] will be created
  resource "dynatrace_automation_workflow" "this" {
      description = "Custom workflow"
      id = (known after apply)
      owner = "GUID"
      private = false
      title = "Custom workflow"
      type = "STANDARD"
      tasks {
          task {
              action = "dynatrace.automations:execute-dql-query"
              active = true
              description = "Task 1"
              input = jsonencode(
                    {
                      query = <<-EOT
                            timeseries {...},
                            by: {...},
                            filter: {...},
                            from: "{{ event()['event.start'] }}",
                            to: now()
                        EOT
                    }
                )
              name = "task1"
                # (4 unchanged attributes hidden)
              conditions {
                  else = "STOP"
                    # (1 unchanged attribute hidden)
                }
              position {
                  x = -1
                  y = 1
                }
            }
          task {
              action = "dynatrace.automations:execute-dql-query"
              active = true
              description = "Task 2"
              input = jsonencode(
                    {
                      query = <<-EOT
                            timeseries sum(test.results, scalar: true),
                            by: {...},
                            filter: { run_id == "{{ result('task1').records[0].runId }}"
                            },
                            from: "{{ event()['event.start'] }}",
                            to: now()
                        EOT
                    }
                )
              name = "task2"
                # (4 unchanged attributes hidden)
              conditions {
                  custom = "{{ result('task1').records | length > 0 }}"
                  else = "STOP"
                  states = {
                      "task1" = "SUCCESS"
                    }
                }
              position {
                  x = 1
                  y = 2
                }
            }
          task {
              action = "dynatrace.msteams:send-message"
              active = true
              description = "Task 3"
              input = jsonencode(
                    {
                      connectionId = "ConnectionID"
                      message = jsonencode({...})
                    }
                )
              name = "task3"
                # (4 unchanged attributes hidden)
              conditions {
                  custom = "{{ result('task1').records | length > 0 }}"
                  else = "STOP"
                  states = {
                      "task1" = "SUCCESS"
                      "task2" = "SUCCESS"
                    }
                }
              position {
                  x = 0
                  y = 3
                }
            }
        }
      trigger {
          event {
              active = true
              config {
                  davis_problem {
                      custom_filter = "custom_filter"
                      entity_tags_match = "all"
                      on_problem_close = false
                      categories {
                          availability = false
                          custom = true
                          error = false
                          info = false
                          monitoring_unavailable = false
                          resource = false
                          slowdown = false
                        }
                    }
                }
            }
        }
    }

```

The&nbsp;request is:  
POST https://{environmentid}.apps.dynatrace.com/platform/automation/v1/workflows?adminAccess=true  
The response is HTTP 400:

```markup
{
  "error": {
    "message": "Invalid request.",
    "code": 400,
    "details": {
      "trigger": {
        "eventTrigger": "Error occurred when creating Event Trigger. Reason: custom_filter isn't allowed here."
      }
    }
  }
}

```

It seems that the issue has to do with the event filter defined here:&nbsp; **custom\_filter = “custom\_filter”** , but why can’t I create a workflow with a custom event that perfectly works in a similar workflow created manually?

Does anybody know what I can do to resolve the issue? Is there a way to export a custom alert and then create it in a JSON or Terraform via Dynatrace API?

---

<div class="post-metadata">

**Author:** ![dylan\_taelemans](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dylan_taelemans/32/21501_2.png) [@dylan\_taelemans](https://community.dynatrace.com/u/dylan_taelemans)\
**Post date:** [September 28, 2026, 7:23am UTC](https://community.dynatrace.com/t/error-on-trying-to-publish-a-new-workflow-using-terraform-and-dynatrace-api/57015/2 "2026-09-28T07:23:35Z")

</div>

Hey, **custom\_filter = “custom\_filter” fails because this isn’t valid DQL.**

The **custom filter needs to return a boolean value**.

For example:

matchesPhrase(event.name, “error”)

or in json:&nbsp; “customFilter”: “matchesPhrase(event.name,‘custom’)”,
