content/influxdb3/cloud-serverless/admin/buckets/create-bucket.md
Use the InfluxDB user interface (UI), influx command line interface (CLI), or InfluxDB HTTP API to create a bucket.
Bucket names must adhere to the following naming restrictions:
_)")Names must be unique within the organization. When you send a request such as writing or querying, {{% product-name %}} uses the bucket name and token in your request to find the bucket within the organization.
In {{< product-name >}}, table (measurement) and column are limited per bucket. Each measurement is represented by a table. Time, fields, and tags are each represented by a column.
Maximum number of tables: 500 Maximum number of columns: 200
InfluxDB can automatically create DBRP mappings and associated buckets for you during the following operations:
<!-- Invisible anchor for "Create a bucket" -->Create a bucket using the InfluxDB UI, influx CLI, or InfluxDB HTTP API.
{{< tabs-wrapper >}} {{% tabs %}} InfluxDB UI influx CLI InfluxDB API {{% /tabs %}} {{% tab-content %}}
<!------------------------------ BEGIN UI CONTENT ----------------------------->There are two places you can create a bucket in the UI.
{{< nav-icon "data" >}}
{{< nav-icon "data-explorer" >}}
+ Create Bucket.{{% /tab-content %}} {{% tab-content %}}
<!----------------------------- BEGIN CLI CONTENT ----------------------------->To create a bucket with the influx CLI, use the influx bucket create command
and specify values for the following flags:
-o, --org: Organization name-n, --name: Bucket name-r, --retention: Retention period durationThe following example creates a bucket with a retention period of 72 hours:
<!--test ```sh influx bucket delete \ --name BUCKET_NAME ``` --> <!--pytest-codeblocks:cont-->{{% code-placeholders "ORG|BUCKET_NAME|72h" %}}
influx bucket create \
--name BUCKET_NAME \
--retention 72h
{{% /code-placeholders %}}
Retention rules specify the bucket retention period, the duration that data is stored before it expires. The retention period also defines the minimum timestamp that you can write to the bucket; the bucket rejects data older than the retention period.
Use the --retention flag to specify a
retention period
for the bucket.
The retention period value is a time duration value made up of a numeric value
plus a duration unit.
For example, 30d means 30 days.
A zero duration (0d) retention period is infinite and data won't expire.
The retention period value cannot be negative or contain whitespace.
{{< flex >}} {{% flex-content %}}
{{% /flex-content %}} {{% flex-content %}}
0d: infinite/none3d: 3 days6w: 6 weeks1mo: 1 month (30 days)1y: 1 year30d30d: 60 days2.5d: 60 hours{{% /flex-content %}} {{< /flex >}}
<!------------------------------ END CLI CONTENT ------------------------------>{{% /tab-content %}} {{% tab-content %}}
<!----------------------------- BEGIN API CONTENT ----------------------------->To create a bucket with the InfluxDB HTTP API, send a request to the following endpoint:
{{< api-endpoint method="post" endpoint="https://{{< influxdb/host >}}/api/v2/buckets" api-ref="/influxdb3/cloud-serverless/api/#operation/PostBuckets" >}}
Include the following in your request:
Token scheme with your InfluxDB API tokenapplication/jsonThe following example creates a bucket with a retention period of 86,400 seconds, or 24 hours:
{{% code-placeholders "API_TOKEN|ORG_ID|86400" %}}
curl --silent -w "%{response_code}: %{errormsg}\n" \
-XPOST "https://{{< influxdb/host >}}/api/v2/buckets" \
--header "Authorization: Token API_TOKEN" \
--header "Content-type: application/json" \
--data @- << EOF
{
"orgID": "ORG_ID",
"name": "BUCKET_NAME",
"retentionRules": [
{
"type": "expire",
"everySeconds": 86400
}
]
}
EOF
{{% /code-placeholders %}}
Replace the following:
BUCKET_NAME{{% /code-placeholder-key %}}: the name of the bucket86400{{% /code-placeholder-key %}}: the number of seconds data is stored before it expires. Default is infinite--data won't expire.API_TOKEN{{% /code-placeholder-key %}}: a token with sufficient permissions to the specified bucketIf successful, the output is an HTTP 201: Created status code and the bucket; otherwise, an error status and message.
Retention rules specify the bucket retention period.
The retention period also defines the minimum timestamp that you can write to the bucket; the bucket rejects data older than the retention period.
The default retention period is infinite--data won't expire.
To specify the retention period, set the retentionRules.everySeconds property to the number of seconds.
A zero seconds (0) retention period is infinite.
The retention period value can't be negative or contain whitespace.
{
"orgID": "ORG_ID",
"name": "BUCKET_NAME",
"retentionRules": [
{
"type": "expire",
"everySeconds": "RETENTION_PERIOD_SECONDS"
}
]
}
For information about InfluxDB API options and response codes, see InfluxDB API Buckets reference documentation.
<!------------------------------ END API CONTENT ------------------------------>{{% /tab-content %}} {{< /tabs-wrapper >}}