Documentation

/write 1.x compatibility API

The /write 1.x compatibility endpoint writes data to InfluxDB Cloud and InfluxDB OSS Cloud 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 schemes:

  • 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 InfluxDB Cloud username to authenticate the request. See query string authentication.

p

(Optional) The InfluxDB Cloud API token 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 https://cloud2.influxdata.com/write?db=mydb \
  --user "exampleuser@influxdata.com:INFLUX_API_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:

  • exampleuser@influxdata.com: the email address that you signed up with
  • INFLUX_API_TOKEN: your InfluxDB API token

Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

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.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

InfluxDB Cloud powered by TSM