---
title: "POST /#X-Amz-Target=AmazonAthena.CreateNamedQuery"
method: POST
path: "/#X-Amz-Target=AmazonAthena.CreateNamedQuery"
---

# POST /#X-Amz-Target=AmazonAthena.CreateNamedQuery

`POST /#X-Amz-Target=AmazonAthena.CreateNamedQuery`

Creates a named query in the specified workgroup. Requires that you have access to the workgroup.

For code samples using the Amazon Web Services SDK for Java, see [Examples and Code Samples](http://docs.aws.amazon.com/athena/latest/ug/code-samples.html) in the _Amazon Athena User Guide_.

## Headers

- `X-Amz-Target` 'AmazonAthena.CreateNamedQuery', required

## Request body

- CreateNamedQueryInput
  - `Name` string, required — The query name.
  - `Description` string — The query description.
  - `Database` string, required — The database to which the query belongs.
  - `QueryString` string, required — The contents of the query with all query statements.
  - `ClientRequestToken` string — <p>A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another <code>CreateNamedQuery</code> request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the <code>QueryString</code>, an error is returned.</p> <important> <p>This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web Services SDK for Java) auto-generate the token for users. If you are not using the Amazon Web Services SDK or the Amazon Web Services CLI, you must provide this token or the action will fail.</p> </important>
  - `WorkGroup` string — The name of the workgroup in which the named query is being created.

## Response `200`

Success

- CreateNamedQueryOutput
  - `NamedQueryId` string — The unique ID of the query.

## Other responses

- `480` — InternalServerException
- `481` — InvalidRequestException

---

[API](https://skmtc.net/aws/apis/athena.md) · [All operations](https://skmtc.net/aws/apis/athena/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/athena/versions/0aec8c61283d/schema)
