---
updatedAt: 2026-04-23T12:57:25.000Z
agentTools:
  projectIndex: https://documentation.northstake.dk/llms.txt
---

# Generate a new API key

Allows a user to generate a new API key with specific rights and restrictions.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Northstake",
    "description": "Northstake api\n\nOperation-level extensions used by the API:\n- x-roleRequired (array of strings): roles required to call the operation.\n- x-mfaApiScope (array of strings): MFA API scopes required when the user has MFA enrolled.\n- x-isProSvmFeature (boolean): when true, the operation is restricted to users whose Cosmos user document has is_pro_svm_user set to true.\n",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.northstake.dk/v1"
    }
  ],
  "paths": {
    "/account/apiKeys": {
      "post": {
        "x-roleRequired": [
          "admin"
        ],
        "x-mfaApiScope": [
          "create:api_key"
        ],
        "operationId": "generateApiKey",
        "summary": "Generate a new API key",
        "description": "Allows a user to generate a new API key with specific rights and restrictions.",
        "tags": [
          "account/apiKeys"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "title": "GenerateApiKeyRequest",
                "type": "object",
                "properties": {
                  "keyName": {
                    "type": "string",
                    "description": "A descriptive name for the API key."
                  },
                  "publicKey": {
                    "type": "string",
                    "description": "The public part of an RSA private keypair in PEM format."
                  },
                  "whitelistedIPs": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "description": "IP addresses or CIDR ranges that are allowed to use this API key."
                    }
                  },
                  "keyRights": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "user",
                        "reader"
                      ]
                    },
                    "default": [
                      "reader"
                    ],
                    "description": "The rights associated with the API key."
                  }
                },
                "required": [
                  "keyName",
                  "publicKey"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "API key generated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKey"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the API key"
          },
          "keyName": {
            "type": "string",
            "description": "Descriptive name for the API key"
          },
          "key": {
            "type": "string",
            "description": "The API key value"
          },
          "pubKey": {
            "type": "string",
            "description": "The public key associated with the API key"
          },
          "ipWhitelist": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of IP addresses or CIDR ranges allowed to use this API key"
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "admin",
                "user",
                "reader"
              ]
            },
            "description": "Roles associated with the API key"
          }
        },
        "required": [
          "id",
          "keyName",
          "key",
          "pubKey"
        ]
      },
      "ErrorResponse": {
        "title": "APIErrorResponse",
        "description": "General structure for error responses from the API.",
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
```