Base URL
All API requests target your Elasticsearch node. For a local development instance:Authentication
- Basic auth
- API key
Content-Type
All requests with a body must setContent-Type. Most APIs accept application/json. The bulk and multi-search APIs also accept application/x-ndjson.
When passing a request body via the
source query parameter (for libraries that don’t support bodies on GET requests), also set source_content_type=application/json.HTTP methods
| Method | Typical use |
|---|---|
GET | Read data, retrieve documents or settings |
POST | Create documents (auto ID), run searches, execute scripts |
PUT | Create or update documents and settings with explicit IDs |
DELETE | Remove documents, indices, or other resources |
HEAD | Check existence (returns 200 or 404, no body) |
Multi-target syntax
Most APIs that accept an<index> path parameter also accept multi-target expressions:
| Syntax | Meaning |
|---|---|
my-index | Single index |
index-a,index-b | Comma-separated list |
logs-* | Wildcard pattern |
logs-*,-logs-old-* | Wildcard with exclusion |
_all or * | All indices |
Multi-target query parameters
When
true, missing or closed concrete indices are silently ignored instead of returning an error.When
false, returns an error if a wildcard expression resolves to no indices.Controls which index types wildcard patterns can match. Valid values:
open, closed, hidden, all, none. Comma-separated values are accepted.Date math in index names
You can use date math expressions in index name patterns to target time-series indices:| Expression | Resolves to (assuming now = 2024-03-22) |
|---|---|
<logstash-{now/d}> | logstash-2024.03.22 |
<logstash-{now/M}> | logstash-2024.03.01 |
<logstash-{now/M{yyyy.MM}}> | logstash-2024.03 |
<logstash-{now/M-1M{yyyy.MM}}> | logstash-2024.02 |
Common query parameters
These parameters are supported on all REST APIs.Format the JSON response for human readability. Use only for debugging; it adds overhead.
Response format. Accepted values:
json, yaml, cbor, smile.When
true, returns human-readable values for statistics alongside machine-readable ones (for example, "1h" next to 3600000).Comma-separated list of dot-notation paths to include in the response. Supports wildcards. Prefix with
- to exclude.When
true, includes a full Java stack trace in error responses. Useful for debugging unexpected errors.When
true, returns settings in flat dot-notation (index.number_of_shards) instead of nested objects.Response format
Successful write operation responses include:The index the document was written to.
The document ID.
The document version number, incremented on each write.
The operation outcome:
created, updated, or deleted.Error responses
HTTP status code (400, 404, 429, 500, etc.).
Machine-readable error type such as
index_not_found_exception or illegal_argument_exception.Human-readable explanation of the error.
Optimistic concurrency control
Use sequence number and primary term to prevent lost updates when multiple writers target the same document.409 Conflict response.
Rate limiting and back-pressure
When the cluster is under load, Elasticsearch may return429 Too Many Requests. Retry with exponential backoff — start with a short delay and double it on each subsequent 429 response.
API version compatibility
To run an application built for the previous major version without modification after an upgrade, include compatibility headers:Compatibility headers preserve request/response structure but do not guarantee identical behavior in all cases.
Unit conventions
Time units
Durations use suffixed strings:1d (days), 2h (hours), 30m (minutes), 10s (seconds), 500ms (milliseconds), 100micros (microseconds), 50nanos (nanoseconds).
Byte size units
Byte sizes use powers of 1024:1kb = 1024 bytes, 1mb, 1gb, 1tb, 1pb. Raw bytes use no suffix.
Date math in queries
Query parameters that accept dates (such asgt/lt in range queries) support date math:
| Expression | Meaning |
|---|---|
now | Current time |
now+1h | One hour from now |
now-1d/d | Start of yesterday |
2024-01-01||+1M | 2024-01-01 plus one month |
Node specification
Cluster-level APIs that target specific nodes accept a node filter list:Request tracing headers
X-Opaque-Id
X-Opaque-Id
Attach an opaque ID to correlate requests across logs and task management output:Keep the set of values finite — Elasticsearch uses this to deduplicate deprecation warnings.
traceparent
traceparent
W3C trace context header for distributed tracing:Elasticsearch surfaces
trace.id from this header in server logs, slow logs, and deprecation logs.