netHSM API error code

Dear Nitrokey teams,

First, many thanks for your product.
I’m planning to use a Docker Nitrokey HSM image to set up a pratical work in an engineering school.

Unfortunately, when I want to generate a key, I got an error code 415 which is not documented in the nethsm-api.yaml.

Could you help me to identify the error ? Is there an exhaustiv list of error available ? Just to be sure I will be able to support students.

Many thanks in advance for your help.

With my best regards.


Dear Philippe,

thanks for your message and the feedback!

I will help you to resolve the problem.
To provide the best help I need a few more information.

  1. You tried to generate a key on POST /keys/generate. Correct?
  2. Did you use the REST API directly or the Nitropy tool?
  3. What kind of key did you try to generate? Maybe you can post the data you sent?

Looking forward to hearing from you!


Dear Markus,

Thank you very much for your help.

Regarding your questions, the answers are

  1. Correct.
  2. I use the direct REST API with python and requests module.
  3. params = {
    “mechanisms”: [
    “type”: “RSA”,
    “length”: 2048,
    “id”: “myRsaSignKey”

I rely on the requests module to send back the status code that it receives. Do you think, that I need to monitor the communication ?



Dear Philippe,

thanks for your quick response!

The parameters you provided for the request body look valid.
We assume the content type of the request might be incorrect,
because HTTP error 415 indicates “Unsupported Media Type”

I prepared a small example for you, using our demo instance.

import requests
from requests.auth import HTTPBasicAuth

url = ""
headers = {'content-type': 'application/json', }
basic = HTTPBasicAuth('admin', 'adminadmin')
    "mechanisms": [
    "type": "RSA",
    "length": 2048,
    "id": "myRsaSignKey"

r =, json=data, headers=headers, auth=basic)

The example sets the content-type to application/json.

Regarding the error codes I will look into improving the documentation.
For testing purposes I can recommend to give the Curl utility a try.
It allows to send HTTP requests from the commandline.
The NetHSM API documentation can provide you the respective command when you click the “Try it out” button under an endpoint.

Please don’t hesitate to reach out if you have further problems or questions!