Updated on 2025-10-17 GMT+08:00

Creating an Organization Policy

Function

This API is used to create an organization policy.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v3/{project_id}/organization-policies

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token

The token can be obtained by calling the IAM API used to obtain a user token. The user token is the value of X-Subject-Token in the response header.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

policy

Yes

OrganizationPolicyCreate object

  
Table 4 OrganizationPolicyCreate

Parameter

Mandatory

Type

Description

name

Yes

String

Organization Policy Name

description

No

String

Organization Policy Description

operation_type

Yes

String

Organization policy type, which can be backup or replication.

policy_name

Yes

String

Policy Name

policy_enabled

Yes

Boolean

Whether the policy is enabled. Default value: N/A The value can be:

  • true: The policy is enabled, and tasks are triggered periodically.

  • false: The policy is disabled, and tasks are not triggered periodically.

policy_operation_definition

Yes

PolicyoODCreate object

Policy definition. The specific fields in backup and replication are different and consistent with those in the policy.

policy_trigger

Yes

PolicyTriggerReq object

Time rule for the policy execution

effective_scope

No

String

Application scope of the organizational policy.

Table 5 PolicyoODCreate

Parameter

Mandatory

Type

Description

day_backups

No

Integer

Number of daily backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

destination_project_id

No

String

Project ID of the destination region, which is mandatory for cross-region replication. Default value: N/A

For details about how to obtain the project ID, see Obtaining a Project ID.

destination_region

No

String

Destination region, which is mandatory for cross-region replication. The destination region cannot be the same as the current region. The value contains a maximum of 255 characters, including only letters, digits, underscores (_), and hyphens (-). Default value: N/A

For details about how to obtain the region ID, see Querying Regions and Endpoints.

enable_acceleration

No

Boolean

Whether to enable acceleration to shorten the cross-region replication time. If this parameter is not set, the acceleration function is disabled. If enabled, the acceleration function is additionally charged.

  • true: The acceleration function is enabled.

  • false: The acceleration function is disabled.

max_backups

No

Integer

Maximum number of backups that can be automatically created for a resource. The value can be -1 or in the range of 1 to 99999. Default value: N/A If the value is set to -1, backups will not be cleared when they reach the quantity limit. If this parameter and retention_duration_days are both left unspecified, backups will be retained permanently. This parameter and retention_duration_days cannot be both specified.

month_backups

No

Integer

Number of monthly backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

retention_duration_days

No

Integer

Backup retention period, in days. The maximum value is 99999. Default value: N/A -1 indicates that the backups will not be cleared based on the retention duration. If this parameter and max_backups are both left blank, the backups will be retained permanently. This parameter cannot be applied together with max_backups, day_backups, week_backups, month_backups, or year_backups.

timezone

No

String

Time zone where the user is located, for example, UTC+08:00. Default value: N/A If any of the yearly, monthly, weekly, and daily backup parameters is selected, this parameter cannot be left blank.

week_backups

No

Integer

Number of weekly backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

year_backups

No

Integer

Number of yearly backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

full_backup_interval

No

Integer

Defines how often a full backup is performed. If -1 is specified, full backup will not be performed. Range: [-1, 100]; Default value: N/A

Table 6 PolicyTriggerReq

Parameter

Mandatory

Type

Description

properties

Yes

PolicyTriggerPropertiesReq object

Policy scheduler attributes.

Table 7 PolicyTriggerPropertiesReq

Parameter

Mandatory

Type

Description

pattern

Yes

Array of strings

Scheduling rule. A maximum of 24 rules can be configured. Scheduling rule. It complies with iCalendar RFC 2445, but it supports only parameters FREQ, BYDAY, BYHOUR, BYMINUTE, and INTERVAL. FREQ can be set only to WEEKLY or DAILY. BYDAY* can be set to MO, TU, WE, TH, FR, SA, or SU (seven days of a week). BYHOUR ranges from 0 to 23 hours. BYMINUTE ranges from 0 minutes to 59 minutes. The scheduling interval must not be less than 1 hour. A maximum of 24 time points can be configured in a day. For example, if the scheduling time is 14:00 (UTC time) from Monday to Sunday, set the scheduling rule as follows: FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00. For example, if the local time zone is UTC+8 and scheduling occurs daily at 14:00, the value of FREQ should reflect the equivalent UTC time, which is 14:00 minus 8 hours. The corresponding rule is: FREQ=DAILY;INTERVAL=1;BYHOUR=6;BYMINUTE=00. Default value: N/A

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

policy

OrganizationPolicy object

Organization Policy Details

Table 9 OrganizationPolicy

Parameter

Type

Description

id

String

Organization Policy ID

name

String

Organization Policy Name

description

String

Organization Policy Description

operation_type

String

Organizational policy type.

  • backup

  • replication

domain_id

String

Specifies the ID of the account to which the organization policy belongs.

policy_name

String

Policy Name

policy_enabled

Boolean

Whether the policy is enabled. Default value: N/A The value can be:

  • true: The policy is enabled, and tasks are triggered periodically.

  • false: The policy is disabled, and tasks are not triggered periodically.

policy_operation_definition

PolicyoODCreate object

Policy definition. The specific fields in backup and replication are different and consistent with those in the policy.

policy_trigger

PolicyTriggerReq object

Time rule for the policy execution

status

String

Organizational policy status. The value can be updating, deleting, or available.

updating: The organizational policy is being updated.

deleting: The organizational policy is being deleted.

available: The organizational policy is available. No operations are performed on the organizational policy.

domain_name

String

Account to which the organizational policy belongs.

effective_scope

String

Application scope of the organizational policy.

Table 10 PolicyoODCreate

Parameter

Type

Description

day_backups

Integer

Number of daily backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

destination_project_id

String

Project ID of the destination region, which is mandatory for cross-region replication. Default value: N/A

For details about how to obtain the project ID, see Obtaining a Project ID.

destination_region

String

Destination region, which is mandatory for cross-region replication. The destination region cannot be the same as the current region. The value contains a maximum of 255 characters, including only letters, digits, underscores (_), and hyphens (-). Default value: N/A

For details about how to obtain the region ID, see Querying Regions and Endpoints.

enable_acceleration

Boolean

Whether to enable acceleration to shorten the cross-region replication time. If this parameter is not set, the acceleration function is disabled. If enabled, the acceleration function is additionally charged.

  • true: The acceleration function is enabled.

  • false: The acceleration function is disabled.

max_backups

Integer

Maximum number of backups that can be automatically created for a resource. The value can be -1 or in the range of 1 to 99999. Default value: N/A If the value is set to -1, backups will not be cleared when they reach the quantity limit. If this parameter and retention_duration_days are both left unspecified, backups will be retained permanently. This parameter and retention_duration_days cannot be both specified.

month_backups

Integer

Number of monthly backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

retention_duration_days

Integer

Backup retention period, in days. The maximum value is 99999. Default value: N/A -1 indicates that the backups will not be cleared based on the retention duration. If this parameter and max_backups are both left blank, the backups will be retained permanently. This parameter cannot be applied together with max_backups, day_backups, week_backups, month_backups, or year_backups.

timezone

String

Time zone where the user is located, for example, UTC+08:00. Default value: N/A If any of the yearly, monthly, weekly, and daily backup parameters is selected, this parameter cannot be left blank.

week_backups

Integer

Number of weekly backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

year_backups

Integer

Number of yearly backups retained, which is not affected by the allowed maximum number of retained backups. The value ranges from 0 to 100. Default value: N/A If this parameter is configured, timezone is mandatory. This parameter and retention_duration_days cannot be both specified.

full_backup_interval

Integer

Defines how often a full backup is performed. If -1 is specified, full backup will not be performed. Range: [-1, 100]; Default value: N/A

Table 11 PolicyTriggerReq

Parameter

Type

Description

properties

PolicyTriggerPropertiesReq object

Policy scheduler attributes.

Table 12 PolicyTriggerPropertiesReq

Parameter

Type

Description

pattern

Array of strings

Scheduling rule. A maximum of 24 rules can be configured. Scheduling rule. It complies with iCalendar RFC 2445, but it supports only parameters FREQ, BYDAY, BYHOUR, BYMINUTE, and INTERVAL. FREQ can be set only to WEEKLY or DAILY. BYDAY* can be set to MO, TU, WE, TH, FR, SA, or SU (seven days of a week). BYHOUR ranges from 0 to 23 hours. BYMINUTE ranges from 0 minutes to 59 minutes. The scheduling interval must not be less than 1 hour. A maximum of 24 time points can be configured in a day. For example, if the scheduling time is 14:00 (UTC time) from Monday to Sunday, set the scheduling rule as follows: FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00. For example, if the local time zone is UTC+8 and scheduling occurs daily at 14:00, the value of FREQ should reflect the equivalent UTC time, which is 14:00 minus 8 hours. The corresponding rule is: FREQ=DAILY;INTERVAL=1;BYHOUR=6;BYMINUTE=00. Default value: N/A

Example Requests

Creating an organization policy

POST https://{endpoint}/v3/{project_id}/organization-policies

{
  "policy" : {
    "policy_enabled" : false,
    "policy_name" : "policy_create_test",
    "policy_operation_definition" : {
      "retention_duration_days" : 30,
      "max_backups" : -1,
      "day_backups" : 0,
      "week_backups" : 0,
      "month_backups" : 0,
      "year_backups" : 0,
      "timezone" : "UTC+08:00",
      "full_backup_interval" : -1
    },
    "policy_trigger" : {
      "properties" : {
        "pattern" : [ "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00" ]
      }
    },
    "operation_type" : "backup",
    "name" : "organization-policies_create_test",
    "description" : "",
    "effective_scope" : "o-dgit8w537q7np40f9i22j9ieotkuxbjq"
  }
}

Example Responses

Status code: 200

OK

{
  "policy" : {
    "id" : "5f5dd325-d7d1-4693-9d97-db37ecb91696",
    "name" : "organization-policies_create_test",
    "description" : "",
    "operation_type" : "backup",
    "domain_id" : "0ae13f008700d53f0fb4c01200e79660",
    "policy_name" : "policy_create_test",
    "policy_operation_definition" : {
      "max_backups" : -1,
      "retention_duration_days" : 30,
      "day_backups" : 0,
      "week_backups" : 0,
      "month_backups" : 0,
      "year_backups" : 0,
      "timezone" : "UTC+08:00",
      "full_backup_interval" : -1
    },
    "policy_enabled" : false,
    "policy_trigger" : {
      "properties" : {
        "pattern" : [ "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00" ]
      }
    },
    "status" : "syncing",
    "effective_scope" : "o-dgit8w537q7np40f9i22j9ieotkuxbjq"
  }
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.