---
name: "mongoc_client_enable_auto_encryption"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_client_enable_auto_encryption"
---

# mongoc\_client\_enable\_auto\_encryption(3)

## SYNOPSIS

```
bool
mongoc_client_enable_auto_encryption (mongoc_client_t *client,
                                      mongoc_auto_encryption_opts_t* opts,
                                      bson_error_t* error);
```

Enable automatic In-Use Encryption on a *mongoc\_client\_t*. Requires libmongoc to be built with support for In-Use Encryption. See *In-Use Encryption* for instructions to enable In-Use Encryption in libmongoc.

Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automatic encryption is not supported for operations on a database or view, and operations that are not bypassed will result in error. To bypass automatic encryption for all operations, bypass automatic encryption with *mongoc\_auto\_encryption\_opts\_set\_bypass\_auto\_encryption()* in **opts**.

Automatic encryption requires the authenticated user to have the *listCollections privilege action*.

Enabling automatic encryption reduces the maximum message size and may have a negative performance impact.

Only applies to a single-threaded *mongoc\_client\_t*. To use with client pools, see *mongoc\_client\_pool\_enable\_auto\_encryption()*.

## PARAMETERS

- •

  **client**: A *mongoc\_client\_t*.

- •

  **opts**: A required *mongoc\_auto\_encryption\_opts\_t*.

- •

  **error**: A *bson\_error\_t* which is set on error.

## RETURNS

True on success. False on error. On error, **error** is set.

**SEE ALSO:**

```
mongoc_auto_encryption_opts_t
```

```
mongoc_client_pool_enable_auto_encryption()
```

```
In-Use Encryption for libmongoc
```

```
The MongoDB Manual for Client-Side Field Level Encryption
```

```
The MongoDB Manual for Queryable Encryption
```

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
