# Create Content Version Batch

Create content versions for a batch of files in Salesforce from Apex.

> Kind: Apex method · Updated: 2026-07-01

## Signature

```apex
global static void createContentVersionBatch(
  List<Types.CreateContentVersionBatchPayload> inputs,
  String runAs
)
```

### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| inputs | List&lt;<a href="#/apex-type-create-content-version-batch-payload">Types.CreateContentVersionBatchPayload</a>&gt; | required | List of Types.CreateContentVersionBatchPayload — one entry per file batch payload. |
| runAs | String | optional | Email ID of the user on whose behalf the function should run. Provide integrationUser to run as the automation user. For CloudFiles internal use only — it does not affect the content version or content document created by this action in Salesforce. |

## Return Type

void

## Example

```apex
cldfs.CreateContentVersionFlowInput file = new cldfs.CreateContentVersionFlowInput();
file.library = 'sharepoint'; //Library
file.driveId = 'b!nJBtPq_z5UeJtFrj_f24XEQqlPUD8vtFsg7GBcrXJepiUn9bkb_7QbDPtqHVD-cP'; //driveId
file.id = '01KEHAKUUSU3E5OUXBBJGLYTD3IZU4BCRV'; //fileId

List<cldfs.CreateContentVersionFlowInput> files = new List<cldfs.CreateContentVersionFlowInput>();
files.add(file);
String context = '{"recordId":"701dL00000WonvTQAR"}';
List<cldfs.Types.CreateContentVersionBatchPayload> inputs = new List<cldfs.Types.CreateContentVersionBatchPayload>{
    new cldfs.Types.CreateContentVersionBatchPayload(
        files,
        context
    )
};
cldfs.Client.createContentVersionBatch(inputs, 'integrationUser');
```

> **Testing** — Use ClientFactory with default mock values to get coverage without callouts. See How to get test coverage of code that uses Client methods.
