Documentation

/write 1.x compatibility API

This page documents an earlier version of InfluxDB. InfluxDB v2.6 is the latest stable version. View this page in the v2.6 documentation.

The /write 1.x compatibility endpoint writes data to InfluxDB Cloud and InfluxDB OSS 2.2 using patterns from the InfluxDB 1.x /write API endpoint. Use the POST request method to write line protocol to the /write endpoint.

POST http://localhost:8086/write

If you have an existing bucket that doesn’t follow the database/retention-policy naming convention, you must manually create a database and retention policy mapping to write data to that bucket with the /write compatibility API.

Authentication

Use one of the following authentication methods:

  • token authentication
  • basic authentication with username and password
  • query string authentication with username and password

For more information, see Authentication.

Request body

Include your line protocol in the request body. Binary encode the line protocol to prevent unintended formatting. The examples below use the curl --data-binary flag to binary encode the line protocol.

Query string parameters

u

(Optional) The 1.x username to authenticate the request. See query string authentication.

p

(Optional) The 1.x password to authenticate the request. See query string authentication.

db

(Required) The database to write data to. This is mapped to an InfluxDB bucket. See Database and retention policy mapping.

rp

The retention policy to write data to. This is mapped to an InfluxDB bucket. See Database and retention policy mapping.

precision

The precision of Unix timestamps in the line protocol. Default is nanosconds (ns). The following precisions are available:

  • ns - nanoseconds
  • u or µ - microseconds
  • ms - milliseconds
  • s - seconds
  • m - minutes
  • h - hours

Write examples

Write data using basic authentication
curl --request POST http://localhost:8086/write?db=mydb \
  --user "INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN" \
  --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
Write data using token authentication
curl --request POST http://localhost:8086/write?db=mydb \
  --header "Authorization: Token INFLUX_API_TOKEN" \
  --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
Write data to a non-default retention policy
curl --request POST http://localhost:8086/write?db=mydb&rp=customrp \
  --header "Authorization: Token INFLUX_API_TOKEN" \
  --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
Write multiple lines of line protocol
curl --request POST http://localhost:8086/write?db=mydb \
  --header "Authorization: Token INFLUX_API_TOKEN" \
  --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000
measurement,host=host2 field1=14i,field2=12.7 1577836800000000000
measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
Write data with millisecond Unix timestamps
curl --request POST http://localhost:8086/write?db=mydb&precision=ms \
  --header "Authorization: Token INFLUX_API_TOKEN" \
  --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000"
Use curl to write data from a file
curl --request POST http://localhost:8086/write?db=mydb \
  --header "Authorization: Token INFLUX_API_TOKEN" \
  --data-binary @path/to/line-protocol.txt

Replace the following:


Was this page helpful?

Thank you for your feedback!


Set your InfluxDB URL

Linux Package Signing Key Rotation

All signed InfluxData Linux packages have been resigned with an updated key. If using Linux, you may need to update your package configuration to continue to download and verify InfluxData software packages.

For more information, see the Linux Package Signing Key Rotation blog post.

InfluxDB Cloud backed by InfluxDB IOx

All InfluxDB Cloud organizations created on or after January 31, 2023 are backed by the new InfluxDB IOx storage engine. Check the right column of your InfluxDB Cloud organization homepage to see which InfluxDB storage engine you’re using.

If powered by IOx, this is the correct documentation.

If powered by TSM, see the TSM-based InfluxDB Cloud documentation.

InfluxDB Cloud backed by InfluxDB TSM

All InfluxDB Cloud organizations created on or after January 31, 2023 are backed by the new InfluxDB IOx storage engine which enables nearly unlimited series cardinality and SQL query support. Check the right column of your InfluxDB Cloud organization homepage to see which InfluxDB storage engine you’re using.

If powered by TSM, this is the correct documentation.

If powered by IOx, see the IOx-based InfluxDB Cloud documentation.

State of the InfluxDB Cloud (IOx) documentation

The new documentation for InfluxDB Cloud backed by InfluxDB IOx is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.