> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nami.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Bucket

> Create a new S3 bucket

<Note>
  You need appropriate permissions to create buckets in your account.
</Note>

## Create Bucket

Creates a new bucket. By default, the bucket is created in the region specified in your configuration.

### Base URL

```bash theme={null}
https://${bucketname}.storage.nami.cloud
```

### Headers

<ParamField header="x-amz-acl" optional>
  The canned ACL to apply to the bucket
</ParamField>

<ParamField header="x-amz-bucket-object-lock-enabled" optional>
  Specifies whether object lock should be enabled for the bucket
</ParamField>

### Request Examples

<RequestExample>
  ```bash Bash theme={null}
  curl -X PUT "https://mybucket.storage.nami.cloud/" \
    -H "Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20231028/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-date, Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024" \
    -H "x-amz-acl: private"
  ```

  ```python Python theme={null}
  import boto3

  s3_client = boto3.client('s3',
      endpoint_url='https://storage.nami.cloud',
      aws_access_key_id='YOUR_ACCESS_KEY',
      aws_secret_access_key='YOUR_SECRET_KEY'
  )

  s3_client.create_bucket(
      Bucket='mybucket',
      ACL='private'
  )
  ```

  ```javascript Node.js theme={null}
  import { S3Client, CreateBucketCommand } from "@aws-sdk/client-s3";

  const client = new S3Client({
    endpoint: "https://storage.nami.cloud",
    credentials: {
      accessKeyId: "YOUR_ACCESS_KEY",
      secretAccessKey: "YOUR_SECRET_KEY",
    },
  });

  async function createBucket() {
    const command = new CreateBucketCommand({
      Bucket: "mybucket",
      ACL: "private"
    });

    try {
      const response = await client.send(command);
      console.log("Bucket created:", response);
    } catch (err) {
      console.error("Error:", err);
    }
  }

  createBucket();
  ```

  ```go Golang theme={null}
  package main

  import (
      "github.com/aws/aws-sdk-go/aws"
      "github.com/aws/aws-sdk-go/aws/credentials"
      "github.com/aws/aws-sdk-go/aws/session"
      "github.com/aws/aws-sdk-go/service/s3"
  )

  func main() {
      sess := session.Must(session.NewSession(&aws.Config{
          Endpoint:    aws.String("https://storage.nami.cloud"),
          Region:      aws.String("us-east-1"),
          Credentials: credentials.NewStaticCredentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", ""),
      }))

      s3Client := s3.New(sess)

      _, err := s3Client.CreateBucket(&s3.CreateBucketInput{
          Bucket: aws.String("mybucket"),
          ACL:    aws.String("private"),
      })
      if err != nil {
          panic(err)
      }
  }
  ```

  ```rust Rust theme={null}
  use aws_sdk_s3::{Client, Config};
  use aws_config::credentials::StaticCredentialsProvider;
  use aws_types::region::Region;
  use tokio;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let credentials = StaticCredentialsProvider::new(
          "YOUR_ACCESS_KEY".to_string(),
          "YOUR_SECRET_KEY".to_string(),
          None,
      );

      let config = Config::builder()
          .endpoint_url("https://storage.nami.cloud")
          .region(Region::new("us-east-1"))
          .credentials_provider(credentials)
          .build();

      let client = Client::from_conf(config);

      client
          .create_bucket()
          .bucket("mybucket")
          .acl(aws_sdk_s3::types::BucketCannedAcl::Private)
          .send()
          .await?;

      println!("Bucket created successfully!");
      Ok(())
  }
  ```
</RequestExample>

### Response Example

```json theme={null}
HTTP/1.1 200 OK
x-amz-id-2: YgIPIfBiKa2bj0KMgUAdQkf3ShJTOOpXUueF6QKo
x-amz-request-id: 236A8905248E5A01
Date: Wed, 28 Oct 2023 22:32:00 GMT
Location: /mybucket
Content-Length: 0
Server: Nami Cloud
```


## OpenAPI

````yaml PUT /
openapi: 3.0.1
info:
  title: Nami Cloud Storage API
  description: S3 compatible storage service API documentation
  version: 1.0.0
servers:
  - url: https://{bucketName}.storage.nami.cloud
    variables:
      bucketName:
        default: mybucket
        description: The name of the bucket
security:
  - awsV4: []
paths:
  /:
    put:
      tags:
        - Bucket Operations
      summary: Create Bucket
      description: Creates a new bucket
      parameters:
        - name: x-amz-acl
          in: header
          description: The canned ACL to apply to the bucket
          schema:
            type: string
            enum:
              - private
              - public-read
              - public-read-write
              - authenticated-read
      responses:
        '200':
          description: Bucket created successfully
        '400':
          description: Bad Request
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        Code:
          type: string
        Message:
          type: string
        RequestId:
          type: string
  securitySchemes:
    awsV4:
      type: apiKey
      name: Authorization
      in: header
      description: AWS Signature Version 4

````