---
title: Create an automation rule
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Case Management
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Create an automation rule{% #create-an-automation-rule %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                                |
| ----------------- | --------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/cases/projects/{project_id}/rules |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/cases/projects/{project_id}/rules |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/cases/projects/{project_id}/rules      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/cases/projects/{project_id}/rules      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/cases/projects/{project_id}/rules  |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/cases/projects/{project_id}/rules |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/cases/projects/{project_id}/rules     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/cases/projects/{project_id}/rules |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/cases/projects/{project_id}/rules |

### Overview

Creates an automation rule for a project. The rule defines a trigger event (for example, case created, status transitioned) and an action to execute.

OAuth apps require the `cases_write` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#case-management) to access this endpoint.



### Arguments

#### Path Parameters

| Name                         | Type   | Description                                             |
| ---------------------------- | ------ | ------------------------------------------------------- |
| project_id [*required*] | string | The UUID of the project that owns the automation rules. |

### Request

#### Body Data (required)

Automation rule payload.

{% tab title="Model" %}

| Parent field | Field                        | Type   | Description                                                                                                                                                                                                                              |
| ------------ | ---------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object | Data object for creating an automation rule.                                                                                                                                                                                             |
| data         | attributes [*required*] | object | Attributes required to create an automation rule.                                                                                                                                                                                        |
| attributes   | action [*required*]     | object | Defines what happens when the rule triggers. Combines an action type with action-specific configuration data.                                                                                                                            |
| action       | data [*required*]       | object | Configuration for the action to execute, dependent on the action type.                                                                                                                                                                   |
| data         | agent_type                   | string | The type of AI agent to assign. Required when the action type is `assign_agent`.                                                                                                                                                         |
| data         | assigned_agent_id            | string | The identifier of the AI agent to assign to the case. Required when the action type is `assign_agent`.                                                                                                                                   |
| data         | handle                       | string | The handle of the Datadog workflow to execute. Required when the action type is `execute_workflow`.                                                                                                                                      |
| action       | type [*required*]       | enum   | The type of automated action to perform when the rule triggers. `execute_workflow` runs a Datadog workflow; `assign_agent` assigns an AI agent to the case. Allowed enum values: `execute_workflow,assign_agent`                         |
| attributes   | name [*required*]       | string | Name of the automation rule.                                                                                                                                                                                                             |
| attributes   | state                        | enum   | Whether the automation rule is active. Enabled rules trigger on matching case events; disabled rules are inactive but preserve their configuration. Allowed enum values: `ENABLED,DISABLED`                                              |
| attributes   | trigger [*required*]    | object | Defines when the rule activates. Combines a trigger type (the case event to listen for) with optional trigger data (conditions that narrow when the trigger fires).                                                                      |
| trigger      | data                         | object | Additional configuration for the trigger, dependent on the trigger type. For `status_transitioned` triggers, specify `from_status_name` and `to_status_name`. For `attribute_value_changed` triggers, specify `field` and `change_type`. |
| data         | approval_type                | string | The approval outcome to match. Used with `case_review_approved` triggers.                                                                                                                                                                |
| data         | change_type                  | string | The kind of attribute change to match. Allowed values: `VALUE_ADDED`, `VALUE_DELETED`, `ANY_CHANGES`. Used with `attribute_value_changed` triggers.                                                                                      |
| data         | field                        | string | The case attribute field name to monitor for changes. Used with `attribute_value_changed` triggers.                                                                                                                                      |
| data         | from_status_name             | string | The originating status name. Used with `status_transitioned` triggers to match transitions from this status.                                                                                                                             |
| data         | to_status_name               | string | The destination status name. Used with `status_transitioned` triggers to match transitions to this status.                                                                                                                               |
| trigger      | type [*required*]       | enum   | The case event that activates the automation rule. Allowed enum values: `case_created,status_transitioned,attribute_value_changed,event_correlation_signal_correlated,case_review_approved,comment_added`                                |
| data         | type [*required*]       | enum   | JSON:API resource type for case automation rules. Allowed enum values: `rule`                                                                                                                                                            |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "action": {
        "data": {
          "agent_type": "string",
          "assigned_agent_id": "string",
          "handle": "workflow-handle-123"
        },
        "type": "execute_workflow"
      },
      "name": "Auto-assign workflow",
      "state": "ENABLED",
      "trigger": {
        "data": {
          "approval_type": "string",
          "change_type": "string",
          "field": "string",
          "from_status_name": "string",
          "to_status_name": "string"
        },
        "type": "case_created"
      }
    },
    "type": "rule"
  }
}
```

{% /tab %}

### Response

{% tab title="201" %}
Created
{% tab title="Model" %}
Response containing a single automation rule.

| Parent field  | Field                        | Type      | Description                                                                                                                                                                                                                              |
| ------------- | ---------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|               | data [*required*]       | object    | An automation rule that executes an action (such as running a Datadog workflow or assigning an AI agent) when a specified case event occurs within a project.                                                                            |
| data          | attributes [*required*] | object    | Core attributes of an automation rule, including its name, trigger condition, action to execute, and current state.                                                                                                                      |
| attributes    | action [*required*]     | object    | Defines what happens when the rule triggers. Combines an action type with action-specific configuration data.                                                                                                                            |
| action        | data [*required*]       | object    | Configuration for the action to execute, dependent on the action type.                                                                                                                                                                   |
| data          | agent_type                   | string    | The type of AI agent to assign. Required when the action type is `assign_agent`.                                                                                                                                                         |
| data          | assigned_agent_id            | string    | The identifier of the AI agent to assign to the case. Required when the action type is `assign_agent`.                                                                                                                                   |
| data          | handle                       | string    | The handle of the Datadog workflow to execute. Required when the action type is `execute_workflow`.                                                                                                                                      |
| action        | type [*required*]       | enum      | The type of automated action to perform when the rule triggers. `execute_workflow` runs a Datadog workflow; `assign_agent` assigns an AI agent to the case. Allowed enum values: `execute_workflow,assign_agent`                         |
| attributes    | created_at [*required*] | date-time | Timestamp when the automation rule was created.                                                                                                                                                                                          |
| attributes    | modified_at                  | date-time | Timestamp when the automation rule was last modified.                                                                                                                                                                                    |
| attributes    | name [*required*]       | string    | A human-readable name for the automation rule, used to identify the rule in the UI and API responses.                                                                                                                                    |
| attributes    | state [*required*]      | enum      | Whether the automation rule is active. Enabled rules trigger on matching case events; disabled rules are inactive but preserve their configuration. Allowed enum values: `ENABLED,DISABLED`                                              |
| attributes    | trigger [*required*]    | object    | Defines when the rule activates. Combines a trigger type (the case event to listen for) with optional trigger data (conditions that narrow when the trigger fires).                                                                      |
| trigger       | data                         | object    | Additional configuration for the trigger, dependent on the trigger type. For `status_transitioned` triggers, specify `from_status_name` and `to_status_name`. For `attribute_value_changed` triggers, specify `field` and `change_type`. |
| data          | approval_type                | string    | The approval outcome to match. Used with `case_review_approved` triggers.                                                                                                                                                                |
| data          | change_type                  | string    | The kind of attribute change to match. Allowed values: `VALUE_ADDED`, `VALUE_DELETED`, `ANY_CHANGES`. Used with `attribute_value_changed` triggers.                                                                                      |
| data          | field                        | string    | The case attribute field name to monitor for changes. Used with `attribute_value_changed` triggers.                                                                                                                                      |
| data          | from_status_name             | string    | The originating status name. Used with `status_transitioned` triggers to match transitions from this status.                                                                                                                             |
| data          | to_status_name               | string    | The destination status name. Used with `status_transitioned` triggers to match transitions to this status.                                                                                                                               |
| trigger       | type [*required*]       | enum      | The case event that activates the automation rule. Allowed enum values: `case_created,status_transitioned,attribute_value_changed,event_correlation_signal_correlated,case_review_approved,comment_added`                                |
| data          | id [*required*]         | string    | Automation rule identifier.                                                                                                                                                                                                              |
| data          | relationships                | object    | Related resources for the automation rule, including the users who created and last modified it.                                                                                                                                         |
| relationships | created_by                   | object    | Relationship to user.                                                                                                                                                                                                                    |
| created_by    | data [*required*]       | object    | Relationship to user object.                                                                                                                                                                                                             |
| data          | id [*required*]         | string    | A unique identifier that represents the user.                                                                                                                                                                                            |
| data          | type [*required*]       | enum      | User resource type. Allowed enum values: `user`                                                                                                                                                                                          |
| relationships | modified_by                  | object    | Relationship to user.                                                                                                                                                                                                                    |
| modified_by   | data [*required*]       | object    | Relationship to user object.                                                                                                                                                                                                             |
| data          | id [*required*]         | string    | A unique identifier that represents the user.                                                                                                                                                                                            |
| data          | type [*required*]       | enum      | User resource type. Allowed enum values: `user`                                                                                                                                                                                          |
| data          | type [*required*]       | enum      | JSON:API resource type for case automation rules. Allowed enum values: `rule`                                                                                                                                                            |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "action": {
        "data": {
          "agent_type": "string",
          "assigned_agent_id": "string",
          "handle": "workflow-handle-123"
        },
        "type": "execute_workflow"
      },
      "created_at": "2024-01-01T00:00:00.000Z",
      "modified_at": "2019-09-19T10:00:00.000Z",
      "name": "Auto-assign workflow",
      "state": "ENABLED",
      "trigger": {
        "data": {
          "approval_type": "string",
          "change_type": "string",
          "field": "string",
          "from_status_name": "string",
          "to_status_name": "string"
        },
        "type": "case_created"
      }
    },
    "id": "e6773723-fe58-49ff-9975-dff00f14e28d",
    "relationships": {
      "created_by": {
        "data": {
          "id": "00000000-0000-0000-0000-000000000000",
          "type": "user"
        }
      },
      "modified_by": {
        "data": {
          "id": "00000000-0000-0000-0000-000000000000",
          "type": "user"
        }
      }
    },
    "type": "rule"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Path parameters export project_id="e555e290-ed65-49bd-ae18-8acbfcf18db7" \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/cases/projects/${project_id}/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "action": {
        "data": {
          "handle": "workflow-handle-123"
        },
        "type": "execute_workflow"
      },
      "name": "Auto-assign workflow",
      "state": "ENABLED",
      "trigger": {
        "type": "case_created"
      }
    },
    "type": "rule"
  }
}
EOF 
                
##### 

```python
"""
Create an automation rule returns "Created" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.case_management_api import CaseManagementApi
from datadog_api_client.v2.model.automation_rule_action import AutomationRuleAction
from datadog_api_client.v2.model.automation_rule_action_data import AutomationRuleActionData
from datadog_api_client.v2.model.automation_rule_action_type import AutomationRuleActionType
from datadog_api_client.v2.model.automation_rule_create import AutomationRuleCreate
from datadog_api_client.v2.model.automation_rule_create_attributes import AutomationRuleCreateAttributes
from datadog_api_client.v2.model.automation_rule_create_request import AutomationRuleCreateRequest
from datadog_api_client.v2.model.automation_rule_trigger import AutomationRuleTrigger
from datadog_api_client.v2.model.automation_rule_trigger_data import AutomationRuleTriggerData
from datadog_api_client.v2.model.automation_rule_trigger_type import AutomationRuleTriggerType
from datadog_api_client.v2.model.case_automation_rule_resource_type import CaseAutomationRuleResourceType
from datadog_api_client.v2.model.case_automation_rule_state import CaseAutomationRuleState

body = AutomationRuleCreateRequest(
    data=AutomationRuleCreate(
        attributes=AutomationRuleCreateAttributes(
            action=AutomationRuleAction(
                data=AutomationRuleActionData(
                    handle="workflow-handle-123",
                ),
                type=AutomationRuleActionType.EXECUTE_WORKFLOW,
            ),
            name="Auto-assign workflow",
            state=CaseAutomationRuleState.ENABLED,
            trigger=AutomationRuleTrigger(
                data=AutomationRuleTriggerData(),
                type=AutomationRuleTriggerType.CASE_CREATED,
            ),
        ),
        type=CaseAutomationRuleResourceType.RULE,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_case_automation_rule"] = True
with ApiClient(configuration) as api_client:
    api_instance = CaseManagementApi(api_client)
    response = api_instance.create_case_automation_rule(project_id="project_id", body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Create an automation rule returns "Created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.create_case_automation_rule".to_sym] = true
end
api_instance = DatadogAPIClient::V2::CaseManagementAPI.new

body = DatadogAPIClient::V2::AutomationRuleCreateRequest.new({
  data: DatadogAPIClient::V2::AutomationRuleCreate.new({
    attributes: DatadogAPIClient::V2::AutomationRuleCreateAttributes.new({
      action: DatadogAPIClient::V2::AutomationRuleAction.new({
        data: DatadogAPIClient::V2::AutomationRuleActionData.new({
          handle: "workflow-handle-123",
        }),
        type: DatadogAPIClient::V2::AutomationRuleActionType::EXECUTE_WORKFLOW,
      }),
      name: "Auto-assign workflow",
      state: DatadogAPIClient::V2::CaseAutomationRuleState::ENABLED,
      trigger: DatadogAPIClient::V2::AutomationRuleTrigger.new({
        data: DatadogAPIClient::V2::AutomationRuleTriggerData.new({}),
        type: DatadogAPIClient::V2::AutomationRuleTriggerType::CASE_CREATED,
      }),
    }),
    type: DatadogAPIClient::V2::CaseAutomationRuleResourceType::RULE,
  }),
})
p api_instance.create_case_automation_rule("project_id", body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Create an automation rule returns "Created" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.AutomationRuleCreateRequest{
		Data: datadogV2.AutomationRuleCreate{
			Attributes: datadogV2.AutomationRuleCreateAttributes{
				Action: datadogV2.AutomationRuleAction{
					Data: datadogV2.AutomationRuleActionData{
						Handle: datadog.PtrString("workflow-handle-123"),
					},
					Type: datadogV2.AUTOMATIONRULEACTIONTYPE_EXECUTE_WORKFLOW,
				},
				Name:  "Auto-assign workflow",
				State: datadogV2.CASEAUTOMATIONRULESTATE_ENABLED.Ptr(),
				Trigger: datadogV2.AutomationRuleTrigger{
					Data: &datadogV2.AutomationRuleTriggerData{},
					Type: datadogV2.AUTOMATIONRULETRIGGERTYPE_CASE_CREATED,
				},
			},
			Type: datadogV2.CASEAUTOMATIONRULERESOURCETYPE_RULE,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateCaseAutomationRule", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewCaseManagementApi(apiClient)
	resp, r, err := api.CreateCaseAutomationRule(ctx, "project_id", body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.CreateCaseAutomationRule`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `CaseManagementApi.CreateCaseAutomationRule`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Create an automation rule returns "Created" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CaseManagementApi;
import com.datadog.api.client.v2.model.AutomationRuleAction;
import com.datadog.api.client.v2.model.AutomationRuleActionData;
import com.datadog.api.client.v2.model.AutomationRuleActionType;
import com.datadog.api.client.v2.model.AutomationRuleCreate;
import com.datadog.api.client.v2.model.AutomationRuleCreateAttributes;
import com.datadog.api.client.v2.model.AutomationRuleCreateRequest;
import com.datadog.api.client.v2.model.AutomationRuleResponse;
import com.datadog.api.client.v2.model.AutomationRuleTrigger;
import com.datadog.api.client.v2.model.AutomationRuleTriggerData;
import com.datadog.api.client.v2.model.AutomationRuleTriggerType;
import com.datadog.api.client.v2.model.CaseAutomationRuleResourceType;
import com.datadog.api.client.v2.model.CaseAutomationRuleState;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.createCaseAutomationRule", true);
    CaseManagementApi apiInstance = new CaseManagementApi(defaultClient);

    AutomationRuleCreateRequest body =
        new AutomationRuleCreateRequest()
            .data(
                new AutomationRuleCreate()
                    .attributes(
                        new AutomationRuleCreateAttributes()
                            .action(
                                new AutomationRuleAction()
                                    .data(
                                        new AutomationRuleActionData()
                                            .handle("workflow-handle-123"))
                                    .type(AutomationRuleActionType.EXECUTE_WORKFLOW))
                            .name("Auto-assign workflow")
                            .state(CaseAutomationRuleState.ENABLED)
                            .trigger(
                                new AutomationRuleTrigger()
                                    .data(new AutomationRuleTriggerData())
                                    .type(AutomationRuleTriggerType.CASE_CREATED)))
                    .type(CaseAutomationRuleResourceType.RULE));

    try {
      AutomationRuleResponse result =
          apiInstance.createCaseAutomationRule("e555e290-ed65-49bd-ae18-8acbfcf18db7", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling CaseManagementApi#createCaseAutomationRule");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Create an automation rule returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_case_management::CaseManagementAPI;
use datadog_api_client::datadogV2::model::AutomationRuleAction;
use datadog_api_client::datadogV2::model::AutomationRuleActionData;
use datadog_api_client::datadogV2::model::AutomationRuleActionType;
use datadog_api_client::datadogV2::model::AutomationRuleCreate;
use datadog_api_client::datadogV2::model::AutomationRuleCreateAttributes;
use datadog_api_client::datadogV2::model::AutomationRuleCreateRequest;
use datadog_api_client::datadogV2::model::AutomationRuleTrigger;
use datadog_api_client::datadogV2::model::AutomationRuleTriggerData;
use datadog_api_client::datadogV2::model::AutomationRuleTriggerType;
use datadog_api_client::datadogV2::model::CaseAutomationRuleResourceType;
use datadog_api_client::datadogV2::model::CaseAutomationRuleState;

#[tokio::main]
async fn main() {
    let body = AutomationRuleCreateRequest::new(AutomationRuleCreate::new(
        AutomationRuleCreateAttributes::new(
            AutomationRuleAction::new(
                AutomationRuleActionData::new().handle("workflow-handle-123".to_string()),
                AutomationRuleActionType::EXECUTE_WORKFLOW,
            ),
            "Auto-assign workflow".to_string(),
            AutomationRuleTrigger::new(AutomationRuleTriggerType::CASE_CREATED)
                .data(AutomationRuleTriggerData::new()),
        )
        .state(CaseAutomationRuleState::ENABLED),
        CaseAutomationRuleResourceType::RULE,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateCaseAutomationRule", true);
    let api = CaseManagementAPI::with_config(configuration);
    let resp = api
        .create_case_automation_rule("project_id".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Create an automation rule returns "Created" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.createCaseAutomationRule"] = true;
const apiInstance = new v2.CaseManagementApi(configuration);

const params: v2.CaseManagementApiCreateCaseAutomationRuleRequest = {
  body: {
    data: {
      attributes: {
        action: {
          data: {
            handle: "workflow-handle-123",
          },
          type: "execute_workflow",
        },
        name: "Auto-assign workflow",
        state: "ENABLED",
        trigger: {
          data: {},
          type: "case_created",
        },
      },
      type: "rule",
    },
  },
  projectId: "project_id",
};

apiInstance
  .createCaseAutomationRule(params)
  .then((data: v2.AutomationRuleResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
