Create a bucket
Use the InfluxDB user interface (UI), influx
command line interface (CLI), or InfluxDB HTTP API
to create a bucket.
By default, buckets have an implicit
schema-type and a schema that conforms to your data.
To require measurements to have specific columns and data types and prevent non-conforming write requests,
create a bucket with the explicit
schema-type.
- Create a bucket in the InfluxDB UI
- Create a bucket using the influx CLI
- Create a bucket using the InfluxDB HTTP API
- Create a bucket that enforces explicit schemas
Create a bucket in the InfluxDB UI
There are two places you can create a bucket in the UI.
Create a bucket from the Load Data menu
In the navigation menu on the left, select Load Data > Buckets.
Click Create Bucket in the upper right.
Enter a Name for the bucket.
Select when to Delete Data:
- Never to retain data forever.
- Older than to choose a specific retention period.
Click Create to create the bucket.
Create a bucket in the Data Explorer
In the navigation menu on the left, select *Explore (Data Explorer).
In the From panel in the Flux Builder, select
+ Create Bucket
.Enter a Name for the bucket.
Select when to Delete Data:
- Never to retain data forever.
- Older than to choose a specific retention period.
Click Create to create the bucket.
Create a bucket using the influx CLI
To create a bucket with the influx
CLI, use the influx bucket create
command
and specify values for the following flags:
Requirement | Include by |
---|---|
Organization | -o |
Bucket | -n |
Retention Period Duration | -r |
The following example creates a bucket with a retention period of seventy-two hours:
influx bucket create -n my-bucket -o {INFLUX_ORG} -r 72h
Create a bucket using the InfluxDB API
To create a bucket with the InfluxDB HTTP API, send a request to the following endpoint:
POST https://cloud2.influxdata.com/api/v2/buckets
In your request body, specify values for the following properties:
Requirement | Include by |
---|---|
Organization | orgID |
Bucket | name |
Retention Rules | retentionRules |
The following example creates a bucket with a retention period of 86,400
seconds, or twenty-four hours:
INFLUX_TOKEN=YOUR_API_TOKEN
INFLUX_ORG_ID=YOUR_ORG_ID
curl --request POST \
"http://localhost:8086/api/v2/buckets" \
--header "Authorization: Token ${INFLUX_TOKEN}" \
--header "Content-type: application/json" \
--data '{
"orgID": "'"${INFLUX_ORG_ID}"'",
"name": "iot-center",
"retentionRules": [
{
"type": "expire",
"everySeconds": 86400,
"shardGroupDurationSeconds": 0
}
]
}'
For information about InfluxDB API options and response codes, see InfluxDB API Buckets reference documentation.
Create a bucket that enforces explicit schemas
A bucket with the explicit
schema-type enforces measurement schemas that you define for the bucket and rejects writes that don’t conform to any of the schemas.
Use the influx
CLI or InfluxDB HTTP API to create a bucket with the explicit
schema-type.
Use the influx bucket create
command and specify the --schema-type=explicit
flag:
influx bucket create \
--name my_schema_bucket \
--schema-type explicit
Use the HTTP API /api/v2/buckets
endpoint and set the schemaType
property value to explicit
in the request body–for example:
POST https://cloud2.influxdata.com/api/v2/buckets
{
"orgID": "{INFLUX_ORG_ID}",
"name": "my-explicit-bucket",
"description": "My Explicit Bucket",
"rp": "string",
"retentionRules": [
{
"type": "expire",
"everySeconds": 86400,
"shardGroupDurationSeconds": 0
}
],
"schemaType": "explicit"
}
Next, see how to create an explicit bucket schema for a measurement.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.