- InfluxDB OSS API Service (2.x)
- Quick start
- Authentication
- Supported operations
- Headers
- Pagination
- Response codes
- Data I/O endpoints
InfluxDB OSS API Service (2.x)
License: MIT
The InfluxDB v2 HTTP API provides a programmatic interface for all interactions with an InfluxDB v2 instance.
The InfluxDB v2 HTTP API provides a programmatic interface for all interactions with an InfluxDB v2 instance. Access the InfluxDB API using /api/v2/ and InfluxDB v1-compatible endpoints.
This documentation is generated from the InfluxDB OpenAPI specification.
Quick start
See the API Quick Start to get up and running authenticating with tokens, writing to buckets, and querying data.
InfluxDB API client libraries are available for popular languages and ready to import into your application.
Authentication
Use one of the following schemes to authenticate to the InfluxDB API:
BasicAuthentication
Basic authentication scheme
Use the HTTP Basic authentication scheme for InfluxDB /api/v2 API operations that support it:
Syntax
Authorization: Basic BASE64_ENCODED_CREDENTIALS
To construct the BASE64_ENCODED_CREDENTIALS, combine the username and the password with a colon (USERNAME:PASSWORD), and then encode the resulting string in base64. Many HTTP clients encode the credentials for you before sending the request.
Warning: Base64-encoding can easily be reversed to obtain the original username and password. It is used to keep the data intact and does not provide security. You should always use HTTPS when authenticating or sending a request with sensitive information.
Examples
In the examples, replace the following:
USERNAME: InfluxDB usernamePASSWORD: InfluxDB API tokenINFLUX_URL: your InfluxDB URL
Encode credentials with cURL
The following example shows how to use cURL to send an API request that uses Basic authentication. With the --user option, cURL encodes the credentials and passes them in the Authorization: Basic header.
1. curl --get "INFLUX_URL/api/v2/signin"
2. --user "USERNAME":"PASSWORD"
Encode credentials with Flux
The Flux http.basicAuth() function returns a Base64-encoded basic authentication header using a specified username and password combination.
Encode credentials with JavaScript
The following example shows how to use the JavaScript btoa() function to create a Base64-encoded string:
1. btoa('USERNAME:PASSWORD')
The output is the following:
1. 'VVNFUk5BTUU6UEFTU1dPUkQ='
Once you have the Base64-encoded credentials, you can pass them in the Authorization header—for example:
1. curl --get "INFLUX_URL/api/v2/signin"
2. --header "Authorization: Basic VVNFUk5BTUU6UEFTU1dPUkQ="
To learn more about HTTP authentication, see Mozilla Developer Network (MDN) Web Docs, HTTP authentication._
| Security Scheme Type | HTTP |
| HTTP Authorization Scheme | basic |
TokenAuthentication
Use the Token authentication scheme to authenticate to the InfluxDB API.
In your API requests, send an Authorization header. For the header value, provide the word Token followed by a space and an InfluxDB API token. The word Token is case-sensitive.
Syntax
Authorization: Token INFLUX_API_TOKEN
Example
Use Token authentication with cURL
The following example shows how to use cURL to send an API request that uses Token authentication:
1. curl --request GET "INFLUX_URL/api/v2/buckets" \
2. --header "Authorization: Token INFLUX_API_TOKEN"
Replace the following:
INFLUX_URL: your InfluxDB URLINFLUX_API_TOKEN: your InfluxDB API token
Related endpoints
Related guides
| Security Scheme Type | API Key |
| Header parameter name: | Authorization |
Supported operations
The following table shows the most common operations that the InfluxDB /api/v2 API supports. Some resources may support other operations that perform functions more specific to those resources. For example, you can use the PATCH /api/v2/scripts endpoint to update properties of a script resource.
| Operation | |
|---|---|
| Write | Writes (POST) data to a bucket. |
| Run | Executes (POST) a query or script and returns the result. |
| List | Retrieves (GET) a list of zero or more resources. |
| Create | Creates (POST) a new resource and returns the resource. |
| Update | Modifies (PUT) an existing resource to reflect data in your request. |
| Delete | Removes (DELETE) a specific resource. |
Headers
InfluxDB HTTP API endpoints use standard HTTP request and response headers. The following table shows common headers used by many InfluxDB API endpoints. Some endpoints may use other headers that perform functions more specific to those endpoints—for example, the POST /api/v2/write endpoint accepts the Content-Encoding header to indicate the compression applied to line protocol in the request body.
| Header | Value type | Description |
|---|---|---|
Accept |
string | The content type that the client can understand. |
Authorization |
string | The authorization scheme and credential. |
Content-Length |
integer | The size of the entity-body, in bytes, sent to the database. |
Content-Type |
string | The format of the data in the request body. |
Pagination
Some InfluxDB API list operations may support the following query parameters for paginating results:
| Query parameter | Value type | Description |
|---|---|---|
limit |
integer | The maximum number of records to return (after other parameters are applied). |
offset |
integer | The number of records to skip (before limit, after other parameters are applied). |
after |
string (resource ID) | Only returns resources created after the specified resource. |
Limitations
- For specific endpoint parameters and examples, see the endpoint definition.
- If you specify an
offsetparameter value greater than the total number of records, then InfluxDB returns an empty list in the response (givenoffsetskips the specified number of records).
The following example passes offset=50 to skip the first 50 results, but the user only has 10 buckets:
1. curl --request GET "INFLUX_URL/api/v2/buckets?limit=1&offset=50" \
2. --header "Authorization: Token INFLUX_API_TOKEN"
The response contains the following:
1. {
2. "links": {
3. "prev": "/api/v2/buckets?descending=false\u0026limit=1\u0026offset=49\u0026orgID=ORG_ID",
4. "self": "/api/v2/buckets?descending=false\u0026limit=1\u0026offset=50\u0026orgID=ORG_ID"
5. },
6. "buckets": []
7. }
Response codes
InfluxDB HTTP API endpoints use standard HTTP status codes for success and failure responses. The response body may include additional details. For details about a specific operation’s response, see Responses and Response Samples for that operation.
API operations may return the following HTTP status codes:
| Code | Status | Description |
|---|---|---|
200 |
Success | |
204 |
Success. No content | InfluxDB doesn’t return data for the request. |
400 |
Bad request | May indicate one of the following: - Line protocol is malformed. The response body contains the first malformed line in the data and indicates what was expected. For partial writes, the number of points written and the number of points rejected are also included. For more information, check the rejected_points measurement in your _monitoring bucket. - Authorization header is missing or malformed or the API token doesn’t have permission for the operation. |
401 |
Unauthorized | May indicate one of the following: - Authorization: Token header is missing or malformed - API token value is missing from the header - API token doesn’t have permission. For more information about token types and permissions, see Manage API tokens |
404 |
Not found | Requested resource was not found. message in the response body provides details about the requested resource. |
413 |
Request entity too large | Request payload exceeds the size limit. |
422 |
Unprocessable entity | Request data is invalid. code and message in the response body provide details about the problem. |
429 |
Too many requests | API token is temporarily over the request quota. The Retry-After header describes when to try the request again. |
500 |
Internal server error | |
503 |
Service unavailable | Server is temporarily unavailable to process the request. The Retry-After header describes when to try the request again. |
Data I/O endpoints
Delete data
Deletes data from a bucket.
Use this endpoint to delete points from a bucket in a specified time range.
InfluxDB Cloud
-
Does the following when you send a delete request:
-
Validates the request and queues the delete.
- 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 2xx status 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
- Validates the request, handles the delete synchronously, and then responds with success or failure.
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
- Delete data
- Learn how to use delete predicate syntax.
- Learn how InfluxDB handles deleted tags and deleted fields.
Authorizations:
query Parameters
| bucket | string A bucket name or ID. Specifies the bucket to delete data from. If you pass both bucket and bucketID, bucketID takes precedence. |
| bucketID | string A bucket ID. Specifies the bucket to delete data from. If you pass both bucket and bucketID, bucketID takes precedence. |
| org | string An organization name or ID. InfluxDB Cloud - Doesn’t use the org parameter or orgID parameter. - Deletes data from the bucket in the organization associated with the authorization (API token). InfluxDB OSS - Requires either the org parameter or the orgID parameter. - Deletes data from the bucket in the specified organization. - If you pass both orgID and org, they must both be valid. |
| orgID | string An organization ID. InfluxDB Cloud - Doesn’t use the org parameter or orgID parameter. - Deletes data from the bucket in the organization associated with the authorization (API token). InfluxDB OSS - Requires either the org parameter or the orgID parameter. - Deletes data from the bucket in the specified organization. - If you pass both orgID and org, they must both be valid. |
header Parameters
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Request Body schema: application/json
Time range parameters and an optional delete predicate expression.
To select points to delete within the specified time range, pass a delete predicate expression in the predicate property of the request body. If you don’t pass a predicate, InfluxDB deletes all data with timestamps in the specified time range.
Related guides
- Delete data
- Learn how to use delete predicate syntax.
| predicate | string An expression in delete predicate syntax. |
| start required | string <date-time> A timestamp (RFC3339 date/time format). The earliest time to delete from. |
| stop required | string <date-time> A timestamp (RFC3339 date/time format). The latest time to delete from. |
Responses
204
Success.
InfluxDB Cloud
- Validated and queued the request.
- Handles the delete asynchronously - the deletion might not have completed yet.
An HTTP 2xx status code acknowledges that the write or delete is queued. To ensure that InfluxDB Cloud handles writes and deletes in the order you request them, wait for a response before you send the next request.
Because writes are asynchronous, data might not yet be written when you receive the response.
InfluxDB OSS
- Deleted the data.
400
Bad request. The response body contains detail about the error.
InfluxDB OSS
- Returns this error if the
orgparameter ororgIDparameter doesn’t match an organization.
401
Unauthorized. 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.
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.
500
Internal server error. The server encountered an unexpected situation.
default
Non 2XX error response from server.
post/api/v2/delete
/api/v2/delete
Request samples
- Payload
- cURL
Content type
application/json
Copy
Expand all Collapse all
{ - "predicate": "tag1=\"value1\" and (tag2=\"value2\" and tag3!=\"value3\")", - "start": "2019-08-24T14:15:22Z", - "stop": "2019-08-24T14:15:22Z" }
Response samples
- 400
- 401
- 404
- 500
- default
Content type
application/json
Copy
Expand all Collapse all
{ - "code": "invalid", - "message": "failed to decode request body: organization not found" }
Query data
Retrieves data from buckets.
Use this endpoint to send a Flux query request and retrieve data from a bucket.
Rate limits (with InfluxDB Cloud)
read rate limits apply. For more information, see limits and adjustable quotas.
Related guides
Authorizations:
query Parameters
| org | string An organization name or ID. InfluxDB Cloud - Doesn’t use the org parameter or orgID parameter. - Queries the bucket in the organization associated with the authorization (API token). InfluxDB OSS - Requires either the org parameter or orgID parameter. - Queries the bucket in the specified organization. |
| orgID | string An organization ID. InfluxDB Cloud - Doesn’t use the org parameter or orgID parameter. - Queries the bucket in the organization associated with the authorization (API token). InfluxDB OSS - Requires either the org parameter or orgID parameter. - Queries the bucket in the specified organization. |
header Parameters
| Accept-Encoding | string Default: identity Enum: “gzip” “identity” The content encoding (usually a compression algorithm) that the client can understand. |
| Content-Type | string Enum: “application/json” “application/vnd.flux” |
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Request Body schema:
application/json

application/json
application/vnd.flux
Flux query or specification to execute
| dialectv2 API - 图8 | object (Dialect) Options for tabular data output. Default output is annotated CSV with headers. For more information about tabular data dialect, see W3 metadata vocabulary for tabular data. |
| externv2 API - 图9 | object (File) Represents a source from a single file |
| now | string <date-time> Specifies the time that should be reported as now in the query. Default is the server now time. |
| query required | string The query script to execute. |
| type | string Value: “flux” The type of query. Must be “flux”. |
Responses
200
Success. The response body contains query results.
400
Bad request. The response body contains detail about the error.
InfluxDB OSS
- Returns this error if the
orgparameter ororgIDparameter doesn’t match an organization.
401
Unauthorized. 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.
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.
429
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
- returns
Retry-Afterheader that describes when to try the write again.
InfluxDB OSS:
- doesn’t return this error.
500
Internal server error. The server encountered an unexpected situation.
default
Non 2XX error response from server.
post/api/v2/query
/api/v2/query
Request samples
- Payload
- cURL
Content type
application/json

application/json
application/vnd.flux
Copy
Expand all Collapse all
{ - "dialect": { - "annotations": [ - "group" ], - "commentPrefix": "#", - "dateTimeFormat": "RFC3339", - "delimiter": ",", - "header": true }, - "extern": { - "body": [ - { - "text": "string", - "type": "string" } ], - "imports": [ - { - "as": { - "name": "string", - "type": "string" }, - "path": { - "type": "string", - "value": "string" }, - "type": "string" } ], - "name": "string", - "package": { - "name": { - "name": "string", - "type": "string" }, - "type": "string" }, - "type": "string" }, - "now": "2019-08-24T14:15:22Z", - "query": "string", - "type": "flux" }
Response samples
- 200
- 400
- 401
- 404
- 500
- default
Content type
application/csv
Copy
1. result,table,_start,_stop,_time,region,host,_value
2. mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
3. mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
4. mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
List tasks
Retrieves a list of tasks.
To limit which tasks are returned, pass query parameters in your request. If no query parameters are passed, InfluxDB returns all tasks up to the default limit.
Related guide
Authorizations:
query Parameters
| after | string A task ID. Only returns tasks created after the specified task. |
| limit | integer [ 1 .. 500 ] Default: 100 The maximum number of tasks to return. Default is 100. The minimum is 1 and the maximum is 500. To reduce the payload size, combine type=basic and limit (see Request samples). For more information about the basic response, see the type parameter. |
| name | string A task name. Only returns tasks with the specified name. Different tasks may have the same name. |
| org | string An organization name. Only returns tasks owned by the specified organization. |
| orgID | string An organization ID. Only returns tasks owned by the specified organization. |
| status | string Enum: “active” “inactive” A task status. Only returns tasks that have the specified status (active or inactive). |
| type | string Default: “” Enum: “basic” “system” A task type (basic or system). Default is system. Specifies the level of detail for tasks in the response. The default (system) response contains all the metadata properties for tasks. To reduce the response size, pass basic to omit some task properties (flux, createdAt, updatedAt). |
| user | string A user ID. Only returns tasks owned by the specified user. |
header Parameters
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Responses
200
Success. The response body contains the list of tasks.
401
Unauthorized. 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.
500
Internal server error. The server encountered an unexpected situation.
default
Non 2XX error response from server.
get/api/v2/tasks
/api/v2/tasks
Request samples
- cURL: all tasks, basic output
Copy
1. curl https://localhost:8086/api/v2/tasks/?limit=-1&type=basic \
2. --header 'Content-Type: application/json' \
3. --header 'Authorization: Token INFLUX_API_TOKEN'
Response samples
- 200
- 401
- 500
- default
Content type
application/json
Example
Basic output

Basic output
System output
A sample response body for the ?type=basic parameter. type=basic omits some task fields (createdAt and updatedAt) and field values (org, flux) in the response.
Copy
Expand all Collapse all
{ - "links": { - "self": "/api/v2/tasks?limit=100" }, - "tasks": [ - { - "every": "30m", - "flux": "", - "id": "09956cbb6d378000", - "labels": [ ], - "lastRunStatus": "success", - "latestCompleted": "2022-06-30T15:00:00Z", - "links": { - "labels": "/api/v2/tasks/09956cbb6d378000/labels", - "logs": "/api/v2/tasks/09956cbb6d378000/logs", - "members": "/api/v2/tasks/09956cbb6d378000/members", - "owners": "/api/v2/tasks/09956cbb6d378000/owners", - "runs": "/api/v2/tasks/09956cbb6d378000/runs", - "self": "/api/v2/tasks/09956cbb6d378000" }, - "name": "task1", - "org": "", - "orgID": "48c88459ee424a04", - "ownerID": "0772396d1f411000", - "status": "active" } ] }
Create a task
Creates a task and returns the task.
Related guides
Authorizations:
header Parameters
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Request Body schema: application/json
The task to create.
| description | string An optional description of the task. |
| flux required | string The Flux script to run for this task. |
| org | string The name of the organization that owns this Task. |
| orgID | string The ID of the organization that owns this Task. |
| status | string (TaskStatusType) Enum: “active” “inactive” inactive cancels scheduled runs and prevents manual runs of the task. |
Responses
201
Success. The response body contains a tasks list with the task.
400
Bad request. The response body contains detail about the error.
InfluxDB OSS
- Returns this error if an incorrect value is passed for
orgororgID.
401
Unauthorized. 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.
500
Internal server error. The server encountered an unexpected situation.
default
Unexpected error
post/api/v2/tasks
/api/v2/tasks
Request samples
- Payload
- cURL: create a task
Content type
application/json
Copy
Expand all Collapse all
{ - "description": "string", - "flux": "string", - "org": "string", - "orgID": "string", - "status": "active" }
Response samples
- 201
- 400
- 401
- 500
- default
Content type
application/json
Copy
Expand all Collapse all
{ - "authorizationID": "string", - "createdAt": "2019-08-24T14:15:22Z", - "cron": "string", - "description": "string", - "every": "string", - "flux": "string", - "id": "string", - "labels": [ - { - "id": "string", - "name": "string", - "orgID": "string", - "properties": { - "color": "ffb3b3", - "description": "this is a description" } } ], - "lastRunError": "string", - "lastRunStatus": "failed", - "latestCompleted": "2019-08-24T14:15:22Z", - "links": { - "labels": "/api/v2/tasks/1/labels", - "logs": "/api/v2/tasks/1/logs", - "members": "/api/v2/tasks/1/members", - "owners": "/api/v2/tasks/1/owners", - "runs": "/api/v2/tasks/1/runs", - "self": "/api/v2/tasks/1" }, - "name": "string", - "offset": "string", - "org": "string", - "orgID": "string", - "ownerID": "string", - "status": "active", - "updatedAt": "2019-08-24T14:15:22Z" }
Retrieve a task
Retrieves a task.
Authorizations:
path Parameters
| taskID required | string The ID of the task to retrieve. |
header Parameters
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Responses
200
Success. The response body contains the task.
400
Bad request. The response body contains detail about the error.
InfluxDB OSS
- Returns this error if an incorrect value is passed in the
orgparameter ororgIDparameter.
401
Unauthorized. 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.
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.
500
Internal server error. The server encountered an unexpected situation.
default
Non 2XX error response from server.
get/api/v2/tasks/{taskID}
/api/v2/tasks/{taskID}
Response samples
- 200
- 400
- 401
- 404
- 500
- default
Content type
application/json
Copy
Expand all Collapse all
{ - "authorizationID": "string", - "createdAt": "2019-08-24T14:15:22Z", - "cron": "string", - "description": "string", - "every": "string", - "flux": "string", - "id": "string", - "labels": [ - { - "id": "string", - "name": "string", - "orgID": "string", - "properties": { - "color": "ffb3b3", - "description": "this is a description" } } ], - "lastRunError": "string", - "lastRunStatus": "failed", - "latestCompleted": "2019-08-24T14:15:22Z", - "links": { - "labels": "/api/v2/tasks/1/labels", - "logs": "/api/v2/tasks/1/logs", - "members": "/api/v2/tasks/1/members", - "owners": "/api/v2/tasks/1/owners", - "runs": "/api/v2/tasks/1/runs", - "self": "/api/v2/tasks/1" }, - "name": "string", - "offset": "string", - "org": "string", - "orgID": "string", - "ownerID": "string", - "status": "active", - "updatedAt": "2019-08-24T14:15:22Z" }
Start a task run, overriding the schedule
Schedules a task run to start immediately, ignoring scheduled runs.
Use this endpoint to manually start a task run. Scheduled runs will continue to run as scheduled. This may result in concurrently running tasks.
To retry a previous run (and avoid creating a new run), use the POST /api/v2/tasks/{taskID}/runs/{runID}/retry endpoint.
Authorizations:
path Parameters
| taskID required | string |
header Parameters
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Request Body schema: application/json
| scheduledFor | string or null <date-time> The time RFC3339 date/time format used for the run’s now option. Default is the server now time. |
Responses
201
Success. The run is scheduled to start.
401
Unauthorized. 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.
500
Internal server error. The server encountered an unexpected situation.
default
Non 2XX error response from server.
post/api/v2/tasks/{taskID}/runs
/api/v2/tasks/{taskID}/runs
Request samples
- Payload
Content type
application/json
Copy
Expand all Collapse all
{ - "scheduledFor": "2019-08-24T14:15:22Z" }
Response samples
- 201
- 401
- 500
- default
Content type
application/json
Copy
Expand all Collapse all
{ - "finishedAt": "2006-01-02T15:04:05.999999999Z07:00", - "flux": "string", - "id": "string", - "links": { - "retry": "/api/v2/tasks/1/runs/1/retry", - "self": "/api/v2/tasks/1/runs/1", - "task": "/api/v2/tasks/1" }, - "log": [ - { - "message": "Halt and catch fire", - "runID": "string", - "time": "2006-01-02T15:04:05.999999999Z07:00" } ], - "requestedAt": "2006-01-02T15:04:05.999999999Z07:00", - "scheduledFor": "2019-08-24T14:15:22Z", - "startedAt": "2006-01-02T15:04:05.999999999Z07:00", - "status": "scheduled", - "taskID": "string" }
Write 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 2xx status 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
- 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
Authorizations:
query Parameters
| bucket required | string A bucket name or ID. InfluxDB writes all points in the batch to the specified bucket. |
| org required | string An organization name or ID. InfluxDB Cloud - Doesn’t use the org parameter or orgID parameter. - Writes data to the bucket in the organization associated with the authorization (API token). InfluxDB OSS - Requires either the org parameter or the orgID parameter. - If you pass both orgID and org, they must both be valid. - Writes data to the bucket in the specified organization. |
| orgID | string An organization ID. InfluxDB Cloud - Doesn’t use the org parameter or orgID parameter. - Writes data to the bucket in the organization associated with the authorization (API token). InfluxDB OSS - Requires either the org parameter or the orgID parameter. - If you pass both orgID and org, they must both be valid. - Writes data to the bucket in the specified organization. |
| precision | string (WritePrecision) Enum: “ms” “s” “us” “ns” The precision for unix timestamps in the line protocol batch. |
header Parameters
| Accept | string Default: application/json Value: “application/json” 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 Cloud - Returns only application/json for format and limit errors. - Returns only text/html for some quota limit errors. InfluxDB OSS - Returns only application/json for format and limit errors. Related guides - Troubleshoot issues writing data |
| Content-Encoding | string Default: identity Enum: “gzip” “identity” The compression applied to the line protocol in the request payload. To send a gzip payload, pass Content-Encoding: gzip header. |
| 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. |
| Content-Type | string Default: text/plain; charset=utf-8 Enum: “text/plain” “text/plain; charset=utf-8” The format of the data in the request body. To send a line protocol payload, pass Content-Type: text/plain; charset=utf-8. |
| Zap-Trace-Span | string Example: baggage,[object Object],span_id,1,trace_id,1 OpenTracing span context |
Request Body schema: text/plain
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
string <byte>
Responses
204
Success.
InfluxDB Cloud
- Validated and queued the request.
- Handles the write asynchronously - the write might not have completed yet.
InfluxDB OSS
- Successfully wrote all points in the batch.
Related guides
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. 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
- Returns this error if the
orgparameter ororgIDparameter doesn’t match an organization.
401
Unauthorized. 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.
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.
413
The 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:
- Returns this error only if the Go (golang) ioutil.ReadAll() function raises an error.
- Returns
Content-Type: application/jsonfor this error.
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-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
(本文超出站点单文档体积上限,已截断)
