# AttachmentsApi.add()

```ts
add(name: string, bytes: Uint8Array, options?: SignedDocumentOptions): Promise<number>
```

Embed a file; it is in every save and export from then on. An index shifts down when an earlier attachment is deleted. Needs the `edit-pages` feature.

- Kind: method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `name` | `string` | The file name to store. |
| `bytes` | `Uint8Array` | The file's bytes. |
| `options?` | `SignedDocumentOptions` | `{ invalidateSignatures? }`. |

Returns `Promise<number>`: Its index in `list()` (zero-based: its position in the document's table), for `data()` / `delete()`.

Throws:

- `INVALID_ARGUMENT` — an empty `name`.
- `PAGE_ERROR` — the file could not be embedded.
- `FEATURE_NOT_LICENSED` — the license lacks `edit-pages`.
- `DOCUMENT_CLOSED` — the document has been closed.
- `INVALID_STATE` — a certified document, unless `options.invalidateSignatures`; or a progressive document still downloading.

```ts
const index = await doc.attachments.add('invoice.csv', csvBytes);
```

Part of [AttachmentsApi](https://kernstra.com/docs/web-sdk/api/doc-attachments) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/doc-attachments/add
