A bucket is a container for storing objects in Object Storage Service (OSS). All objects in OSS are stored in buckets.
Usage notes
The examples in this topic use the public endpoint for the China (Hangzhou) region. To access OSS from other Alibaba Cloud services in the same region, use an internal endpoint instead. For supported regions and endpoints, see Regions and endpoints.
Starting October 13, 2025, at 10:00 (UTC+8), OSS is rolling out Block Public Access by default for all new buckets created through the API, SDKs, and ossutil. For the rollout schedule by region, see the Notice. When this feature is active, you cannot grant public access through access control list (ACL) settings (such as public-read or public-read-write) or bucket policies. If your use case requires public access, disable Block Public Access after creating the bucket.
Permissions
By default, an Alibaba Cloud account has full permissions. RAM users and RAM roles have no permissions by default and must be granted access through RAM policies or bucket policies.
| API | Action | Description |
|---|---|---|
| PutBucket | oss:PutBucket | Creates a bucket. |
| PutBucket | oss:PutBucketAcl | Modifies the bucket ACL after creation. |
Sample code
The following example creates a bucket named examplebucket:
const OSS = require('ali-oss');
const client = new OSS({
// Specify the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the region to oss-cn-hangzhou.
region: 'yourregion',
// Load credentials from environment variables.
// Set OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET before running this code.
accessKeyId: process.env.OSS_ACCESS_KEY_ID,
accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
authorizationV4: true,
// Specify the name of the bucket.
bucket: 'yourBucketName',
});
async function putBucket() {
try {
const options = {
// Storage class: Standard (default), Archive
storageClass: 'Standard',
// ACL: private (default), public-read, public-read-write
acl: 'private',
// Data redundancy type: LRS (locally redundant storage, default), ZRS (zone-redundant storage)
dataRedundancyType: 'LRS',
};
const result = await client.putBucket('examplebucket', options);
console.log(result);
} catch (err) {
console.log(err);
}
}
putBucket();References
For API details, see PutBucket.