InvokeEsRequest
Proxies access to native Elasticsearch APIs by using registered managed credentials. The accessible scope is determined by the permissions of the credential in Elasticsearch. Additionally, when a RAM user calls this API operation by using a managed credential, the caller must have the permissions on this API operation and the elasticsearch:UseCredential permission on the credential.
Operation description
For RAM user authorization, refer to the following example and replace the region and account information as needed.
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "elasticsearch:InvokeEsRequest",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "elasticsearch:UseCredential",
"Resource": "acs:elasticsearch:{#regionId}:{#accountId}:instances/{#instanceId}/credentials/{#credentialId}"
}
]
}
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
elasticsearch:InvokeEsRequest |
none |
*Instance
|
None | None |
Request syntax
POST /openapi/instances/{instanceId}/es-request HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| instanceId |
string |
Yes |
The instance ID. |
es-cn-n6w1o1x0w001c**** |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| path |
string |
Yes |
The Elasticsearch path to access. This parameter is required. The leading slash (/) can be omitted. |
_cat/indices?format=json |
| method |
string |
No |
The HTTP method used to access Elasticsearch. Default value: GET. |
GET |
| credentialId |
string |
No |
The ID of the credential to use. If this parameter is not specified, the default credential of the instance is used. |
cred-7k2mq9xr4vbn |
| body |
string |
No |
The request body passed through to Elasticsearch. Specify this parameter based on the requirements of the destination Elasticsearch API operation. This parameter is not required for API operations that do not have a request body, such as GET. |
{"query":{"match_all":{}}} |
| system |
boolean |
No |
Specifies whether to use the Alibaba Cloud Elasticsearch system credential. Default value: false. |
false |
Snapshot request reference:
For details about the request body, refer to the Elasticsearch official documentation.
View snapshot policies
POST /openapi/instances/es-cn-xxx/es-request?path=/_slm/policy&method=GET&system=true
Create an automatic backup policy
POST /openapi/instances/es-cn-xxx/es-request?path=/_slm/policy/snapshot_test&method=PUT&system=true
Sample request body
{
"schedule": "0 00 04 * * ?",
"name": "<snapshot_test-{now{yyyyMMddHHmmss}}>",
"repository": "backupnew",
"config": {
"indices": [
"*",
"-.monitoring*",
"-.security*",
"-.kibana*",
"-.internal.alerts*",
"-.alerts*",
"-.ds*",
"-.ds-ilm-history-*",
"-.slo-*"
],
"ignore_unavailable": true,
"include_global_state": false
},
"retention": {
"expire_after": "7d"
}
}
Manual backup
POST /openapi/instances/es-cn-xxx/es-request?path=/_snapshot/snapshot_test/manual_20260924_1***3_u81b&method=PUT&system=true
Sample request body
{
"indices": [
"test_snapshot_index"
],
"ignore_unavailable": true,
"include_global_state": false
}
Snapshot restoration
POST /openapi/instances/es-cn-xxx/es-request?path=/_snapshot/snapshot_test/manual_20260924_15***_u81b/_restore&method=POST&system=true
Sample request body
{
"indices": "test_snapshot_index",
"ignore_unavailable": true,
"include_global_state": false,
"partial": false,
"rename_pattern": "(.+)",
"rename_replacement": "restore1_$1"
}
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
Id of the request |
8E5A2C41-D96B-4308-AF72-5C0B14E6**** |
| Result |
any |
The response content returned as-is by Elasticsearch. The structure is determined by the called Elasticsearch API operation. |
{"esResult":{"took":5,"timed_out":false,"hits":{"total":{"value":1,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"my-index","_id":"1","_score":1.0,"_source":{"title":"Wireless Bluetooth headphones"}}]}}} |
Sample response body
View snapshot repositories
POST /openapi/instances/es-cn-xxx/es-request?path=/_snapshot&method=GET&system=true
{
"RequestId":"01A0D256-6C5D-1ECE-****B0B4A9CE92A0",
"Result":{
"esResult":{
"snapshot_test":{
"settings":{
"bucket":"elasticsearch-test-***",
"chunk_size":"500mb",
"endpoint":"http://oss-cn-hangzhou-internal.aliyuncs.com",
"compress":"true",
"base_path":"snapshots"
},
"type":"oss"
},
"aliyun_auto_snapshot":{
"settings":{
"endpoint":"http://oss-cn-hangzhou-internal.aliyuncs.com",
"compress":"true",
"base_path":"813996-1330710960327595/es-cn-4b84z1c***"
},
"type":"oss"
}
}
}
}
Examples
Success response
JSON format
{
"RequestId": "8E5A2C41-D96B-4308-AF72-5C0B14E6****",
"Result": "{\"esResult\":{\"took\":5,\"timed_out\":false,\"hits\":{\"total\":{\"value\":1,\"relation\":\"eq\"},\"max_score\":1.0,\"hits\":[{\"_index\":\"my-index\",\"_id\":\"1\",\"_score\":1.0,\"_source\":{\"title\":\"Wireless Bluetooth headphones\"}}]}}}"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.