Create a Tag
/20160918/tagNamespaces/{tag_namespace_id}/tags
You must specify a name for the tag, which must be unique across all tags in the tag namespace and cannot be changed. The name can contain any ASCII character except the space or period characters. Names are case insensitive. That means, for example, "myTag" and "mytag" are not allowed in the same namespace. If you specify a name that is already in use in the tag namespace, a 409 error is returned.
The tag must have a description. The description does not need to be unique, and you can change it with UpdateTag.
The tag must have a value type, which is specified with a validator. Tags can use either a static value or a list of possible values. Static values are entered by a user applying the tag to a resource. Lists are created by you, and the user must apply a value from the list. Lists are validiated.
Request
- application/json
-
tagNamespaceId(required): string
Minimum Length:
1Maximum Length:100The OCID of the tag namespace.
-
isLockOverride: boolean
Whether to override locks (if any exist).Default Value:
false
-
opc-retry-token: string
Minimum Length:
1Maximum Length:64A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (for example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).
object-
definedTags:
object definedTags
Additional Properties Allowed: additionalPropertiesDefined tags for this resource. Each key is predefined and scoped to a namespace. Example: {"Operations": {"CostCenter": "42"}}
-
description(required):
string
Minimum Length:
1Maximum Length:400The description you assign to the tag during creation. -
freeformTags:
object freeformTags
Additional Properties Allowed: additionalPropertiesFree-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Example: {"Department": "Finance"}
-
isCostTracking:
boolean
Indicates whether the tag is enabled for cost tracking.
-
name(required):
string
Minimum Length:
1Maximum Length:100The name you assign to the tag during creation. This is the tag key definition. The name must be unique within the tag namespace and cannot be changed. -
validator:
object BaseTagDefinitionValidator
Discriminator:
validatorTypeValidates a definedTag value. Each validator performs validation steps in addition to the standard validation for definedTag values. If you define a validator after a value has been set for a defined tag, then any updates that attempt to change the value must pass the additional validation defined by the current rule. Previously set values (even those that would fail the current validation) are not updated. You can still update other attributes to resources that contain a non-valid defined tag. To clear the validator call UpdateTag with [DefaultTagDefinitionValidator](/api/#/en/identity/latest/datatypes/DefaultTagDefinitionValidator).
object-
object additionalProperties
Additional Properties Allowed: additionalPropertiesKey-value pair representing a defined tag key and value, scoped to a namespace. Example: `{"CostCenter": "42"}`
objectobjectvalidatorType-
validatorType(required):
string
Allowed Values:
[ "ENUM", "DEFAULT" ]Specifies the type of validation: a static value (no validation) or a list.
object-
object additionalProperties
The value of the tag. Only the String type is supported.
objectResponse
- application/json
200 Response
-
etag: string
For optimistic concurrency control. See `if-match`.
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
compartmentId(required):
string
Minimum Length:
1Maximum Length:100The OCID of the compartment that contains the tag definition. -
definedTags:
object definedTags
Additional Properties Allowed: additionalPropertiesDefined tags for this resource. Each key is predefined and scoped to a namespace. Example: {"Operations": {"CostCenter": "42"}}
-
description(required):
string
Minimum Length:
1Maximum Length:400The description you assign to the tag. -
freeformTags:
object freeformTags
Additional Properties Allowed: additionalPropertiesFree-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Example: {"Department": "Finance"}
-
id(required):
string
Minimum Length:
1Maximum Length:100The OCID of the tag definition. -
isCostTracking:
boolean
Indicates whether the tag is enabled for cost tracking.
-
isRetired(required):
boolean
Indicates whether the tag is retired.
-
lifecycleState:
string
Allowed Values:
[ "ACTIVE", "INACTIVE", "DELETING", "DELETED" ]The tag's current state. After creating a tag, make sure its lifecycleState is ACTIVE before using it. After retiring a tag, make sure its lifecycleState is INACTIVE before using it. If you delete a tag, you cannot delete another tag until the deleted tag's lifecycleState changes from DELETING to DELETED. -
name(required):
string
Minimum Length:
1Maximum Length:100The name assigned to the tag during creation. This is the tag key definition. The name must be unique within the tag namespace and cannot be changed. -
tagNamespaceId(required):
string
Minimum Length:
1Maximum Length:100The OCID of the namespace that contains the tag definition. -
tagNamespaceName(required):
string
Minimum Length:
1Maximum Length:100The name of the tag namespace that contains the tag definition. -
timeCreated(required):
string(date-time)
Date and time the tag was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
-
validator:
object BaseTagDefinitionValidator
Discriminator:
validatorTypeValidates a definedTag value. Each validator performs validation steps in addition to the standard validation for definedTag values. If you define a validator after a value has been set for a defined tag, then any updates that attempt to change the value must pass the additional validation defined by the current rule. Previously set values (even those that would fail the current validation) are not updated. You can still update other attributes to resources that contain a non-valid defined tag. To clear the validator call UpdateTag with [DefaultTagDefinitionValidator](/api/#/en/identity/latest/datatypes/DefaultTagDefinitionValidator).
object-
object additionalProperties
Additional Properties Allowed: additionalPropertiesKey-value pair representing a defined tag key and value, scoped to a namespace. Example: `{"CostCenter": "42"}`
objectobjectvalidatorType-
validatorType(required):
string
Allowed Values:
[ "ENUM", "DEFAULT" ]Specifies the type of validation: a static value (no validation) or a list.
object-
object additionalProperties
The value of the tag. Only the String type is supported.
object{ "name" : "CostCenter", "description" : "This tag will show the cost center that will be used for billing of associated resources.", "type" : "string", "tagNamespaceId" : "ocid1.namespace.oc1..aaaaaaaaqexampleuniqueID", "tagNameSpaceName" : "BillingTags", "compartmentId" : "ocid1.tenancy.oc1..aaaaaaaabaexampleuniqueID", "isRetired" : "false", "lifecycleState" : "ACTIVE", "timeCreated" : "2017-09-01T18:13:12.210Z", "isCostTracking" : "true", "validator" : {} }
400 Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.
401 Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.
404 Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.
409 Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.
429 Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.
500 Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.
Default Response
-
opc-request-id: string
Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
object-
code(required):
string
A short error code that defines the error, meant for programmatic parsing. See [API Errors](https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm).
-
message(required):
string
A human-readable error string.