# Create API key **POST /users/auth/keys** Creates a new API key. ## Servers - https://api.elastic-cloud.com/api/v1: https://api.elastic-cloud.com/api/v1 () ## Parameters ### Body: application/json (object) The request to create the API key - **description** (string) API key description. Useful if there are multiple keys - **expiration** (string) The optional expiration for the API key, provided as a duration (ex: '1d', '3h') - **role_assignments** (object) Roles assigned to users, API keys or organization invitations. Currently unavailable in self-hosted ECE. ## Responses ### 201 The API key is created and returned in the body of the response. #### Body: application/json (object) - **id** (string) The API key ID. - **user_id** (string) The user ID. - **organization_id** (string) The organization ID linked to the API key - **description** (string) The API key description. TIP: Useful when you have multiple API keys. - **key** (string) The API key. TIP: Since the API key is returned only once, save it in a safe place. - **creation_date** (string(date-time)) The date/time for when the API key is created. - **expiration_date** (string(date-time)) The date/time when the API key expires. - **role_assignments** (object) Roles assigned to users, API keys or organization invitations. Currently unavailable in self-hosted ECE. ### 400 The request is invalid. Specify a different request, then try again. (code: `api_keys.invalid_input`) #### Headers - **x-cloud-error-codes** (string) The error codes associated with the response #### Body: application/json (object) - **errors** (array[object]) A list of errors that occurred in the failing request [Powered by Bump.sh](https://bump.sh)