Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Key Management Service
  • Getting started
  • Access management
  • Pricing policy
  • Terraform reference
    • Authentication with the API
      • Overview
        • Overview
        • Encrypt
        • Decrypt
        • ReEncrypt
        • GenerateDataKey
  • Monitoring metrics
  • Audit Trails events
  • FAQ

In this article:

  • HTTP request
  • Path parameters
  • Body parameters
  • Response
  1. API reference
  2. REST
  3. SymmetricCrypto
  4. GenerateDataKey

Key Management Service API, REST: SymmetricCrypto.GenerateDataKey

Written by
Yandex Cloud
Updated at November 26, 2024
  • HTTP request
  • Path parameters
  • Body parameters
  • Response

Generates a new symmetric data encryption key (not a KMS key) and returns
the generated key as plaintext and as ciphertext encrypted with the specified symmetric KMS key.

HTTP request

POST https://kms.yandex/kms/v1/keys/{keyId}:generateDataKey

Path parameters

Field

Description

keyId

string

Required field. ID of the symmetric KMS key that the generated data key should be encrypted with.

Body parameters

{
  "versionId": "string",
  "aadContext": "string",
  "dataKeySpec": "string",
  "skipPlaintext": "boolean"
}

Field

Description

versionId

string

ID of the key version to encrypt the generated data key with.
Defaults to the primary version if not specified.

aadContext

string (bytes)

Additional authenticated data (AAD context), optional.
If specified, this data will be required for decryption with the SymmetricDecryptRequest.
Should be encoded with base64.

dataKeySpec

enum (SymmetricAlgorithm)

Encryption algorithm and key length for the generated data key.

  • SYMMETRIC_ALGORITHM_UNSPECIFIED
  • AES_128: AES algorithm with 128-bit keys.
  • AES_192: AES algorithm with 192-bit keys.
  • AES_256: AES algorithm with 256-bit keys.
  • AES_256_HSM: AES algorithm with 256-bit keys hosted by HSM

skipPlaintext

boolean

If true, the method won't return the data key as plaintext.
Default value is false.

Response

HTTP Code: 200 - OK

{
  "keyId": "string",
  "versionId": "string",
  "dataKeyPlaintext": "string",
  "dataKeyCiphertext": "string"
}

Field

Description

keyId

string

ID of the symmetric KMS key that was used to encrypt the generated data key.

versionId

string

ID of the key version that was used for encryption.

dataKeyPlaintext

string (bytes)

Generated data key as plaintext.
The field is empty, if the GenerateDataKeyRequest.skipPlaintext parameter
was set to true.

dataKeyCiphertext

string (bytes)

The encrypted data key.

Was the article helpful?

Previous
ReEncrypt
Next
Overview
© 2025 Direct Cursus Technology L.L.C.