# Documents

Document service is at your service when managing documents

In this documentation when we reference to naviga.Document or Document we ha refering to [Naviga Doc Format](https://app.gitbook.com/@infomaker/s/document-format-v2/)

## Methods

## WriteDocument

<mark style="color:green;">`POST`</mark> `https://cca-{region}-saas-{enviroment}.infomaker.io/twirp/cca.Documents/WriteDocument`

WriteDocument is the method you would want to use when creating or updating documents.The method also contains functionality to handle optimistic locking. To use this you need to pass lockingMode and expectedRevision parameters.

#### Request Body

| Name             | Type            | Description                                                             |
| ---------------- | --------------- | ----------------------------------------------------------------------- |
| uploadId         | string          |                                                                         |
| unit             | string          |                                                                         |
| document         | naviga.Document |                                                                         |
| expectedRevision | string          | When lockingMode is used expected revision should also be posted        |
| lockingMode      | string          | Enum to enable certain locking mode when saving documents (See "Enums") |
| features         | cca.FeatureFlag |                                                                         |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## DeleteDocument

<mark style="color:green;">`POST`</mark> `https://cca-{region}-saas-{enviroment}.infomaker.io/twirp/cca.Documents/DeleteDocument`

DeleteDocument deletes a document from repository.

#### Request Body

| Name | Type   | Description                                     |
| ---- | ------ | ----------------------------------------------- |
| UUID | string | The UUID of the document that will be removed   |
| unit | string | Under which unit are you performing this action |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## GetDocument

<mark style="color:green;">`POST`</mark> `https://cca-{region}-saas-{enviroment}.infomaker.io/twirp/cca.Documents/GetDocument`

Get document retreives a document from content repo

#### Request Body

| Name    | Type   | Description   |
| ------- | ------ | ------------- |
| UUID    | string | Document UUID |
| version | int64  |               |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## DocumentExists

<mark style="color:green;">`POST`</mark> `https://cca-{region}-saas-{enviroment}.infomaker.io/twirp/cca.Documents/DocumentExists`

Method to check weather a document exists, Is cheaper to use than GetDocument

#### Request Body

| Name | Type   | Description                                     |
| ---- | ------ | ----------------------------------------------- |
| UUID | string | UUID of the document                            |
| unit | string | Under which unit are you performing this action |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

api-method-response endapi-method-response

## Enums

**cca.DownloadType** DownloadType can be passed as a parameter when downloading assets

```
TYPE_UNKNOWN
TYPE_ORIGINAL
TYPE_PRESENTATION
```

**cca.LockingMode** Locking mode is passed as a parameter when saving documents

```
NONE
OPTIMISTIC_LOCKING
PESSIMISTIC_LOCKING
```

**cca.ProcessingStatus**

```
UNKNOWN
IN_PROGRESS
DONE
ERROR
```
