---
title: Write data
description: Write time series data to InfluxDB 3 Clustered databases using the v2-compatible /api/v2/write endpoint or the v1-compatible /write endpoint with line protocol.
url: https://docs.influxdata.com/influxdb3/clustered/api/data-api/write-data/
estimated_tokens: 3240
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb3/clustered/api/data-api/write-data/
---

[Download Clustered Data API Spec](/openapi/influxdb-clustered-data-api.yml)

Write time series data to InfluxDB 3 Clustered databases 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 database.

Use this endpoint to send data in [line protocol](/influxdb3/clustered/reference/syntax/line-protocol/) format to InfluxDB.

InfluxDB does the following when you send a write request:

1. Validates the request
2. If successful, attempts to [ingest the data](/influxdb3/clustered/reference/internals/durability/#data-ingest); *error* otherwise.
3. If successful, responds with *success* (HTTP `204` status 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`requiredstring

Ignored. 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`string

Ignored. An organization ID.

InfluxDB ignores this parameter; authorizes the request using the specified database token
and writes data to the specified cluster database.

`bucket`requiredstring

A database name or ID.
InfluxDB writes all points in the batch to the specified database.

`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.

* 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 bodyrequired

In the request body, provide data in [line protocol format](/influxdb3/clustered/reference/syntax/line-protocol/).

To send compressed data, do the following:

1. Use [gzip](https://www.gzip.org/) 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](#)

```sh
curl --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

204Success. Data is written and queryable.

400

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`requiredstring

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 or query the database.

`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`requiredstring

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 size limit.

`code`requiredstring

Code is the machine-readable error code.

Allowed:`invalid`

`message`requiredstring

Human-readable message.

429

Too many requests.

* Returns this error if ingesters are resource constrained.

500Internal server error.
The server encountered an unexpected situation.

`code`requiredstring

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 due to concurrent request limits or insufficient healthy ingesters.

defaultNon 2XX error response from server.

`code`requiredstring

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 database.

Use this InfluxDB v1-compatible endpoint to send data in [line protocol](/influxdb3/clustered/reference/syntax/line-protocol/) format to InfluxDB using v1 API parameters and authorization.

InfluxDB does the following when you send a write request:

1. Validates the request
2. If successful, attempts to [ingest the data](/influxdb3/clustered/reference/internals/durability/#data-ingest); *error* otherwise.
3. If successful, responds with *success* (HTTP `204` status 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`string

The InfluxDB 1.x username to authenticate the request.

`p`string

The InfluxDB 1.x password to authenticate the request.

`db`requiredstring

database to write to. If none exists, InfluxDB creates a database 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, its value indicates to the database that compression is applied to the line protocol body.

Allowed values:`gzip`, `identity`

Default:`identity`

#### Request bodyrequired

Line protocol body

Content-Type:`application/json`

Example request[Ask AI about this](#)

```sh
curl --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

204Write data is correctly formatted and accepted for writing to the database.

400Data 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](/influxdb3/clustered/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.

`code`requiredstring

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.

401Token doesn’t have sufficient permissions to write to this database or the database doesn’t exist.

`code`requiredstring

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.

403No token was sent and they are required.

`code`requiredstring

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.

413Write 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`requiredstring

Code is the machine-readable error code.

Allowed:`invalid`

`message`requiredstring

Human-readable message.

429Too many requests. The service may be temporarily unavailable or ingesters are resource constrained.

503Server is temporarily unavailable to accept writes due to too many concurrent requests or insufficient healthy ingesters.

defaultInternal server error

`code`requiredstring

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.

#### Related

* [Write data](/influxdb3/clustered/write-data/)
* [Get started writing data](/influxdb3/clustered/get-started/write/)
* [Best practices for writing data](/influxdb3/clustered/write-data/best-practices/)
* [Troubleshoot issues writing data](/influxdb3/clustered/write-data/troubleshoot/)
* [Optimize writes to InfluxDB](/influxdb3/clustered/write-data/best-practices/optimize-writes/)
* [InfluxDB 3 API client libraries](/influxdb3/clustered/reference/client-libraries/v3/)
