# Method: projects.locations.keys.create

- [HTTP request](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.PATH_PARAMETERS)
- [Query parameters](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.QUERY_PARAMETERS)
- [Request body](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.request_body)
- [Response body](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#body.aspect_1)
- [Try it!](https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys/create#try-it)

Creates a new API key.

NOTE: Key is a global resource; hence the only supported value for location is `global`.

### HTTP request

`POST https://apikeys.googleapis.com/v2/{parent=projects/*/locations/*}/keys`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The project in which the API key is created. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `parent`: - `apikeys.keys.create` |

### Query parameters

| Parameters ||
|---|---|
| `keyId` | `string` User specified key id (optional). If specified, it will become the final component of the key resource name. The id must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the id must match the regular expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id must NOT be a UUID-like string. |

### Request body

The request body contains an instance of `https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/projects.locations.keys#Key`.

### Response body

If successful, the response body contains a newly created instance of `https://docs.cloud.google.com/api-keys/docs/reference/rest/v2/operations#Operation`.

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

### IAM Permissions

Requires the following [IAM](https://cloud.google.com/iam/docs) permission on the `parent` resource:

- `apikeys.keys.create`

For more information, see the [IAM documentation](https://cloud.google.com/iam/docs).