---
title: "Create a bucket"
method: POST
path: "/api/v1/buckets"
tags: ["Buckets"]
---

# Create a bucket

`POST /api/v1/buckets`

## Request

- Base URL: `https://app.khotan.com`
- URL: `https://app.khotan.com/api/v1/buckets`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Provisions a Khotan-managed storage bucket synchronously and responds 201 with the persisted record whether setup ends ready or failed; branch on the returned status. A bucket is a private folder subtree in your organization's file storage, reached through the Files API with a scoped key. Supply an idempotencyKey to make retries safe — a retry carrying the same key returns the original bucket instead of creating a second one; without a key, every call creates a new bucket.

## Request body

- object
  - `name` string, required
  - `idempotencyKey` string

## Response `201`

The persisted bucket record, ready or failed.

- object
  - `id` string, required
  - `displayName` string, required
  - `status` 'creating' | 'ready' | 'failed', required
  - `provider` string, required
  - `accessMode` 'private' | 'public', required
  - `rootFolderId` string, nullable, required
  - `protected` boolean, required
  - `tags` string[], required
  - `createdAt` string, required
  - `updatedAt` string, required
  - `readyAt` string, nullable, required
  - `failedAt` string, nullable, required
  - `failureState` object, nullable, required
    - `code` 'provider_unavailable' | 'provider_rejected' | 'internal_error', required
    - `message` string, required

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Authentication is missing or invalid.
- `429`: Too many requests; retry after the indicated delay.

---

[API](https://skmtc.dev/khotan/apis/khotan-api.md) - [All operations](https://skmtc.dev/khotan/apis/khotan-api/llms.txt) - [OpenAPI document](https://skmtc.dev/khotan/apis/khotan-api/revisions/90b512a53e42?raw)
