# AttachmentsApi.data()

```ts
data(index: number): Promise<Uint8Array>
```

One attachment's bytes. Needs the `extract` feature.

- Kind: method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `index` | `number` | The attachment's index, as `list()` reports it. |

Returns `Promise<Uint8Array>`: The attachment's bytes.

Throws:

- `INVALID_ARGUMENT` — an `index` that names no attachment.
- `PAGE_ERROR` — the entry has no file stream, or the stream exceeds the SDK's size limit for an attachment.
- `FEATURE_NOT_LICENSED` — the license lacks `extract`.
- `DOCUMENT_CLOSED` — the document has been closed.

```ts
const [first] = await doc.attachments.list();
if (first) {
  const bytes = await doc.attachments.data(first.index);
  saveAs(new Blob([bytes.slice()]), first.name);
}
```

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/data
