Write data
/api/v2/write endpoint./api/v2/writeWrite data
Writes data to a bucket.
Use this endpoint to send data in line protocol format to InfluxDB.
InfluxDB Cloud
Does the following when you send a write request:
- Validates the request and queues the write.
- If queued, responds with success (HTTP
2xxstatus code); error otherwise. - Handles the delete asynchronously and reaches eventual consistency.
To ensure that InfluxDB Cloud handles writes and deletes in the order you request them, wait for a success response (HTTP
2xxstatus code) before you send the next request.Because writes and deletes are asynchronous, your change might not yet be readable when you receive the response.
InfluxDB OSS v2
- Validates the request and handles the write synchronously.
- If all points were written successfully, responds with HTTP
2xxstatus code; otherwise, returns the first line that failed.
Required permissions
write-bucketsorwrite-bucket BUCKET_ID.
BUCKET_ID is the ID of the destination bucket.
Rate limits (with InfluxDB Cloud)
write rate limits apply.
For more information, see limits and adjustable quotas.
Related guides
Parameters
Query parameters
org
required
stringAn organization name or ID.
InfluxDB Cloud
- Doesn’t use the
orgparameter ororgIDparameter. - Writes data to the bucket in the organization associated with the authorization (API token).
InfluxDB OSS v2
- Requires either the
orgparameter or theorgIDparameter. - If you pass both
orgIDandorg, they must both be valid. - Writes data to the bucket in the specified organization.
orgID
stringAn organization ID.
InfluxDB Cloud
- Doesn’t use the
orgparameter ororgIDparameter. - Writes data to the bucket in the organization associated with the authorization (API token).
InfluxDB OSS v2
- Requires either the
orgparameter or theorgIDparameter. - If you pass both
orgIDandorg, they must both be valid. - Writes data to the bucket in the specified organization.
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.
InfluxDB Cloud
- Returns only
application/jsonfor format and limit errors. - Returns only
text/htmlfor some quota limit errors.
InfluxDB OSS v2
- Returns only
application/jsonfor format and limit errors.
Related guides
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.
Related guides
application/jsoncurl --request POST \
"http://localhost:8086/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
Success.
InfluxDB Cloud
- Validated and queued the request.
- Handles the write asynchronously - the write might not have completed yet.
InfluxDB OSS v2
- Successfully wrote all points in the batch.
Related guides
Bad request. The response body contains detail about the error.
InfluxDB returns this error if the line protocol data in the request is malformed. The response body contains the first malformed line in the data, and indicates what was expected.
InfluxDB Cloud
- Returns this error for bucket schema conflicts.
InfluxDB OSS v2
- Returns this error if the
orgparameter ororgIDparameter doesn’t match an organization.
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 this organization and bucket.
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 Cloud:
- Returns this error if the payload exceeds the 50MB size limit.
- Returns
Content-Type: text/htmlfor this error.
InfluxDB OSS v2:
- Returns this error only if the Go (golang)
ioutil.ReadAll()function raises an error. - Returns
Content-Type: application/jsonfor this error.
code
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
stringToo many requests.
InfluxDB Cloud
- Returns this error if a read or write request exceeds your plan’s adjustable service quotas or if a delete request exceeds the maximum global limit.
- For rate limits that reset automatically, returns a
Retry-Afterheader that describes when to try the write again. - For limits that can’t reset (for example, cardinality limit), doesn’t return a
Retry-Afterheader.
Rates (data-in (writes), queries (reads), and deletes) accrue within a fixed five-minute window. Once a rate limit is exceeded, InfluxDB returns an error response until the current five-minute window resets.
InfluxDB OSS v2
- Doesn’t return this error.
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.
- Returns a
Retry-Afterheader that describes when to try the write again.
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
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 and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.