MONGOC_CLIENT...CREATE_DATAKEY(3)

πŸ’… MONGOC_CLIENT...CREATE_DATAKEY(3) πŸ’…

okay so bestie, welcome to the libmongoc manual page for mongoc_client_encryption_create_datakey β€” yes that's a mouthful, no i will not be shortening it, it's iconic as is πŸŽ€


✨ SYNOPSIS ✨

bool
mongoc_client_encryption_create_datakey (
   mongoc_client_encryption_t *client_encryption,
   const char *kms_provider,
   const mongoc_client_encryption_datakey_opts_t *opts,
   bson_value_t *keyid,
   bson_error_t *error);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function literally creates a brand new key document in the key vault collection, and it sets keyid to the UUID of the newly created key β€” but only if keyid is not NULL, iykyk. 🫢

the new key can be used to configure automatic encryption (peep mongoc_client_enable_auto_encryption() and mongoc_client_pool_enable_auto_encryption()) or for explicit encryption (see mongoc_client_encryption_encrypt()). both roads lead to slay. ✨

the created key document is inserted into the key vault collection β€” which you identify via mongoc_client_encryption_opts_set_keyvault_namespace() β€” and it goes in with majority write concern. no cap, majority. πŸ‘‘

ok important thing bestie: keyid is always initialized (even on error). you, the caller, must call bson_value_destroy() on keyid to free it. don't forget or it's giving memory leak energy πŸ’€

🌸 PARAMETERS 🌸

  • client_encryption β€” a mongoc_client_encryption_t. the main character of this whole operation πŸ’…
  • kms_provider β€” a string identifying the Key Management Service (KMS) provider used to encrypt the datakey (e.g. "aws" or "local"). pick your fighter. 🧚
  • opts β€” a mongoc_client_encryption_datakey_opts_t. the options, obviously. ✨
  • keyid β€” optional. an uninitialized bson_value_t that gets set to the UUID (BSON binary subtype 0x04) of the newly created key. must be freed by bson_value_destroy(). yes. must. πŸ™ˆ
  • error β€” optional. a bson_error_t. it'll catch the drama if something goes wrong 😭

⭐ RETURNS ⭐

returns true if successful. returns false and sets error otherwise. that's it, that's the vibe check. πŸ’–

πŸ‘€ SEE ALSO

  • mongoc_client_encryption_datakey_opts_t

πŸŽ€ AUTHOR πŸŽ€

MongoDB, Inc β€” the legends themselves πŸ‘‘

2009-present, MongoDB, Inc.


ok that's the whole page bestie, go forth and create your datakeys fr fr πŸ¦‹πŸ’œ

libmongoc version 2.5.6, dated Oct 09, 2026 β€” mwah, stan this manpage, periodt. πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from