

# CreateAutomationRule
<a name="API_automation_CreateAutomationRule"></a>

 Creates a new automation rule to apply recommended actions to resources based on specified criteria. 

## Request Syntax
<a name="API_automation_CreateAutomationRule_RequestSyntax"></a>

```
{
   "clientToken": "string",
   "criteria": { 
      "ebsVolumeSizeInGib": [ 
         { 
            "comparison": "string",
            "values": [ number ]
         }
      ],
      "ebsVolumeType": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ],
      "estimatedMonthlySavings": [ 
         { 
            "comparison": "string",
            "values": [ number ]
         }
      ],
      "lookBackPeriodInDays": [ 
         { 
            "comparison": "string",
            "values": [ number ]
         }
      ],
      "region": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ],
      "resourceArn": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ],
      "resourceTag": [ 
         { 
            "comparison": "string",
            "key": "string",
            "values": [ "string" ]
         }
      ],
      "restartNeeded": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ]
   },
   "description": "string",
   "name": "string",
   "organizationConfiguration": { 
      "accountIds": [ "string" ],
      "ruleApplyOrder": "string"
   },
   "priority": "string",
   "recommendedActionTypes": [ "string" ],
   "ruleType": "string",
   "schedule": { 
      "executionWindowInMinutes": number,
      "scheduleExpression": "string",
      "scheduleExpressionTimezone": "string"
   },
   "status": "string",
   "tags": [ 
      { 
         "key": "string",
         "value": "string"
      }
   ]
}
```

## Request Parameters
<a name="API_automation_CreateAutomationRule_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [clientToken](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-clientToken"></a>
 A unique identifier to ensure idempotency of the request.   
Type: String  
Pattern: `[a-zA-Z0-9_-]{1,64}`   
Required: No

 ** [criteria](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-criteria"></a>
A set of conditions that specify which recommended action qualify for implementation. When a rule is active and a recommended action matches these criteria, Compute Optimizer implements the action at the scheduled run time.   
Type: [Criteria](API_automation_Criteria.md) object  
Required: No

 ** [description](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-description"></a>
 A description of the automation rule.   
Type: String  
Length Constraints: Minimum length of 0. Maximum length of 1024.  
Pattern: `[a-zA-Z0-9_\-\s@\.]*`   
Required: No

 ** [name](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-name"></a>
 The name of the automation rule.   
Type: String  
Length Constraints: Minimum length of 0. Maximum length of 128.  
Pattern: `[a-zA-Z0-9_-]*`   
Required: Yes

 ** [organizationConfiguration](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-organizationConfiguration"></a>
 Configuration for organization-level rules. Required for OrganizationRule type.   
Type: [OrganizationConfiguration](API_automation_OrganizationConfiguration.md) object  
Required: No

 ** [priority](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-priority"></a>
A string representation of a decimal number between 0 and 1 (having up to 30 digits after the decimal point) that determines the priority of the rule. When multiple rules match the same recommended action, Compute Optimizer assigns the action to the rule with the lowest priority value (highest priority), even if that rule is scheduled to run later than other matching rules.   
Type: String  
Required: No

 ** [recommendedActionTypes](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-recommendedActionTypes"></a>
 The types of recommended actions this rule will automate.   
Type: Array of strings  
Valid Values: `SnapshotAndDeleteUnattachedEbsVolume | UpgradeEbsVolumeType`   
Required: Yes

 ** [ruleType](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-ruleType"></a>
 The type of rule.   
Only the management account or a delegated administrator can set the ruleType to be OrganizationRule.
Type: String  
Valid Values: `OrganizationRule | AccountRule`   
Required: Yes

 ** [schedule](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-schedule"></a>
 The schedule for when the rule should run.   
Type: [Schedule](API_automation_Schedule.md) object  
Required: Yes

 ** [status](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-status"></a>
The status of the rule   
Type: String  
Valid Values: `Active | Inactive`   
Required: Yes

 ** [tags](#API_automation_CreateAutomationRule_RequestSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-request-tags"></a>
 The tags to associate with the rule.   
Type: Array of [Tag](API_automation_Tag.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 200 items.  
Required: No

## Response Syntax
<a name="API_automation_CreateAutomationRule_ResponseSyntax"></a>

```
{
   "createdTimestamp": number,
   "criteria": { 
      "ebsVolumeSizeInGib": [ 
         { 
            "comparison": "string",
            "values": [ number ]
         }
      ],
      "ebsVolumeType": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ],
      "estimatedMonthlySavings": [ 
         { 
            "comparison": "string",
            "values": [ number ]
         }
      ],
      "lookBackPeriodInDays": [ 
         { 
            "comparison": "string",
            "values": [ number ]
         }
      ],
      "region": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ],
      "resourceArn": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ],
      "resourceTag": [ 
         { 
            "comparison": "string",
            "key": "string",
            "values": [ "string" ]
         }
      ],
      "restartNeeded": [ 
         { 
            "comparison": "string",
            "values": [ "string" ]
         }
      ]
   },
   "description": "string",
   "name": "string",
   "organizationConfiguration": { 
      "accountIds": [ "string" ],
      "ruleApplyOrder": "string"
   },
   "priority": "string",
   "recommendedActionTypes": [ "string" ],
   "ruleArn": "string",
   "ruleId": "string",
   "ruleRevision": number,
   "ruleType": "string",
   "schedule": { 
      "executionWindowInMinutes": number,
      "scheduleExpression": "string",
      "scheduleExpressionTimezone": "string"
   },
   "status": "string",
   "tags": [ 
      { 
         "key": "string",
         "value": "string"
      }
   ]
}
```

## Response Elements
<a name="API_automation_CreateAutomationRule_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [createdTimestamp](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-createdTimestamp"></a>
The timestamp when the automation rule was created.  
Type: Timestamp

 ** [criteria](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-criteria"></a>
 A set of conditions that specify which recommended action qualify for implementation. When a rule is active and a recommended action matches these criteria, Compute Optimizer implements the action at the scheduled run time. You can specify up to 20 conditions per filter criteria and 20 values per condition.   
Type: [Criteria](API_automation_Criteria.md) object

 ** [description](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-description"></a>
A description of the automation rule. Can be up to 1024 characters long and contain alphanumeric characters, underscores, hyphens, spaces, and certain special characters.  
Type: String

 ** [name](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-name"></a>
The name of the automation rule. Must be 1-128 characters long and contain only alphanumeric characters, underscores, and hyphens.  
Type: String  
Length Constraints: Minimum length of 0. Maximum length of 128.  
Pattern: `[a-zA-Z0-9_-]*` 

 ** [organizationConfiguration](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-organizationConfiguration"></a>
Configuration settings for organization-wide rules, including rule application order and target account IDs.  
Type: [OrganizationConfiguration](API_automation_OrganizationConfiguration.md) object

 ** [priority](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-priority"></a>
The priority level of the automation rule, used to determine execution order when multiple rules apply to the same resource.  
Type: String

 ** [recommendedActionTypes](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-recommendedActionTypes"></a>
List of recommended action types that this rule can execute, such as SnapshotAndDeleteUnattachedEbsVolume or UpgradeEbsVolumeType.  
Type: Array of strings  
Valid Values: `SnapshotAndDeleteUnattachedEbsVolume | UpgradeEbsVolumeType` 

 ** [ruleArn](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-ruleArn"></a>
 The Amazon Resource Name (ARN) of the created rule.   
Type: String  
Pattern: `arn:aws:compute-optimizer::[0-9]{12}:automation-rule/[a-zA-Z0-9_-]+` 

 ** [ruleId](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-ruleId"></a>
 The unique identifier of the created rule.   
Type: String  
Pattern: `[0-9A-Za-z]{16}` 

 ** [ruleRevision](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-ruleRevision"></a>
The revision number of the automation rule. This is incremented each time the rule is updated.  
Type: Long

 ** [ruleType](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-ruleType"></a>
The type of automation rule. Can be either OrganizationRule for organization-wide rules or AccountRule for account-specific rules.  
Type: String  
Valid Values: `OrganizationRule | AccountRule` 

 ** [schedule](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-schedule"></a>
The schedule configuration for when the automation rule should execute, including cron expression, timezone, and execution window.  
Type: [Schedule](API_automation_Schedule.md) object

 ** [status](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-status"></a>
The current status of the automation rule. Can be Active or Inactive.  
Type: String  
Valid Values: `Active | Inactive` 

 ** [tags](#API_automation_CreateAutomationRule_ResponseSyntax) **   <a name="computeoptimizer-automation_CreateAutomationRule-response-tags"></a>
A list of key-value pairs used to categorize and organize the automation rule. Maximum of 200 tags allowed.  
Type: Array of [Tag](API_automation_Tag.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 200 items.

## Errors
<a name="API_automation_CreateAutomationRule_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** AccessDeniedException **   
 You do not have sufficient permissions to perform this action.   
HTTP Status Code: 400

 ** ForbiddenException **   
 You are not authorized to perform this action.   
HTTP Status Code: 400

 ** IdempotencyTokenInUseException **   
 The specified client token is already in use.   
HTTP Status Code: 400

 ** IdempotentParameterMismatchException **   
Exception thrown when the same client token is used with different parameters, indicating a mismatch in idempotent request parameters.  
HTTP Status Code: 400

 ** InternalServerException **   
 An internal error occurred while processing the request.   
HTTP Status Code: 500

 ** InvalidParameterValueException **   
 One or more parameter values are not valid.   
HTTP Status Code: 400

 ** OptInRequiredException **   
 The account must be opted in to Compute Optimizer Automation before performing this action.   
HTTP Status Code: 400

 ** ResourceNotFoundException **   
 The specified resource was not found.   
HTTP Status Code: 400

 ** ServiceQuotaExceededException **   
 The request would exceed service quotas.   
HTTP Status Code: 400

 ** ServiceUnavailableException **   
 The service is temporarily unavailable.   
HTTP Status Code: 500

 ** ThrottlingException **   
 The request was denied due to request throttling.   
HTTP Status Code: 400

## See Also
<a name="API_automation_CreateAutomationRule_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/compute-optimizer-automation-2025-09-22/CreateAutomationRule) 