> ## Documentation Index
> Fetch the complete documentation index at: https://docs.royaltyport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Statements

> List, retrieve, upload, download, and track statement processing with the SDK.

## list()

Returns a paginated list of statements for a project.

### Signature

```js theme={null}
royaltyport.statements.list(projectId, options?)
```

### Parameters

| Parameter         | Type     | Required | Default | Description               |
| ----------------- | -------- | -------- | ------- | ------------------------- |
| `projectId`       | `string` | Yes      | —       | The project ID            |
| `options.page`    | `number` | No       | `1`     | Page number               |
| `options.perPage` | `number` | No       | `20`    | Items per page (max: 100) |

### Example

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data } = await royaltyport.statements.list('project-id', {
  perPage: 50,
});

for (const statement of data.items) {
  console.log(`${statement.file_name} — ${statement.status}`);
}
```

***

## get()

Returns a single statement by ID.

### Signature

```js theme={null}
royaltyport.statements.get(projectId, statementId)
```

### Parameters

| Parameter     | Type     | Required | Description      |
| ------------- | -------- | -------- | ---------------- |
| `projectId`   | `string` | Yes      | The project ID   |
| `statementId` | `number` | Yes      | The statement ID |

### Example

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data: statement } = await royaltyport.statements.get('project-id', 456);

console.log(statement.file_name);
console.log('Status:', statement.status);
console.log('Currency:', statement.currency);
```

***

## upload()

Uploads a statement PDF to a project. The file is stored and queued for processing.

### Signature

```js theme={null}
royaltyport.statements.upload(projectId, file, options?)
```

### Parameters

| Parameter            | Type                                        | Required | Default                            | Description                                                         |
| -------------------- | ------------------------------------------- | -------- | ---------------------------------- | ------------------------------------------------------------------- |
| `projectId`          | `string`                                    | Yes      | —                                  | The project ID                                                      |
| `file`               | `Buffer`, `Uint8Array`, `Blob`, or `string` | Yes      | —                                  | The file to upload. Pass a file path as a string to read from disk. |
| `options.fileName`   | `string`                                    | No       | Inferred from path or `upload.pdf` | The file name                                                       |
| `options.fileType`   | `string`                                    | No       | `application/pdf`                  | MIME type                                                           |
| `options.onProgress` | `function`                                  | No       | —                                  | Upload progress callback                                            |

### Examples

**Upload from file path:**

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data } = await royaltyport.statements.upload('project-id', './statement.pdf');

console.log(`Staging ID: ${data.staging_id}`);
console.log(`Stage: ${data.staging_stage}`);
```

**Upload with progress tracking:**

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data } = await royaltyport.statements.upload('project-id', './statement.pdf', {
  onProgress: (event) => {
    console.log(`Upload progress: ${event.percent}%`);
  },
});
```

The `onProgress` callback receives an object with `bytesUploaded`, `bytesTotal`, and `percent` fields.

**Upload from Buffer:**

```js theme={null}
import { readFileSync } from 'node:fs';
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const buffer = readFileSync('./statement.pdf');

const { data } = await royaltyport.statements.upload('project-id', buffer, {
  fileName: 'Q4-2025-statement.pdf',
});
```

***

## download()

Returns a pre-signed download URL for a statement file.

### Signature

```js theme={null}
royaltyport.statements.download(projectId, statementId)
```

### Parameters

| Parameter     | Type     | Required | Description      |
| ------------- | -------- | -------- | ---------------- |
| `projectId`   | `string` | Yes      | The project ID   |
| `statementId` | `number` | Yes      | The statement ID |

### Example

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data } = await royaltyport.statements.download('project-id', 456);

console.log('Download URL:', data.url);
console.log('Expires:', data.expires_at);
```

***

## processes()

Returns the processing status for a statement, including staging and processing progress.

### Signature

```js theme={null}
royaltyport.statements.processes(projectId, statementId)
```

### Parameters

| Parameter     | Type     | Required | Description      |
| ------------- | -------- | -------- | ---------------- |
| `projectId`   | `string` | Yes      | The project ID   |
| `statementId` | `number` | Yes      | The statement ID |

### Example

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data: status } = await royaltyport.statements.processes('project-id', 456);

console.log('Staging done:', status.staging_done);
console.log('Processing done:', status.processing_done);
console.log('Stage:', status.staging_processes.stage);
```
