# 2.Create and Manage Buckets

A bucket in MCS is a logical container for storing files and folders.

### 2.1 Create a new bucket

Use the `create_bucket` method to create a new bucket:

```python
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

bucket_client.create_bucket("<BUCKET_NAME>")
```

### 2.2 List existing buckets

List all existing buckets using `list_buckets`:

```python
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

for i in bucket_client.list_buckets():
    print(i.to_json())
```

### 2.3 Get bucket information

Use `get_bucket(bucket_name)`to get specific bucket info

```
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

print(bucket_client.get_bucket("<BUCKET_NAME>").to_json())
```

### 2.4 Create folder

`create_folder(bucket_name, folder_name, prefix='')`

The `create_folder` the method allows you to create a folder in the specified bucket. It accepts bucket names, folder names, and prefixes. The folder will be created in `bucket_name/prefix/folder_name`

```python
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

# If you want to place the folder directly in the root directory, you can leave the prefix field empty
bucket_client.create_folder("<BUCKET_NAME>","<FOLDER_NAME>","<PREFIX>")
```

**Parameters**

* **bucket\_name**: The name of the bucket
* **folder\_name:** The name of the folder to create
* **prefix:** The prefix for the folder's object name


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swanchain.io/bulders/app-developer/store-and-retrieve-a-file-with-swan-storage/2.create-and-manage-buckets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
