StartQueryExecution - Amazon Athena
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Runs the SQL query statements contained in the Query. Requires you to have access to the workgroup in which the query ran. Running queries against an external catalog requires GetDataCatalog permission to the catalog. For code samples using the Amazon SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide.

Request Syntax

{ "ClientRequestToken": "string", "ExecutionParameters": [ "string" ], "QueryExecutionContext": { "Catalog": "string", "Database": "string" }, "QueryString": "string", "ResultConfiguration": { "AclConfiguration": { "S3AclOption": "string" }, "EncryptionConfiguration": { "EncryptionOption": "string", "KmsKey": "string" }, "ExpectedBucketOwner": "string", "OutputLocation": "string" }, "ResultReuseConfiguration": { "ResultReuseByAgeConfiguration": { "Enabled": boolean, "MaxAgeInMinutes": number } }, "WorkGroup": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.


A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another StartQueryExecution request is received, the same response is returned and another query is not created. An error is returned if a parameter, such as QueryString, has changed. A call to StartQueryExecution that uses a previous client request token returns the same QueryExecutionId even if the requester doesn't have permission on the tables specified in QueryString.


This token is listed as not required because Amazon SDKs (for example the Amazon SDK for Java) auto-generate the token for users. If you are not using the Amazon SDK or the Amazon CLI, you must provide this token or the action will fail.

Type: String

Length Constraints: Minimum length of 32. Maximum length of 128.

Required: No


A list of values for the parameters in a query. The values are applied sequentially to the parameters in the query in the order in which the parameters occur.

Type: Array of strings

Array Members: Minimum number of 1 item.

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: No


The database within which the query executes.

Type: QueryExecutionContext object

Required: No


The SQL query statements to be executed.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 262144.

Required: Yes


Specifies information about where and how to save the results of the query execution. If the query runs in a workgroup, then workgroup's settings may override query settings. This affects the query results location. The workgroup settings override is specified in EnforceWorkGroupConfiguration (true/false) in the WorkGroupConfiguration. See WorkGroupConfiguration:EnforceWorkGroupConfiguration.

Type: ResultConfiguration object

Required: No


Specifies the query result reuse behavior for the query.

Type: ResultReuseConfiguration object

Required: No


The name of the workgroup in which the query is being started.

Type: String

Pattern: [a-zA-Z0-9._-]{1,128}

Required: No

Response Syntax

{ "QueryExecutionId": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


The unique ID of the query that ran as a result of this request.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: \S+


For information about the errors that are common to all actions, see Common Errors.


Indicates a platform issue, which may be due to a transient condition or outage.

HTTP Status Code: 500


Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.

HTTP Status Code: 400


Indicates that the request was throttled.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: