Write data
/api/v2/write endpoint or the v1-compatible /write endpoint with line protocol./api/v2/writeWrite data using the InfluxDB v2 HTTP API
Writes data to a database.
Use this endpoint to send data in line protocol format to InfluxDB.
InfluxDB does the following when you send a write request:
- Validates the request
- If successful, attempts to ingest the data; error otherwise.
- If successful, responds with success (HTTP
204status code), acknowledging that the data is written and queryable; error otherwise.
To ensure that InfluxDB Cloud handles writes in the order you request them,
wait for a success response (HTTP 2xx status code) before you send the next request.
Parameters
Query parameters
org
required
stringIgnored. An organization name or ID.
InfluxDB ignores this parameter; authorizes the request using the specified database token and writes data to the specified cluster database.
orgID
stringIgnored. An organization ID.
InfluxDB ignores this parameter; authorizes the request using the specified database token and writes data to the specified cluster database.
bucket
required
stringprecision
stringHeader parameters
Zap-Trace-Span
stringContent-Encoding
stringContent-Encoding: gzip header.gzip
, identityidentityContent-Type
stringContent-Type: text/plain; charset=utf-8.text/plain
, text/plain; charset=utf-8text/plain; charset=utf-8Content-Length
integermax body configuration option,
the server responds with status code 413.Accept
stringThe content type that the client can understand. Writes only return a response body if they fail–for example, due to a formatting problem or quota limit.
- Returns only
application/jsonfor format and limit errors. - Returns only
text/htmlfor some quota limit errors.
application/jsonapplication/jsonRequest body required
In the request body, provide data in line protocol format.
To send compressed data, do the following:
- Use gzip to compress the line protocol data.
- In your request, send the compressed data and the
Content-Encoding: gzipheader.
application/jsoncurl --request POST \
"https://cluster-host.com/api/v2/write?org=ORG&bucket=BUCKET" \
--header "Authorization: Bearer INFLUX_TOKEN" \
--header "Content-Type: text/plain" \
--data-raw 'airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.48445310567793615 1630424257000000000'Responses
Bad request. The response body contains detail about the error.
InfluxDB returns this error if the line protocol data in the request is malformed or contains a database schema conflict. The response body contains the first malformed line in the data, and indicates what was expected.
code
required
stringinternal error
, not found
, conflict
, invalid
, empty value
, unavailableerr
stringline
integer <int32>message
stringop
stringUnauthorized. The error may indicate one of the following:
- The
Authorization: Tokenheader is missing or malformed. - The API token value is missing from the header.
- The token doesn’t have sufficient permissions to write to or query the database.
code
stringunauthorized.unauthorizedmessage
stringNot found. A requested resource was not found. The response body contains the requested resource type and the name value (if you passed it)–for example:
"organization name \"my-org\" not found""organization not found": indicates you passed an ID that did not match an organization.
code
required
stringinternal error
, not implemented
, not found
, conflict
, invalid
, unprocessable entity
, empty value
, unavailable
, forbidden
, too many requests
, unauthorized
, method not allowed
, request too large
, unsupported media typeerr
stringmessage
stringop
stringThe request payload is too large. InfluxDB rejected the batch and did not write any data.
InfluxDB returns this error if the payload exceeds the size limit.
code
required
stringinvalidmessage
required
stringToo many requests.
- Returns this error if ingesters are resource constrained.
code
required
stringinternal error
, not implemented
, not found
, conflict
, invalid
, unprocessable entity
, empty value
, unavailable
, forbidden
, too many requests
, unauthorized
, method not allowed
, request too large
, unsupported media typeerr
stringmessage
stringop
stringService unavailable.
- Returns this error if the server is temporarily unavailable to accept writes due to concurrent request limits or insufficient healthy ingesters.
code
required
stringinternal error
, not implemented
, not found
, conflict
, invalid
, unprocessable entity
, empty value
, unavailable
, forbidden
, too many requests
, unauthorized
, method not allowed
, request too large
, unsupported media typeerr
stringmessage
stringop
string/writeWrite data using the InfluxDB v1 HTTP API
Writes data to a database.
Use this InfluxDB v1-compatible endpoint to send data in line protocol format to InfluxDB using v1 API parameters and authorization.
InfluxDB does the following when you send a write request:
- Validates the request
- If successful, attempts to ingest the data; error otherwise.
- If successful, responds with success (HTTP
204status code), acknowledging that the data is written and queryable; error otherwise.
To ensure that InfluxDB handles writes in the order you request them,
wait for a success response (HTTP 2xx status code) before you send the next request.
Parameters
Query parameters
u
stringp
stringdb
required
stringrp
stringprecision
stringHeader parameters
Zap-Trace-Span
stringContent-Encoding
stringgzip
, identityidentityRequest body required
application/jsoncurl --request POST \
"https://cluster-host.com/write?db=DB" \
--header "Authorization: Bearer INFLUX_TOKEN" \
--header "Content-Type: text/plain" \
--data-raw 'measurement,tag=value field=1.0'Responses
code
required
stringinternal error
, not found
, conflict
, invalid
, empty value
, unavailableerr
stringline
integer <int32>message
stringop
stringcode
required
stringinternal error
, not implemented
, not found
, conflict
, invalid
, unprocessable entity
, empty value
, unavailable
, forbidden
, too many requests
, unauthorized
, method not allowed
, request too large
, unsupported media typeerr
stringmessage
stringop
stringcode
required
stringinternal error
, not implemented
, not found
, conflict
, invalid
, unprocessable entity
, empty value
, unavailable
, forbidden
, too many requests
, unauthorized
, method not allowed
, request too large
, unsupported media typeerr
stringmessage
stringop
stringcode
required
stringinvalidmessage
required
stringcode
required
stringinternal error
, not implemented
, not found
, conflict
, invalid
, unprocessable entity
, empty value
, unavailable
, forbidden
, too many requests
, unauthorized
, method not allowed
, request too large
, unsupported media typeerr
stringmessage
stringop
stringWas 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 Clustered and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.