Create Key

Overview

Creates a new cryptographic key and deploys it to environments. Keys are used for encryption, decryption, signing, and verification operations.

Endpoint

POST /apiops/projects/{projectName}/keys/

Authentication

Requires a Personal API Access Token.

Authorization: Bearer YOUR_TOKEN

Request

Headers

Header Value Required
Authorization Bearer {token} Yes
Content-Type application/json Yes

Path Parameters

Parameter Type Required Description
projectName string Yes Project name

Request Body

The request body should contain a complete CryptoKeyInfo object. See the Key structure in the response format.

Notes

  • name must be unique within the project
  • Key is automatically deployed to all specified environments after creation
  • Key material must be provided as base64-encoded content

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "message": "Deployment completed successfully",
    "environmentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployed successfully"
      }
    ]
  }
}

Error Response (400 Bad Request)

{
  "error": "bad_request",
  "error_description": "Key (name: my-key) is already exist! Try update operation if want to change its value."
}

cURL Example

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/keys/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-key",
    "description": "Key for API encryption",
    "keyType": "RSA",
    "cryptoKeyInfoEnvironmentList": [
      {
        "environmentName": "production",
        "publicKey": "base64-encoded-public-key",
        "privateKey": "base64-encoded-private-key"
      }
    ]
  }'

Notes and Warnings

  • Key Name:
    • Must be unique within the project
  • Automatic Deployment:
    • Key is automatically deployed after creation
  • Permissions:
    • Requires ROLE_API_SECURITY permission
    • Requires ROLE_DEPLOY_UNDEPLOY_PROXIES permission for deployment