# Add a Key

Add a keys that can be used to securely authenticate at the Zitadel APIs using JWT profile authentication using short-lived tokens. Make sure you store the returned key safely, as you won't be able to read it from the Zitadel API anymore. Only users of type machine can have keys.

**Required permission:**

- user.write

## POST

``
/v2/users/{user_id}/keys
``

### Send

**Path**

**Body**

## [Path Parameters](/content/docs/reference/api/user/zitadel.user.v2.UserService.AddKey#parameters-path/index.html)

- `user_id*user_id`

## [Request Body](/content/docs/reference/api/user/zitadel.user.v2.UserService.AddKey#request-body/index.html)

### `application/json`

### TypeScript Definitions

Use the request body type in TypeScript.

```json
{
  "expirationDate": "expiration_date",  
  "publicKey": "public_key"
}
```

**expirationDate?** expiration_date

The date the key will expire and no logins will be possible anymore.

**Format**: `date-time`

**publicKey?** public_key

Optionally provide a public key of your own generated RSA private key.

**Format**: `byte`

## [Response Body](/content/docs/reference/api/user/zitadel.user.v2.UserService.AddKey#response-body/index.html)

### 200  `application/json`

**cURL**

```bash
curl -X POST "https://example.com/v2/users/string/keys" \
  -H "Content-Type: application/json" \
  -d '{}'
```

#### Response Example

```json
{
  "creationDate": "2023-01-15T01:30:15.01Z",
  "keyId": "string",
  "keyContent": "string"
}
```
