Updated on 2026-04-16 GMT+08:00

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

The account root user has the permissions to call all APIs, but other IAM users under the account must have the permission to create buckets before calling this API. You are advised to use IAM for authorization. You can use either role/policy-based authorization or identity policy-based authorization and configure the required permission:
  • 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)

    Condition Key

    Alias

    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.

Table 1 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

  • private: A bucket or an object can be accessed only by its owner.
  • public-read: If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata.
  • public-read-write: If this permission is granted on a bucket, anyone can obtain the object list, multipart tasks, and metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and cancel multipart upload tasks.
  • public-read-delivered: If this permission is set for a bucket, everyone can obtain the object list, multipart uploads, and bucket metadata in the bucket, and obtain the content and metadata of the objects in the bucket.
  • public-read-write-delivered: If this permission is set for a bucket, everyone can obtain the object list in the bucket, multipart uploads in the bucket, and metadata of the bucket; upload and delete objects; initiate multipart uploads; upload, assemble, and copy parts; cancel multipart uploads; and obtain content and metadata of objects in the bucket.
  • bucket-owner-full-control: If this permission is granted on an object, only the bucket and object owners have the full control over the object.

    By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

    For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets the bucket-owner-full-control policy for object x, user B then has the control over object x.

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

  • STANDARD: The Standard storage class, which features low access latency and high throughput. It is applicable to store a large number of frequently accessed hot files. The application scenarios include big data, mobile applications, hots videos, and social media images.
  • Warm: The Infrequent Access storage class, which is suitable for storing data that is infrequently accessed (less than 12 times a year) yet has quick response requirements. Potential application scenarios include file synchronization or sharing and enterprise backup.
  • COLD: The Archive storage class, which is ideal for storing data that is rarely accessed (once a year on average). Its application scenarios include data archive and long-term backups. This storage class is secure, durable, and inexpensive. It can be used to replace tape libraries.
  • DEEP_ARCHIVE: The Deep Archive storage class, which is ideal for storing data that is hardly ever accessed (once every few years). This storage class costs even less than the Archive storage class, but it also takes longer time (usually several hours) to restore data.

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

  • 3az: multi-AZ, which provides higher reliability

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

  • OBJECT: a bucket
  • POSIX: a parallel file system.

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

  • Buckets are supported. Parallel file systems are not supported.
  • When you create a bucket with WORM enabled, OBS automatically enables versioning for the bucket and the versioning cannot be suspended for that bucket.

Range

  • true: WORM is enabled.

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

  • kms: SSE-KMS is used for encryption.
  • obs: SSE-OBS is used for encryption.

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

  • AES256: The AES256 algorithm is used. AES256 can be configured for both SSE-KMS and SSE-OBS.

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

  • true: The bucket key is enabled.
  • false: The bucket key is disabled.

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

Table 2 Request body parameters

Element

Type

Mandatory (Yes/No)

Description

Location

String

No

Definition

Specifies the region where a bucket will be created.

  • When the endpoint of the CN North-Beijing1 region is used for bucket creation:
    • if location is not included, the bucket will be created in CN North-Beijing1 (cn-north-1) by default.
    • if another region, for example, CN-Hong Kong (ap-southeast-1), is specified for location, the bucket will be created in the CN-Hong Kong region.
  • When the endpoint of a region other than CN North-Beijing1 is used for bucket creation, location must be set to the region that the used endpoint corresponds to.

    For example, if obs.ap-southeast-1.myhuaweicloud.com is used, you must set location to ap-southeast-1.

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.

Table 3 Additional response headers

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

  • kms: SSE-KMS is used for encryption.
  • obs: SSE-OBS is used for encryption.

x-obs-server-side-data-encryption

String

Definition

The algorithm used for server-side encryption. Example: x-obs-server-side-data-encryption: AES256

Range

  • AES256: The AES256 algorithm is used. AES256 can be configured for both SSE-KMS and SSE-OBS.

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.

Java

Python

C

Go

BrowserJS: not supported

.NET

Android

iOS

PHP

Node.js

References