# Attachments

## List Attachments

`client.beta.attachments.list(AttachmentListParamsquery, RequestOptionsoptions?): PaginatedCursor<AttachmentListResponse>`

**get** `/api/v1/beta/attachments`

List the attachments associated with a file (e.g. per-page screenshots).

### Parameters

- `query: AttachmentListParams`

  - `source_id: string`

    File UUID or directory file ID (dfl-...).

  - `organization_id?: string | null`

  - `page_size?: number | null`

  - `page_token?: string | null`

  - `project_id?: string | null`

### Returns

- `AttachmentListResponse`

  Metadata for a single file attachment.

  - `name: string`

    Name of the attachment

  - `size: number`

    Size of the attachment in bytes

  - `last_modified?: string | null`

    When the attachment was last modified

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const attachmentListResponse of client.beta.attachments.list({
  source_id: 'source_id',
})) {
  console.log(attachmentListResponse.name);
}
```

#### Response

```json
{
  "items": [
    {
      "name": "name",
      "size": 0,
      "last_modified": "2019-12-27T18:11:19.117Z"
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```

## Get Attachment

`client.beta.attachments.get(stringattachmentName, AttachmentGetParamsquery, RequestOptionsoptions?): PresignedURL`

**get** `/api/v1/beta/attachments/{attachment_name}`

Return a presigned download URL for a specific attachment.

### Parameters

- `attachmentName: string`

- `query: AttachmentGetParams`

  - `source_id: string`

    File UUID or directory file ID (dfl-...).

  - `organization_id?: string | null`

  - `project_id?: string | null`

### Returns

- `PresignedURL`

  Schema for a presigned URL.

  - `expires_at: string`

    The time at which the presigned URL expires

  - `url: string`

    A presigned URL for IO operations against a private file

  - `form_fields?: Record<string, string> | null`

    Form fields for a presigned POST request

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const presignedURL = await client.beta.attachments.get('attachment_name', {
  source_id: 'source_id',
});

console.log(presignedURL.expires_at);
```

#### Response

```json
{
  "expires_at": "2019-12-27T18:11:19.117Z",
  "url": "https://example.com",
  "form_fields": {
    "foo": "string"
  }
}
```

## Domain Types

### Attachment List Response

- `AttachmentListResponse`

  Metadata for a single file attachment.

  - `name: string`

    Name of the attachment

  - `size: number`

    Size of the attachment in bytes

  - `last_modified?: string | null`

    When the attachment was last modified
