All Products
Search
Document Center

Resource Management:CreatePolicy

Last Updated:Aug 28, 2026

Creates a tag policy.

Operation description

The following example creates a tag policy named test in multi-account mode. The policy defines that resources tagged with CostCenter:Beijing or CostCenter:Shanghai are compliant and other resources are not compliant.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

tag:CreatePolicy

create

*Policy

acs:tag::{#accountId}:policy/*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

No

Region ID. Set this to cn-shanghai.

cn-shanghai

PolicyName

string

Yes

The tag policy name.

1 to 128 characters. Supports letters, digits, and underscores (_).

test

PolicyDesc

string

No

The tag policy description.

0 to 512 characters.

This is a tag policy example.

PolicyContent

string

Yes

The tag policy document.

For tag policy syntax, see Syntax of a tag policy.

{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}}

DryRun

boolean

No

Whether to perform a dry run only. Valid values:

  • false (default): runs the dry run and sends the actual request.

  • true: runs the dry run only.

false

UserType

string

No

The Tag Policy feature mode. Valid values:

  • USER: single-account mode. Use this value when an Alibaba Cloud account or a resource directory member creates a tag policy for that account or member.

  • RD: multi-account mode. Use this value when the management account of a resource directory creates a tag policy for the directory.

For details on Tag Policy modes, see Modes of the Tag Policy feature.

RD

For common request parameters, see Common parameters.

Response elements

Element

Type

Description

Example

object

The returned result.

RequestId

string

The request ID.

FDBE270D-C491-5EEC-A5CD-98245422D3F7

PolicyId

string

The ID of the tag policy.

p-5732750813924f90****

PolicyName

string

The name of the tag policy.

test

Examples

Success response

JSON format

{
  "RequestId": "FDBE270D-C491-5EEC-A5CD-98245422D3F7",
  "PolicyId": "p-5732750813924f90****",
  "PolicyName": "test"
}

Error codes

HTTP status code

Error code

Error message

Description

400 NoPermission.RAM The operator is not permission for the action in ram policy. The account is not supported.
403 EffectivePolicy.ResourceGroupScope.TooLong The resource group range of for effective policy is too long. The resource group range for a valid policy is too long.
403 RDAcount.HasOpened As the RD master or administrator, you cannot activate the tag policy service because account has already enabled it, you can only activate it once the policy service is disabled by the aforementioned RD account. The member account of the resource directory has a tag policy. You must disable the member account before you can activate the multi-account mode.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.