---
title: "Generate keys"
method: POST
path: "/v1/cryptotoken/{cryptotoken_name}/generatekeys"
tags: ["v1/cryptotoken"]
---

# Generate keys

`POST /v1/cryptotoken/{cryptotoken_name}/generatekeys`

Generates a key pair given crypto token name, key pair alias, key algorithm and key specification, i.e. RSA 4096 or ECDSA secp256r1.

## Path parameters

- `cryptotoken_name` string, required

## Request body

- CryptoTokenKeyGenerationRestRequest
  - `key_pair_alias` string — Key pair aliasof the key pair to be generated, must not already exist
  - `key_alg` string — Key algorithm, required for some algorithms, RSA, not required for others like EC or ML-DSA
  - `key_spec` string — Key specification, key size, curve or name, must be supported by the underlying crypto token, like 4096 for RSA or secp256r1 for EC
  - `key_usage` string — Optional key usage, affects some crypto tokens (PKCS#11 NG) but not most others. Values SIGN, ENCRYPT, SIGN_ENCRYPT

## Response `200`

Successful operation

## Changes

- **2025-03-11** `4045b1bab09f` — 1 breaking, 2 info
  - removed the media type `*/*` from the request body
  - added the media type `application/json` to the request body
  - added the success response with the status `200`
- **2025-03-11** `37878df36b77` — 2 breaking, 1 info
  - removed the media type `application/json` from the request body
  - removed the success response with the status `200`
  - added the media type `*/*` to the request body
- **2025-01-24** `d0f3affe7c3c` — 1 breaking, 2 info
  - removed the media type `*/*` from the request body
  - added the media type `application/json` to the request body
  - added the success response with the status `200`
- **2024-07-05** `b6fc2ad168e5` — 2 breaking, 1 info
  - removed the media type `application/json` from the request body
  - removed the success response with the status `200`
  - added the media type `*/*` to the request body

[Change history](https://skmtc.dev/keyfactor/apis/ejbca-rest-interface/changes/v1/cryptotoken/:cryptotoken_name/generatekeys/post.md)

---

[API](https://skmtc.dev/keyfactor/apis/ejbca-rest-interface.md) · [All operations](https://skmtc.dev/keyfactor/apis/ejbca-rest-interface/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/keyfactor/ejbca-rest-interface/revisions/44f8798658e2/schema)
