# post\_\_bucket

`POST /bucket`

*Create Bucket*

Create a new storage bucket for cloud storage management.

This endpoint allows you to configure storage buckets from various cloud providers. The system supports:

* **AWS S3**: Amazon Web Services Simple Storage Service
* **GCS**: Google Cloud Storage
* **Azure**: Microsoft Azure Blob Storage
* **S3-Compatible**: Services like StorJ, Akave, and other S3-compatible providers

**Supported Providers:**

* `S3`: AWS S3 and S3-compatible services
* `GCS`: Google Cloud Storage
* `AZURE`: Azure Blob Storage

**Validation:**

* Bucket name must be unique within your organization
* Storage credentials are validated before creation
* Quota limits are checked (organization bucket limit)

**Security:**

* Access keys and secrets are encrypted before storage
* Credentials are never returned in API responses

**Quota Limits:**

* Maximum buckets per organization based on subscription
* Free trial typically includes 10 buckets
* Quota exceeded returns 429 status code

#### TypeScript Client Library

```typescript
public createStorageBucket = async (data: CreateBucketRequest): Promise<CreateBucketResponse> => {
  return this.makeRequest<CreateBucketResponse>('bucket', 'POST', data);
};
```

#### Code Samples

{% tabs %}
{% tab title="Shell" %}

```shell
# You can also use wget
curl -X POST https://backend.flashback.tech/bucket \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST https://backend.flashback.tech/bucket HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Accept: application/json
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const inputBody = '{
  "name": "My Backup Bucket",
  "bucket": "my-backup-bucket-2024",
  "storageType": "S3",
  "key": "AKIAIOSFODNN7EXAMPLE",
  "secret": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
  "region": "us-east-1",
  "endpoint": "https://gateway.storjshare.io"
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

fetch('https://backend.flashback.tech/bucket',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

result = RestClient.post 'https://backend.flashback.tech/bucket',
  params: {
  }, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

r = requests.post('https://backend.flashback.tech/bucket', headers = headers)

print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$headers = array(
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
    $response = $client->request('POST','https://backend.flashback.tech/bucket', array(
        'headers' => $headers,
        'json' => $request_body,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

 // ...
```

{% endtab %}

{% tab title="Java" %}

```java
URL obj = new URL("https://backend.flashback.tech/bucket");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "https://backend.flashback.tech/bucket", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Body parameter

```json
{
  "name": "My Backup Bucket",
  "bucket": "my-backup-bucket-2024",
  "storageType": "S3",
  "key": "AKIAIOSFODNN7EXAMPLE",
  "secret": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
  "region": "us-east-1",
  "endpoint": "https://gateway.storjshare.io",
  "workspaceId": "workspace-123"
}
```

#### Parameters <a href="#post__bucket-parameters" id="post__bucket-parameters"></a>

| Name          | In   | Type   | Required | Description                                    |
| ------------- | ---- | ------ | -------- | ---------------------------------------------- |
| body          | body | object | true     | none                                           |
| » name        | body | string | true     | Human-readable name for the bucket             |
| » bucket      | body | string | true     | Actual bucket name in cloud storage            |
| » storageType | body | string | true     | Cloud storage provider type                    |
| » key         | body | string | true     | Access key for the storage provider            |
| » secret      | body | string | true     | Secret key for the storage provider            |
| » region      | body | string | true     | Storage region (e.g., us-east-1, eu-west-1)    |
| » endpoint    | body | string | false    | Custom endpoint URL for S3-compatible services |
| » workspaceId | body | string | true     | Workspace ID the bucket belongs to             |

**Enumerated Values**

| Parameter     | Value |
| ------------- | ----- |
| » storageType | S3    |
| » storageType | GCS   |
| » storageType | AZURE |

> Example responses

> 200 Response

```json
{
  "success": true,
  "bucketId": "550e8400-e29b-41d4-a716-446655440000"
}
```

#### Responses <a href="#post__bucket-responses" id="post__bucket-responses"></a>

| Status | Meaning                                                            | Description                 | Schema |
| ------ | ------------------------------------------------------------------ | --------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)            | Bucket created successfully | Inline |
| 400    | [Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)   | Validation error            | Inline |
| 429    | [Too Many Requests](https://tools.ietf.org/html/rfc6585#section-4) | Quota exceeded              | Inline |

#### Response Schema <a href="#post__bucket-responseschema" id="post__bucket-responseschema"></a>

Status Code **200**

| Name       | Type    | Required | Restrictions | Description                              |
| ---------- | ------- | -------- | ------------ | ---------------------------------------- |
| » success  | boolean | false    | none         | none                                     |
| » bucketId | string  | false    | none         | Unique identifier for the created bucket |

Status Code **400**

| Name      | Type    | Required | Restrictions | Description |
| --------- | ------- | -------- | ------------ | ----------- |
| » success | boolean | false    | none         | none        |
| » message | string  | false    | none         | none        |

Status Code **429**

| Name       | Type    | Required | Restrictions | Description |
| ---------- | ------- | -------- | ------------ | ----------- |
| » success  | boolean | false    | none         | none        |
| » bucketId | string  | false    | none         | none        |


---

# 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.flashback.tech/support-reference/platform-api-reference/storage-apis/bucket-management/post__bucket.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.
