# Create Attachments

Create one or more attachments from Apex, linking files or folders to Salesforce records.

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

## Signature

```apex
global static List<Attachment> createAttachments(
  List<Types.CreateAttachmentInput> attachmentInputs,
  String library,
  String runAs
)
```

### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| attachmentInputs | List&lt;<a href="#/apex-type-create-attachment-input">Types.CreateAttachmentInput</a>&gt; | required | One entry per attachment. See Types.CreateAttachmentInput. |
| library | String | required | Type of library. Example — sharepoint. You can get this value from the Content Library. |
| runAs | String | optional | Email Id of the user on whose behalf the function should run. To run the action as the automation user, supply integrationUser. |

## Return Type

List<Attachment&gt;

## Example

```apex
List<cldfs.Types.CreateAttachmentInput> inputs = new List<cldfs.Types.CreateAttachmentInput>{
    new cldfs.Types.CreateAttachmentInput(<folder id>, 'folder', <salesforce record id>, 'b!ZfA15HRS1Uy9pH3Vw5tFjAHfP1lRYlZAvDwLnHYYq8sa-L6ejXB-TJbMYUxi1QfL')
};
List<cldfs.Attachment> attachments = cldfs.Client.createAttachments(
   inputs,
  'sharepoint',
  'integrationUser'
);
```
