Create tag
Updated at:2025-10-20
Description
- This interface allows the creation of one or more tags.
- Use the respective product APIs to bind tags to specific resources.
- Skip creation if the tag already exists.
- Tag keys and values shall comply with specifications in [Tag](BCC/Tag Service API Reference/Appendix 1.md#Tag). Tag keys shall not be empty.
Request
Request structure
Plain Text
1PUT /v{version}/tag?create HTTP/1.1
2Host: tag.baidubce.com
3Authorization: authorization string
4
5{
6 "tags": [
7 {
8 "tagKey": tagKey,
9 "tagValue": tagValue
10 }
11 ]
12}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Whether required | Parameter location | Description |
|---|---|---|---|---|
| version | String | Yes | URL parameter | API version number |
| tags | List<[Tag](BCC/Tag Service API Reference/Appendix 1.md#Tag)> | Yes | Request Body parameters | List of tag key-value pairs to be created |
Response
Response headers
No special headers are required beyond the standard ones.
Response parameters
There are no special response parameters
Error code
| Error code | Error description | HTTP status code | Chinese explanation |
|---|---|---|---|
| TagExceptions.TagKeyInvalid | Tag key contains invalid characters or length exceeds limit. | 400 | The tag key contains invalid characters or exceeds the length limit. |
| TagExceptions.TagValueInvalid | Tag value contains invalid characters or length exceeds limit. | 400 | The tag value contains invalid characters or exceeds the length limit. |
| TagExceptions.TagKeyEmpty | Tag key should not be empty. | 400 | The tag key shall not be empty. |
| TagExceptions.TagEmpty | Tag should not be empty. | 400 | The tag shall not be empty. |
| TagExceptions.LimitExceeded | Limit exceeded for current request. | 413 | Total tags created exceeds limit. |
Example
Request example
Plain Text
1PUT /v1/tag?create HTTP/1.1
2Host: tag.baidubce.com
3Authorization: authorization string
4
5{
6 "tags": [
7 {
8 "tagKey": "key1",
9 "tagValue": "value1"
10 },
11 {
12 "tagKey": "key2",
13 "tagValue": "value2"
14 }
15 ]
16}
Response example
Plain Text
1cache-control: no-cache
2content-length: 0
3content-type: text/plain; charset=utf-8
4date: Mon, 09 Apr 2018 09:14:41 GMT
5server: BWS
6x-bce-request-id: 602b9cda-d803-433b-b902-c6f787ebb7fc
