InvokeEsRequest

Updated at:

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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

elasticsearch:InvokeEsRequest

none

*Instance

acs:elasticsearch:{#regionId}:{#accountId}:instances/{#instancesId}

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.