# DocumentsResource

Canonical page: https://docs.ovok.com/java-sdk/reference/documents-resource

```java
public final class DocumentsResource
```

Lists, uploads and links to the project's documents. Get it from [`Ovok.documents()`](/java-sdk/reference/ovok#documents).

## Methods [#methods]

### list [#list]

```java
public JsonNode list() throws IOException, InterruptedException
```

Lists documents (`GET /document`).

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

```java
public JsonNode list(Map<String, ?> parameters) throws IOException, InterruptedException
```

Lists documents (`GET /document?...`).

**Parameters:**

- `parameters`: query parameters added to the URL

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

```java
public JsonNode list(
        Map<String, ?> parameters,
        RequestOptions options) throws IOException, InterruptedException
```

Lists documents (`GET /document?...`).

**Parameters:**

- `parameters`: query parameters added to the URL
- `options`: per-request options, such as the timeout

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### createUpload [#createupload]

```java
public JsonNode createUpload(Object body) throws IOException, InterruptedException
```

Creates a document and its upload (`POST /document`).

**Parameters:**

- `body`: the document metadata, serialized as JSON

**Returns:** the created document with its upload details

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

```java
public JsonNode createUpload(
        Object body,
        RequestOptions options) throws IOException, InterruptedException
```

Creates a document and its upload (`POST /document`).

**Parameters:**

- `body`: the document metadata, serialized as JSON
- `options`: per-request options, such as the timeout

**Returns:** the created document with its upload details

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### replaceUpload [#replaceupload]

```java
public JsonNode replaceUpload(
        String documentId,
        Object body) throws IOException, InterruptedException
```

Starts a new upload that replaces a document's file (`POST /document/{documentId}`).

**Parameters:**

- `documentId`: the document id
- `body`: the upload metadata, serialized as JSON

**Returns:** the document with its upload details

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

```java
public JsonNode replaceUpload(
        String documentId,
        Object body,
        RequestOptions options) throws IOException, InterruptedException
```

Starts a new upload that replaces a document's file (`POST /document/{documentId}`).

**Parameters:**

- `documentId`: the document id
- `body`: the upload metadata, serialized as JSON
- `options`: per-request options, such as the timeout

**Returns:** the document with its upload details

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### updateMetadata [#updatemetadata]

```java
public JsonNode updateMetadata(
        String documentId,
        Object body) throws IOException, InterruptedException
```

Updates a document's metadata (`PATCH /document/{documentId}`).

**Parameters:**

- `documentId`: the document id
- `body`: the fields to change, serialized as JSON

**Returns:** the updated document

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

```java
public JsonNode updateMetadata(
        String documentId,
        Object body,
        RequestOptions options) throws IOException, InterruptedException
```

Updates a document's metadata (`PATCH /document/{documentId}`).

**Parameters:**

- `documentId`: the document id
- `body`: the fields to change, serialized as JSON
- `options`: per-request options, such as the timeout

**Returns:** the updated document

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### delete [#delete]

```java
public JsonNode delete(String documentId) throws IOException, InterruptedException
```

Deletes a document (`DELETE /document/{documentId}`).

**Parameters:**

- `documentId`: the document id

**Returns:** the response body, or `null` when it is empty

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

```java
public JsonNode delete(
        String documentId,
        RequestOptions options) throws IOException, InterruptedException
```

Deletes a document (`DELETE /document/{documentId}`).

**Parameters:**

- `documentId`: the document id
- `options`: per-request options, such as the timeout

**Returns:** the response body, or `null` when it is empty

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### downloadUrl [#downloadurl]

```java
public String downloadUrl(String documentId)
```

Builds the download URL of a document (`GET /document/{documentId}`); no request is sent.

**Parameters:**

- `documentId`: the document id

**Returns:** the absolute URL

```java
public String downloadUrl(String documentId, Map<String, ?> parameters)
```

Builds the download URL of a document (`GET /document/{documentId}?...`); no request is sent.

**Parameters:**

- `documentId`: the document id
- `parameters`: query parameters added to the URL

**Returns:** the absolute URL

### publicDownloadUrl [#publicdownloadurl]

```java
public String publicDownloadUrl(String publicToken)
```

Builds the public download URL for a share token (`GET /document/public/{publicToken}`); no request is sent.

**Parameters:**

- `publicToken`: the document's public share token

**Returns:** the absolute URL

```java
public String publicDownloadUrl(String publicToken, Map<String, ?> parameters)
```

Builds the public download URL for a share token (`GET /document/public/{publicToken}?...`); no request is sent.

**Parameters:**

- `publicToken`: the document's public share token
- `parameters`: query parameters added to the URL

**Returns:** the absolute URL
