Documentation

Create a bucket

Use the InfluxDB user interface (UI), the influx command line interface (CLI), or the 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.

There are two places you can create a bucket in the UI.

Create a bucket from the Load Data menu

  1. In the navigation menu on the left, select Load Data > Buckets.
  1. Click Create Bucket in the upper right.
  2. Enter a Name for the bucket (see Bucket naming restrictions).
  3. Select when to Delete Data:
    • Never to retain data forever.
    • Older than to choose a specific retention period.
  4. Click Create to create the bucket.

Create a bucket in the Data Explorer

  1. In the navigation menu on the left, select *Explore (Data Explorer).
  1. In the From panel in the Flux Builder, select + Create Bucket.
  2. Enter a Name for the bucket (see Bucket naming restrictions).
  3. Select when to Delete Data:
    • Never to retain data forever.
    • Older than to choose a specific retention period.
  4. 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:

The following example creates a bucket with a retention period of 72 hours:

influx bucket create \
  --name my-bucket \
  --org {INFLUX_ORG} \
  --retention 72h
  • Copy
  • Fill window

To create a bucket with the InfluxDB HTTP API, send a request to the following endpoint:

Include the following in your request:

  • Headers:
    • Authorization: Token scheme with your InfluxDB API token
    • Content-type: application/json
  • Request body: JSON object with the following fields:
    * Required
    • * name: Bucket name
    • orgID: InfluxDB organization ID
    • description: Bucket description
    • * retentionRules: JSON array containing a single object with the following fields:
      • type: expire
      • everySecond: Number of seconds to retain data (0 means forever)
      • shardGroupDuration: Number of seconds to retain shard groups (0 means forever)

The following example creates a bucket with a retention period of 86,400 seconds, or 24 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
      }
    ]
  }'
  • Copy
  • Fill window

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
  • Copy
  • Fill window

Use the HTTP API /api/v2/buckets endpoint and set the schemaType property value to explicit in the request body–for example:

{
  "orgID": "{INFLUX_ORG_ID}",
  "name": "my-explicit-bucket",
  "description": "My Explicit Bucket",
  "rp": "string",
  "retentionRules": [
    {
      "type": "expire",
      "everySeconds": 86400,
      "shardGroupDurationSeconds": 0
    }
  ],
  "schemaType": "explicit"
}
  • Copy
  • Fill window

Next, see how to create an explicit bucket schema for a measurement.

Bucket naming restrictions

Bucket names must adhere to the following naming restrictions:

  • Must contain two or more characters
  • Cannot start with an underscore (_)
  • Cannot contain a double quote (")

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

Now Generally Available

InfluxDB 3 Core and Enterprise

Start fast. Scale faster.

Get the Updates

InfluxDB 3 Core is an open source, high-speed, recent-data engine that collects and processes data in real-time and persists it to local disk or object storage. InfluxDB 3 Enterprise builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries and optimized storage. A free tier of InfluxDB 3 Enterprise is available for non-commercial at-home or hobbyist use.

For more information, check out:

InfluxDB Cloud powered by TSM