Write data

Write time series data to InfluxDB 3 Cloud Serverless buckets using the v2-compatible /api/v2/write endpoint or the v1-compatible /write endpoint with line protocol.
POST /api/v2/write

Write data using the InfluxDB v2 HTTP API

Writes data to a bucket.

Use this endpoint to send data in line protocol format to InfluxDB.

InfluxDB 3 Cloud Serverless does the following when you send a write request:

  1. Validates the request.
  2. If successful, attempts to ingest data from the request body; otherwise, responds with an error status.
  3. Ingests or rejects data in the batch and returns one of the following HTTP status codes:
  • 204 No Content: All data in the batch is ingested.
  • 400 Bad Request: Data from the batch was rejected and not written. The response body indicates if a partial write occurred.

The response body contains error details about rejected points, up to 100 points.

Writes are synchronous–the response status indicates the final status of the write and all ingested data is queryable.

To ensure that InfluxDB handles writes in the order you request them, wait for the response before you send the next request.

Write endpoints

The /write and /api/v2/write endpoints are functionally equivalent for writing data to InfluxDB Cloud Serverless.

Rate limits

Write rate limits apply. For more information, see limits and adjustable quotas.

Parameters

Query parameters
org required string

An organization name or ID.

InfluxDB 3 Cloud Serverless writes data to the bucket in the organization associated with the authorization (API token); doesn’t use the org parameter or orgID parameter.

orgID string

An organization ID.

InfluxDB 3 Cloud Serverless writes data to the bucket in the organization associated with the authorization (API token); doesn’t use the org parameter or orgID parameter.

bucket required string
A bucket name or ID. InfluxDB writes all points in the batch to the specified bucket.
precision string
The precision for unix timestamps in the line protocol batch.
Header parameters
Zap-Trace-Span string
OpenTracing span context
Content-Encoding string
The compression applied to the line protocol in the request payload. To send a gzip payload, pass Content-Encoding: gzip header.
Allowed values: gzip , identity
Default: identity
Content-Type string
The format of the data in the request body. To send a line protocol payload, pass Content-Type: text/plain; charset=utf-8.
Allowed values: text/plain , text/plain; charset=utf-8
Default: text/plain; charset=utf-8
Content-Length integer
The size of the entity-body, in bytes, sent to InfluxDB. If the length is greater than the max body configuration option, the server responds with status code 413.
Accept string

The 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 3 Cloud Serverless

  • Returns only application/json for format and limit errors.
  • Returns only text/html for some quota limit errors.
Allowed values: application/json
Default: application/json

Request body required

In the request body, provide data in line protocol format.

To send compressed data, do the following:

  1. Use gzip to compress the line protocol data.
  2. In your request, send the compressed data and the Content-Encoding: gzip header.
Content-Type: application/json
Example request Ask AI about this
curl --request POST \
  "https://us-east-1-1.aws.cloud2.influxdata.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

204 Success (“No Content”). All data in the batch is written and queryable.
400

Data from the batch was rejected and not written. The response body indicates if a partial write occurred or all data was rejected. If a partial write occurred, then some points from the batch are written and queryable.

The response body contains details about the rejected points, up to 100 points.

code required string
Code is the machine-readable error code.
Allowed: internal error , not found , conflict , invalid , empty value , unavailable
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
line integer <int32>
First line in the request body that contains malformed data.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
401

Unauthorized. The error may indicate one of the following:

  • The Authorization: Token header 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 string
The HTTP status code description. Default is unauthorized.
Allowed: unauthorized
message string
A human-readable message that may contain detail about the error.
404

Not 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 string
code is the machine-readable error code.
Allowed: internal 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 type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
413

The request payload is too large. InfluxDB rejected the batch and did not write any data.

InfluxDB returns this error if the payload exceeds the 50MB size limit or all data is outside the retention window.

code required string
Code is the machine-readable error code.
Allowed: invalid
message required string
Human-readable message.
429

Too 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-After header that describes when to try the write again.
  • For limits that can’t reset (for example, cardinality limit), doesn’t return a Retry-After header.

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.

500 Internal server error. The server encountered an unexpected situation.
code required string
code is the machine-readable error code.
Allowed: internal 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 type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
503

Service unavailable.

  • Returns this error if the server is temporarily unavailable to accept writes.
  • Returns a Retry-After header that describes when to try the write again.
default Non 2XX error response from server.
code required string
code is the machine-readable error code.
Allowed: internal 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 type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
POST /write

Write data using the InfluxDB v1 HTTP API

Writes data to a bucket.

Use this endpoint for InfluxDB v1 parameter compatibility when sending data in line protocol format to InfluxDB.

InfluxDB 3 Cloud Serverless does the following when you send a write request:

  1. Validates the request.
  2. If successful, attempts to ingest data from the request body; otherwise, responds with an error status.
  3. Ingests or rejects data in the batch and returns one of the following HTTP status codes:
  • 204 No Content: all data in the batch is ingested
  • 201 Created: some points in the batch are ingested and queryable, and some points are rejected
  • 400 Bad Request: all data is rejected

The response body contains error details about rejected points, up to 100 points.

Writes are synchronous–the response status indicates the final status of the write and all ingested data is queryable.

To ensure that InfluxDB handles writes in the order you request them, wait for the response before you send the next request.

Write endpoints

The /write and /api/v2/write endpoints are functionally equivalent for writing data to InfluxDB Cloud Serverless.

Rate limits

Write rate limits apply. For more information, see limits and adjustable quotas.

Parameters

Query parameters
u string
The InfluxDB 1.x username to authenticate the request.
p string
The InfluxDB 1.x password to authenticate the request.
db required string
Bucket to write to. If none exists, InfluxDB creates a bucket with a default 3-day retention policy.
rp string
Retention policy name.
precision string
Write precision.
Header parameters
Zap-Trace-Span string
OpenTracing span context
Content-Encoding string
When present, indicates that compression is applied to the line protocol body.
Allowed values: gzip , identity
Default: identity

Request body required

Line protocol body
Content-Type: application/json
Example request Ask AI about this
curl --request POST \
  "https://us-east-1-1.aws.cloud2.influxdata.com/write?db=DB" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: text/plain" \
  --data-raw 'measurement,tag=value field=1.0'

Responses

201 Success (“Created”). Some points in the batch are written and queryable, and some points are rejected. The response body contains details about the rejected points, up to 100 points.
code required string
Code is the machine-readable error code.
Allowed: internal error , not found , conflict , invalid , empty value , unavailable
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
line integer <int32>
First line in the request body that contains malformed data.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
204 Success (“No Content”). All data in the batch is written and queryable.
400

All data in the batch is rejected and not written.

The response body contains details about the rejected points.

code required string
Code is the machine-readable error code.
Allowed: internal error , not found , conflict , invalid , empty value , unavailable
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
line integer <int32>
First line in the request body that contains malformed data.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
401 Token doesn’t have sufficient permissions to write to this organization and bucket or the organization and bucket do not exist.
code required string
code is the machine-readable error code.
Allowed: internal 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 type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
403 No token was sent and they are required.
code required string
code is the machine-readable error code.
Allowed: internal 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 type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
413 Write has been rejected because the payload is too large. Error message returns max size supported. All data in body was rejected and not written.
code required string
Code is the machine-readable error code.
Allowed: invalid
message required string
Human-readable message.
429 Token is temporarily over quota. The Retry-After header describes when to try the write again.
503 Server is temporarily unavailable to accept writes. The Retry-After header describes when to try the write again.
default Internal server error
code required string
code is the machine-readable error code.
Allowed: internal 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 type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.

Was this page helpful?

Thank you for your feedback!