---
name: "mongoc_bulk_operation_execute"
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_bulk_operation_execute"
---

# mongoc\_bulk\_operation\_execute(3)

## SYNOPSIS

```
uint32_t
mongoc_bulk_operation_execute (mongoc_bulk_operation_t *bulk,
                               bson_t *reply,
                               bson_error_t *error);
```

This function executes all operations queued into the bulk operation. Unless **ordered: false** was specified in the **opts** passed to *mongoc\_collection\_create\_bulk\_operation\_with\_opts()*, then forward progress will be stopped upon the first error.

It is only valid to call *mongoc\_bulk\_operation\_execute()* once. The **mongoc\_bulk\_operation\_t** must be destroyed afterwards.

**WARNING:**

**reply** is always initialized, even upon failure. Callers *must* call *bson\_destroy()* to release this potential allocation.

## PARAMETERS

- •

  **bulk**: A *mongoc\_bulk\_operation\_t*.

- •

  **reply**: A maybe-**NULL** pointer to *overwritable storage* for a *bson\_t* to contain the results.

- •

  **error**: An optional location for a *bson\_error\_t* or **NULL**.

## ERRORS

Errors are propagated via the **error** parameter.

## RETURNS

On success, returns the server id used. On failure, returns 0 and sets **error**.

A write concern timeout or write concern error is considered a failure.

The **reply** document counts operations and collects error information. See *Bulk Write Operations* for examples.

**SEE ALSO:**

```
Bulk Write Operations
```

```
mongoc_bulk_operation_get_server_id(), which gets the id of the server used even if the operation failed.
```

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
