Creating a Bucket
Functions
This operation creates a bucket with a specified name. The bucket name must be unique in OBS. For more information about creating a bucket, see Creating a Bucket.
Constraints
- Once a bucket is created, its name and region cannot be changed. Make sure that the bucket name and region you set are appropriate.
- An account (and all its IAM users) can create a maximum of 100 buckets. You are advised to use the fine-grained access control of OBS to properly plan and use buckets. For example, you can create folders in a bucket based on object prefixes and use fine-grained access control to isolate data between departments. There is no limit to the total number or size of objects in a bucket, so scalability is not a concern.
- OBS buckets are global resources, so each bucket name must be unique across all users, including your own.
To reuse the name of a deleted bucket for another bucket, you must wait until the bucket name is released. Deleting a bucket via API takes about 30 minutes. However, the process may take longer if the bucket is not empty, or if the account is in arrears or has been deregistered. OBS cannot guarantee immediate deletion. Therefore, if you attempt to create a new bucket using a name that has not been released, the creation will fail. Similarly, if the name is released but claimed by another user before you reuse it, the creation will also fail.
Authorization Information
- If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you need to grant the obs:bucket:CreateBucket permission. For details, see Creating a Custom IAM Policy.
- If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you need to grant the obs:bucket:createBucket permission, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.
Action
Access Level
Resource Type (*: Required)
Dependencies
obs:bucket:createBucket
Write
bucket *
-
-
-
-
- obs:EpochTime
- obs:SourceIp
- obs:TlsVersion
- obs:CustomDomain
- obs:BucketEncrypted
- obs:x-obs-acl
Request Syntax
The following is an example request. Replace BucketName with your bucket name and RegionID with the ID of the region where your bucket resides. You can obtain the region ID by referring to Supported Regions.
PUT / HTTP/1.1 Host: BucketName.obs.RegionID.myhuaweicloud.com Content-Length: BodyLength Date: GMT Date Authorization: SignatureValue x-obs-az-redundancy: 3az <CreateBucketConfiguration xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/"> <Location>RegionID</Location> </CreateBucketConfiguration>
URI Parameters
The request of this API contains no URI parameters.
Request Headers
The request of this API contains common request headers and additional request headers. Table 3 describes the common request headers. The following table describes the additional request headers.
|
Header |
Type |
Mandatory (Yes/No) |
Description |
|---|---|---|---|
|
x-obs-acl |
String |
No |
Definition When creating a bucket, you can use this parameter to set a predefined ACL. Constraints OBS allows you to use Service Control Policies (SCPs) to manage the behaviors of member accounts in your organization. Suppose your organization or organizational unit (OU) uses an SCP to limit the value range of x-obs-acl and the SCP specifies that x-obs-acl cannot be set to public-read or public-read-write during bucket or parallel file system creation. In this case, creation requests containing either of these two values will fail, with 403 returned. For more information about SCPs, see SCP Principles. Range
Default Value private |
|
x-obs-storage-class |
String |
No |
Definition When creating a bucket, you can add this header to set the default storage class for the bucket. Range
Default Value STANDARD |
|
x-obs-grant-read |
String |
No |
Definition Grants the read permission to all users in a specified domain. It allows you to list objects in a bucket, list multipart tasks in a bucket, list multi-version objects in a bucket, and obtain bucket metadata. Example: x-obs-grant-read:id=tenant-ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-grant-write |
String |
No |
Definition Grants the WRITE permission to all users in a specified domain to create, delete, and overwrite all objects in a bucket; and initiate multipart uploads, upload parts, copy parts, assemble parts, and cancel multipart uploads. Example: x-obs-grant-write:id=tenant-ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-grant-read-acp |
String |
No |
Definition Grant the READ_ACP permission to all users in a specified domain to allow them to read the bucket ACL. Example: x-obs-grant-read-acp:id=Account ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-grant-write-acp |
String |
No |
Definition Grants the WRITE_ACP permission to all users in a specified domain to allow them to modify the bucket ACL. Example: x-obs-grant-write-acp:id=Account ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-grant-full-control |
String |
No |
Definition Grants the FULL_CONTROL permission to all users in a specified domain. Example: x-obs-grant-full-control:id=tenant-ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-grant-read-delivered |
String |
No |
Definition Grants the READ permission to all users in a specified domain. By default, the read permission is granted on all objects in the bucket. Example: x-obs-grant-read-delivered:id=tenant-ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-grant-full-control-delivered |
String |
No |
Definition Grants the FULL_CONTROL permission to all users in a specified domain. By default, the FULL_CONTROL permission is granted on all objects in the bucket. Example: x-obs-grant-full-control-delivered:id=tenant-ID Constraints None Range id=tenant-ID. For details, see Obtaining Account, IAM User, Project, User Group, Region, and Agency Information. Default Value None |
|
x-obs-az-redundancy |
String |
No |
Definition When creating a bucket, you can use this header to set the data redundancy policy for the bucket. Constraints If a region does not support multi-AZ storage, even if this header is specified, the bucket is still single-AZ. Range
Default Value If this header is not specified, single AZ applies. |
|
x-obs-fs-file-interface |
String |
No |
Definition This header can be carried when you want to create a parallel file system. Example: x-obs-fs-file-interface:Enabled Range Enabled Default Value If the header is specified, the value must be Enabled. There is no default value. |
|
x-obs-epid |
String |
No |
Definition Enterprise project ID. Users who have enabled the enterprise project function can obtain this ID in UUID format from the enterprise project service. The default project ID is 0. This header can be not included. This header is not required for users who have not enabled the enterprise project function. Example: x-obs-epid:9892d768-2d13-450f-aac7-ed0e44c2585f Constraints None Range The value can be 0 or your actual enterprise project ID. Default Value 0 |
|
x-obs-bucket-type |
String |
No |
Definition You can add this header to specify what type of bucket you will create. You can choose to create a bucket or a parallel file system. Example: x-obs-bucket-type:OBJECT Constraints None Range
Default Value If the header is specified, the value must be manually entered. There is no default value. If the header is not specified, OBJECT is used by default. |
|
x-obs-bucket-object-lock-enabled |
String |
No |
Definition When creating a bucket, you can use this header to enable WORM for the bucket. Example: x-obs-bucket-object-lock-enabled:true Constraints
Range
Default Value If the header is specified, the value must be true or True. If the header is not specified, the object lock policy is disabled. |
|
x-obs-server-side-encryption |
String |
No |
Definition When creating a bucket, you can use this header to specify an encryption method for the bucket. Example: x-obs-server-side-encryption: kms Constraints None Range
Default Value If the header is specified, the value must be manually entered. There is no default value. If the header is not specified, bucket encryption is disabled. |
|
x-obs-server-side-data-encryption |
String |
No |
Definition When creating a bucket, you can use this header to specify an encryption algorithm for server-side encryption. Example: x-obs-server-side-data-encryption: AES256 Constraints None Range
Default Value None |
|
x-obs-server-side-encryption-kms-key-id |
String |
No if x-obs-server-side-encryption:kms is used. |
Definition ID of a specified key used for SSE-KMS encryption. For details about how to obtain a key ID, see Viewing a Key. Type: string Constraints This header can only be used when you specify kms for the x-obs-server-side-encryption header. Default Value If you specify kms for encryption but do not specify a key ID, the default master key will be used. If there is no default master key, OBS will create one and use it. |
|
x-obs-server-side-encryption-bucket-key-enabled |
String |
No |
Definition Whether to enable the SSE-KMS bucket key feature. Constraints If you set this header to true, you must also specify x-obs-server-side-encryption-kms-key-id to specify the key ID. Range
Default Value false |
|
x-obs-sse-kms-key-project-id |
String |
This parameter can be used only when x-obs-server-side-encryption-kms-key-id is included. |
Definition ID of the project (not an enterprise project) where the KMS CMK belongs when SSE-KMS is used Constraints None Range A project ID (not an enterprise project ID) that matches the key ID specified by x-obs-server-side-encryption-kms-key-id Default Value None |
Request Body
|
Element |
Type |
Mandatory (Yes/No) |
Description |
|---|---|---|---|
|
Location |
String |
No |
Definition Specifies the region where a bucket will be created.
Range For details about OBS regions and endpoints, see Regions and Endpoints. Default Value If obs.myhuaweicloud.com is used as the endpoint and no region is specified, cn-north-1 (the CN North-Beijing1 region) is used by default. |
Response Syntax
HTTP/1.1 status_code Location: /BucketName Date: GMT Date Content-Length: BodyLength
Response Headers
This response uses common headers. For details, see Table 1.
In addition to common response headers, this API may also return additional response headers, as shown in the following table.
|
Header |
Type |
Description |
|---|---|---|
|
Location |
String |
Definition The bucket address, which consists of a slash (/) and a bucket name. Example: /exampleBucket Range Bucket name |
|
x-obs-server-side-encryption |
String |
Definition The encryption method of the bucket. Example: x-obs-server-side-encryption: kms Range
|
|
x-obs-server-side-data-encryption |
String |
Definition The algorithm used for server-side encryption. Example: x-obs-server-side-data-encryption: AES256 Range
|
|
x-obs-server-side-encryption-kms-key-id |
String |
Definition If SSE-KMS encryption is used with a custom master key, the ID of the custom master key is returned. Range N/A |
|
x-obs-sse-kms-key-project-id |
String |
Definition If SSE-KMS encryption is used with a custom master key, the ID of the project (not enterprise project) to which the custom master key belongs is returned. Range ID of the project (not enterprise project) to which the custom master key specified by x-obs-server-side-encryption-kms-key-id belongs |
Response Body
The response of this API does not contain a response body.
Error Responses
No special error responses are returned. For details about error responses, see Table 2.
Sample Request: Creating a Bucket
1 2 3 4 5 6 7 8 9 10 11 |
PUT / HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 02:25:05 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw= Content-Length: 157 <CreateBucketConfiguration xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/"> <Location>region</Location> </CreateBucketConfiguration> |
Sample Response: Creating a Bucket
1 2 3 4 5 6 7 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF260000016435CE298386946AE4C482 Location: /examplebucket x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0 |
Sample Request: Creating a Bucket (with the ACL and Storage Class Specified)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
PUT / HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 02:25:05 GMT x-obs-acl:public-read x-obs-storage-class:STANDARD Authorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw= Content-Length: 157 <CreateBucketConfiguration xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/"> <Location>region</Location> </CreateBucketConfiguration> |
Sample Response: Creating a Bucket (with the ACL and Storage Class Specified)
1 2 3 4 5 6 7 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF260000016435CE298386946AE4C482 Location: /examplebucket x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0 |
Sample Request: Creating a Bucket with AZ Redundancy
1 2 3 4 5 6 7 8 9 |
PUT / HTTP/1.1 Host: examplebucket.obs.region.myhuaweicloud.com Content-Length: length Date: date Authorization: authorization x-obs-az-redundancy: 3az <CreateBucketConfiguration xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/"> <Location>region</Location> </CreateBucketConfiguration> |
Sample Response: Creating a Bucket with AZ Redundancy
1 2 3 4 5 6 7 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF260000016435CE298386946AE4C482 Location: /examplebucket x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0 |
Sample Request: Creating a Parallel File System
1 2 3 4 5 6 7 8 9 10 11 12 |
PUT / HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 02:25:05 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw= Content-Length: 157 x-obs-fs-file-interface: Enabled <CreateBucketConfiguration xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/"> <Location>region</Location> </CreateBucketConfiguration> |
Sample Response: Creating a Parallel File System
1 2 3 4 5 6 7 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF260000016435CE298386946AE4C482 Location: /examplebucket x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0 |
Sample Request: Creating a Bucket with WORM Enabled
PUT / HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 02:25:05 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw= x-obs-bucket-object-lock-enabled:true Content-Length: 0
Sample Response: Creating a Bucket with WORM Enabled
HTTP/1.1 200 OK Server: OBS x-obs-request-id: 00000184C11AC7A6809F881341842C02 x-reserved-indicator: Unauthorized Location: /examplebucket x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0
Sample Request: Creating a Bucket with SSE-KMS Configured
PUT / HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 02:25:05 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw= x-obs-server-side-encryption: kms x-obs-server-side-data-encryption: obs:kms Content-Length: 0
Sample Response: Creating a Bucket with SSE-KMS Configured
HTTP/1.1 200 OK Server: OBS x-obs-request-id: 0000018865CDACCA53062E5C2674A8FC x-reserved-indicator: Unauthorized Location: /examplebucket x-obs-server-side-encryption: kms x-obs-server-side-data-encryption: obs:kms x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0
Sample Request: Creating a Bucket with a Specific KMS Key for Server-Side Encryption
PUT / HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 02:25:05 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw= x-obs-server-side-encryption: kms x-obs-server-side-data-encryption: obs:kms x-obs-server-side-encryption-kms-key-id: 8r3u893k-fops-32m9-ba8e-9e4989b130ba x-obs-sse-kms-key-project-id: z2a619fc6s9e4062aca895fa612qd095 Content-Length: 0
Sample Response: Creating a Bucket with a Specific KMS Key for Server-Side Encryption
HTTP/1.1 200 OK Server: OBS x-obs-request-id: 0000018865CDACCA53062E5C2674A8FC x-reserved-indicator: Unauthorized Location: /examplebucket x-obs-server-side-encryption: kms x-obs-server-side-data-encryption: obs:kms x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUz Date: WED, 01 Jul 2015 02:25:06 GMT Content-Length: 0
Sample Request: Creating a Bucket with Explicitly Configured Access Permissions
PUT / HTTP/1.1
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4=
x-obs-grant-read: id=783fc6vz2cf2442c096evxxxxxxxxxxxx
x-obs-grant-write: id=3u3fc6vz2cf24mc830fhsxxxxxxxxxxxx
x-obs-grant-read-acp: id=902su2vz2cf2vire.239caxxxxxxxxxxxx
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml
<CreateBucketConfiguration xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/">
<Location>region</Location>
</CreateBucketConfiguration>
Sample Response: Creating a Bucket with Explicitly Configured Access Permissions
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTeau73DlKTh4wPYzoZf5w3KacolerP4 x-obs-request-id: 0000018A2A22B72447CF01A99F32E2B0 Server: OBS Content-Length: 0 Date: WED, 01 Jul 2015 02:37:22 GMT Location: /examplebucket
Using SDKs to Call APIs
You are advised to use OBS SDKs to call APIs. SDKs encapsulate APIs to simplify development. You can call SDK API functions to access OBS without manually calculating signatures.
References
- To use obsutil to create a bucket, see Creating a Bucket.
- To use OBS Browser+ to create can object, see Creating a Bucket.
- For more information about creating a bucket, see Creating a Bucket.
- For details about the billing items involved in API operations, see Billing Items.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot

