---
title: "Documents | Docs | DMS by R&D Copilot"
description: "Create a document from a file, read it, revise it, archive it, import an archive and read the versions."
canonical: "https://documents.rdcopilot.com/docs/api-reference/documents/"
language: en
updated: 2026-11-23
---

# Documents

Create a document from a file, read it, revise it, archive it, import an archive and read the versions.

## List documents

GET `/documents/v1/documents`

Returns documents in pages, the most recently changed first. The filters combine: a document must match every one you send.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `class` | query | `string` | Nooptional | Only documents of this class. One of `contract`, `invoice`, `offer`, `report` |
| `status` | query | `string` | Nooptional | Only documents in this status. One of `draft`, `in-review`, `approved`, `signed`, `archived` |
| `counterpartyId` | query | `string (uuid)` | Nooptional | Only documents with this counterparty. |
| `owner` | query | `string` | Nooptional | Only the documents of this owner. |
| `awaitingApprover` | query | `string` | Nooptional | Only documents in review that wait for this approver to decide. |
| `keepUntilBefore` | query | `string (date)` | Nooptional | Only documents whose keep-until date is on or before this day. |
| `limit` | query | `integer` | Nooptional | Records per page. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of records. | `DocumentPage` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/documents/v1/documents?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents?limit=20`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents?limit=20');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "items": [
    {
      "id": "af784fd4-dcdb-4ac4-9e0a-3f59571d40c9",
      "number": "DOC-2026-0401",
      "name": "Invoice BO-2026-0733",
      "class": "invoice",
      "counterpartyId": "f8888efb-9a9e-4556-82a4-687b8880629f",
      "counterparty": "Brânzeturi Obcina SRL",
      "project": "Purchasing",
      "owner": "sorin-avram",
      "date": "2026-11-19",
      "amount": "18940.50",
      "currency": "RON",
      "status": "in-review",
      "version": 1,
      "returned": false,
      "keepUntil": "2036-12-31",
      "changedAt": "2026-11-19T07:51:00Z",
      "approval": {
        "route": [
          "ioana-marin"
        ],
        "decisions": [],
        "next": "ioana-marin"
      },
      "signature": null,
      "readers": {
        "groups": [
          "finance",
          "purchasing"
        ],
        "people": [
          "sorin-avram",
          "ioana-marin"
        ]
      },
      "revision": 2
    },
    {
      "id": "c4619fe2-a7f9-49d9-98f7-46a02d5c39c3",
      "number": "DOC-2026-0400",
      "name": "Invoice AC-2026-0911",
      "class": "invoice",
      "counterpartyId": "a1f13366-0199-4955-9251-6bd2703ce5cf",
      "counterparty": "Ambalaje Carpatin SRL",
      "project": "Purchasing",
      "owner": "sorin-avram",
      "date": "2026-11-18",
      "amount": "34862.00",
      "currency": "RON",
      "status": "in-review",
      "version": 1,
      "returned": false,
      "keepUntil": "2036-12-31",
      "changedAt": "2026-11-20T09:40:00Z",
      "approval": {
        "route": [
          "ioana-marin",
          "ana-rusu"
        ],
        "decisions": [
          {
            "approver": "ioana-marin",
            "decision": "approved",
            "time": "2026-11-20T09:40:00Z"
          }
        ],
        "next": "ana-rusu"
      },
      "signature": null,
      "readers": {
        "groups": [
          "finance",
          "purchasing"
        ],
        "people": [
          "sorin-avram",
          "ioana-marin",
          "ana-rusu"
        ]
      },
      "revision": 3
    },
    {
      "id": "472fda2c-c118-43fc-80a9-5a708911c856",
      "number": "DOC-2026-0398",
      "name": "Framework sales agreement 2027",
      "class": "contract",
      "counterpartyId": "6617426f-8893-403d-8266-5582b7c3ba29",
      "counterparty": "Hanul Ozana SRL",
      "project": "Customer agreements 2027",
      "owner": "andrei-pop",
      "date": "2026-11-12",
      "amount": "84000.00",
      "currency": "RON",
      "status": "approved",
      "version": 2,
      "returned": false,
      "keepUntil": "2036-12-31",
      "changedAt": "2026-11-20T10:05:00Z",
      "approval": {
        "route": [
          "ioana-marin"
        ],
        "decisions": [
          {
            "approver": "ioana-marin",
            "decision": "approved",
            "time": "2026-11-17T11:20:00Z"
          }
        ],
        "next": null
      },
      "signature": {
        "id": "e4dd8cf2-2e3f-4179-a4fc-2eac1f3ae3bc",
        "state": "open",
        "sentAt": "2026-11-20T10:00:00Z",
        "sentBy": "andrei-pop",
        "recipients": [
          {
            "id": "ana-rusu",
            "state": "signed",
            "time": "2026-11-20T10:05:00Z"
          },
          {
            "id": "mircea-balan",
            "state": "delivered",
            "time": "2026-11-20T10:02:00Z"
          },
          {
            "id": "carmen-diaconu",
            "state": "sent",
            "time": "2026-11-20T10:00:00Z"
          }
        ]
      },
      "readers": {
        "groups": [
          "finance",
          "sales",
          "purchasing"
        ],
        "people": [
          "andrei-pop",
          "ioana-marin",
          "ana-rusu"
        ]
      },
      "revision": 8
    }
  ],
  "nextCursor": null
}
```

## Create a document

POST `/documents/v1/documents`

Creates a draft from a file. With `extract` true, an invoice is read and its values are returned by `getExtraction`. The answer is the operation result with the identifier and the number of the document.

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `class` | `string` | Yesrequired | The class of the document. One of `contract`, `invoice`, `offer`, `report` |
| `name` | `string` | Yesrequired | The name of the document. |
| `counterpartyId` | `string (uuid)` | Nooptional | The customer, supplier or carrier the document is with. |
| `project` | `string` | Nooptional | The project the document belongs to. |
| `date` | `string (date)` | Yesrequired | The date on the document, `YYYY-MM-DD`. The keep-until date counts from the end of its year. |
| `amount` | `string` | Nooptional | The gross amount as a decimal string, in RON. A class that is routed by amount needs one before it is submitted. |
| `owner` | `string` | Yesrequired | Identifier of the person who owns the document. |
| `extract` | `boolean` | Nooptional | True to read the values of an invoice. Only a document of class `invoice` is read. Default `false` |
| `file` | `object` | Yesrequired | The file, in the request. A request carries up to 10 MiB. |
| `file.name` | `string` | Yesrequired | The name of the file. |
| `file.mediaType` | `string` | Yesrequired | The media type of the file: `application/pdf`, `image/png`, `image/jpeg` or `image/tiff`. One of `application/pdf`, `image/png`, `image/jpeg`, `image/tiff` |
| `file.content` | `string` | Yesrequired | The content of the file in base64. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `DocumentOperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `counterparty_not_found` or `person_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `class_not_valid`, `name_required`, `date_not_valid` or `amount_not_valid`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/documents/v1/documents" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246",
  "class": "invoice",
  "name": "Invoice MV-2026-03117",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "project": "Purchasing",
  "date": "2026-11-20",
  "amount": "12502.17",
  "owner": "sorin-avram",
  "extract": true,
  "file": {
    "name": "MV-2026-03117.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246",
    "class": "invoice",
    "name": "Invoice MV-2026-03117",
    "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
    "project": "Purchasing",
    "date": "2026-11-20",
    "amount": "12502.17",
    "owner": "sorin-avram",
    "extract": true,
    "file": {
      "name": "MV-2026-03117.pdf",
      "mediaType": "application/pdf",
      "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
    }
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246',
        'class': 'invoice',
        'name': 'Invoice MV-2026-03117',
        'counterpartyId': '365fcde1-a8f1-4abc-bff5-001cc36ad963',
        'project': 'Purchasing',
        'date': '2026-11-20',
        'amount': '12502.17',
        'owner': 'sorin-avram',
        'extract': True,
        'file': {
            'name': 'MV-2026-03117.pdf',
            'mediaType': 'application/pdf',
            'content': 'JVBERi0xLjcKJeLjz9MKJSVFT0YK',
        },
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246",
  "class": "invoice",
  "name": "Invoice MV-2026-03117",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "project": "Purchasing",
  "date": "2026-11-20",
  "amount": "12502.17",
  "owner": "sorin-avram",
  "extract": true,
  "file": {
    "name": "MV-2026-03117.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246",
  "class": "invoice",
  "name": "Invoice MV-2026-03117",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "project": "Purchasing",
  "date": "2026-11-20",
  "amount": "12502.17",
  "owner": "sorin-avram",
  "extract": true,
  "file": {
    "name": "MV-2026-03117.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246",
  "status": "accepted",
  "aggregateRevision": 1,
  "documentId": "ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6",
  "number": "DOC-2026-0403"
}
```

## Import a document into the archive

POST `/documents/v1/imports`

Files a document that was approved elsewhere straight into the archive. It is kept by the rule of its class from the date on it, and nothing changes on it afterwards.

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `class` | `string` | Yesrequired | The class of the document. One of `contract`, `invoice`, `offer`, `report` |
| `name` | `string` | Yesrequired | The name of the document. |
| `counterpartyId` | `string (uuid)` | Nooptional | The customer, supplier or carrier the document is with. |
| `project` | `string` | Nooptional | The project the document belongs to. |
| `date` | `string (date)` | Yesrequired | The date on the document, `YYYY-MM-DD`. The keep-until date counts from the end of its year. |
| `amount` | `string` | Nooptional | The gross amount as a decimal string, in RON. A class that is routed by amount needs one before it is submitted. |
| `owner` | `string` | Yesrequired | Identifier of the person who answers for the document. |
| `file` | `object` | Yesrequired | The file, in the request. A request carries up to 10 MiB. |
| `file.name` | `string` | Yesrequired | The name of the file. |
| `file.mediaType` | `string` | Yesrequired | The media type of the file: `application/pdf`, `image/png`, `image/jpeg` or `image/tiff`. One of `application/pdf`, `image/png`, `image/jpeg`, `image/tiff` |
| `file.content` | `string` | Yesrequired | The content of the file in base64. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `DocumentOperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `counterparty_not_found` or `person_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `class_not_valid`, `name_required`, `date_not_valid` or `amount_not_valid`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/documents/v1/imports" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "df39276c-f803-47ea-acae-b3af65ffc67c",
  "class": "invoice",
  "name": "Invoice MV-2018-0311",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "project": "Imported archive",
  "date": "2018-04-12",
  "amount": "4310.50",
  "owner": "ioana-marin",
  "file": {
    "name": "MV-2018-0311.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/imports`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "df39276c-f803-47ea-acae-b3af65ffc67c",
    "class": "invoice",
    "name": "Invoice MV-2018-0311",
    "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
    "project": "Imported archive",
    "date": "2018-04-12",
    "amount": "4310.50",
    "owner": "ioana-marin",
    "file": {
      "name": "MV-2018-0311.pdf",
      "mediaType": "application/pdf",
      "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
    }
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/imports',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'df39276c-f803-47ea-acae-b3af65ffc67c',
        'class': 'invoice',
        'name': 'Invoice MV-2018-0311',
        'counterpartyId': '365fcde1-a8f1-4abc-bff5-001cc36ad963',
        'project': 'Imported archive',
        'date': '2018-04-12',
        'amount': '4310.50',
        'owner': 'ioana-marin',
        'file': {
            'name': 'MV-2018-0311.pdf',
            'mediaType': 'application/pdf',
            'content': 'JVBERi0xLjcKJeLjz9MKJSVFT0YK',
        },
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "df39276c-f803-47ea-acae-b3af65ffc67c",
  "class": "invoice",
  "name": "Invoice MV-2018-0311",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "project": "Imported archive",
  "date": "2018-04-12",
  "amount": "4310.50",
  "owner": "ioana-marin",
  "file": {
    "name": "MV-2018-0311.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/imports');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/imports");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "df39276c-f803-47ea-acae-b3af65ffc67c",
  "class": "invoice",
  "name": "Invoice MV-2018-0311",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "project": "Imported archive",
  "date": "2018-04-12",
  "amount": "4310.50",
  "owner": "ioana-marin",
  "file": {
    "name": "MV-2018-0311.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "df39276c-f803-47ea-acae-b3af65ffc67c",
  "status": "accepted",
  "aggregateRevision": 1,
  "documentId": "ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6",
  "number": "DOC-2026-0403"
}
```

## Get a document

GET `/documents/v1/documents/{documentId}`

Returns the document at its current revision, with its approval and its signature request.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `documentId` | path | `string (uuid)` | Yesrequired | The document. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | The record at its current revision. | `Document` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `document_not_found`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/documents/v1/documents/af784fd4-dcdb-4ac4-9e0a-3f59571d40c9" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/af784fd4-dcdb-4ac4-9e0a-3f59571d40c9`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents/af784fd4-dcdb-4ac4-9e0a-3f59571d40c9',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/af784fd4-dcdb-4ac4-9e0a-3f59571d40c9');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents/af784fd4-dcdb-4ac4-9e0a-3f59571d40c9");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "id": "af784fd4-dcdb-4ac4-9e0a-3f59571d40c9",
  "number": "DOC-2026-0401",
  "name": "Invoice BO-2026-0733",
  "class": "invoice",
  "counterpartyId": "f8888efb-9a9e-4556-82a4-687b8880629f",
  "counterparty": "Brânzeturi Obcina SRL",
  "project": "Purchasing",
  "owner": "sorin-avram",
  "date": "2026-11-19",
  "amount": "18940.50",
  "currency": "RON",
  "status": "in-review",
  "version": 1,
  "returned": false,
  "keepUntil": "2036-12-31",
  "changedAt": "2026-11-19T07:51:00Z",
  "approval": {
    "route": [
      "ioana-marin"
    ],
    "decisions": [],
    "next": "ioana-marin"
  },
  "signature": null,
  "readers": {
    "groups": [
      "finance",
      "purchasing"
    ],
    "people": [
      "sorin-avram",
      "ioana-marin"
    ]
  },
  "revision": 2
}
```

## List versions

GET `/documents/v1/documents/{documentId}/versions`

Returns the versions of a document, the newest first.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `documentId` | path | `string (uuid)` | Yesrequired | The document. |
| `limit` | query | `integer` | Nooptional | Records per page. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of records. | `VersionPage` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `document_not_found`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/documents/v1/documents/472fda2c-c118-43fc-80a9-5a708911c856/versions?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/472fda2c-c118-43fc-80a9-5a708911c856/versions?limit=20`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents/472fda2c-c118-43fc-80a9-5a708911c856/versions?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/472fda2c-c118-43fc-80a9-5a708911c856/versions?limit=20');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents/472fda2c-c118-43fc-80a9-5a708911c856/versions?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "items": [
    {
      "n": 2,
      "time": "2026-11-13T09:10:00Z",
      "by": "andrei-pop",
      "note": "Delivery days added."
    },
    {
      "n": 1,
      "time": "2026-11-12T08:30:00Z",
      "by": "andrei-pop"
    }
  ],
  "nextCursor": null
}
```

## Revise a draft

POST `/documents/v1/documents/{documentId}/revise`

Adds a version to a draft. A document that an approver returned is revised before it is submitted again.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `documentId` | path | `string (uuid)` | Yesrequired | The document. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the document you read. |
| `by` | `string` | Yesrequired | Who makes the new version. |
| `note` | `string` | Nooptional | What changed. |
| `file` | `object` | Yesrequired | The file, in the request. A request carries up to 10 MiB. |
| `file.name` | `string` | Yesrequired | The name of the file. |
| `file.mediaType` | `string` | Yesrequired | The media type of the file: `application/pdf`, `image/png`, `image/jpeg` or `image/tiff`. One of `application/pdf`, `image/png`, `image/jpeg`, `image/tiff` |
| `file.content` | `string` | Yesrequired | The content of the file in base64. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `document_not_found` or `person_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `document_archived`, `revision_conflict`, `operation_reused` or `document_not_draft`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/documents/v1/documents/7e9127fe-ec9e-4863-baf0-4ca4177acc75/revise" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "45e4eb70-7f6e-4690-a7e9-f31d188116a4",
  "expectedRevision": 3,
  "by": "mihai-stan",
  "note": "Differences by aisle added.",
  "file": {
    "name": "stock-count-october-2026-v2.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/7e9127fe-ec9e-4863-baf0-4ca4177acc75/revise`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "45e4eb70-7f6e-4690-a7e9-f31d188116a4",
    "expectedRevision": 3,
    "by": "mihai-stan",
    "note": "Differences by aisle added.",
    "file": {
      "name": "stock-count-october-2026-v2.pdf",
      "mediaType": "application/pdf",
      "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
    }
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents/7e9127fe-ec9e-4863-baf0-4ca4177acc75/revise',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '45e4eb70-7f6e-4690-a7e9-f31d188116a4',
        'expectedRevision': 3,
        'by': 'mihai-stan',
        'note': 'Differences by aisle added.',
        'file': {
            'name': 'stock-count-october-2026-v2.pdf',
            'mediaType': 'application/pdf',
            'content': 'JVBERi0xLjcKJeLjz9MKJSVFT0YK',
        },
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "45e4eb70-7f6e-4690-a7e9-f31d188116a4",
  "expectedRevision": 3,
  "by": "mihai-stan",
  "note": "Differences by aisle added.",
  "file": {
    "name": "stock-count-october-2026-v2.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/7e9127fe-ec9e-4863-baf0-4ca4177acc75/revise');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents/7e9127fe-ec9e-4863-baf0-4ca4177acc75/revise");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "45e4eb70-7f6e-4690-a7e9-f31d188116a4",
  "expectedRevision": 3,
  "by": "mihai-stan",
  "note": "Differences by aisle added.",
  "file": {
    "name": "stock-count-october-2026-v2.pdf",
    "mediaType": "application/pdf",
    "content": "JVBERi0xLjcKJeLjz9MKJSVFT0YK"
  }
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "45e4eb70-7f6e-4690-a7e9-f31d188116a4",
  "status": "accepted",
  "aggregateRevision": 4
}
```

## Archive a document

POST `/documents/v1/documents/{documentId}/archive`

Archives an approved invoice or report, or a signed contract or offer. Nothing changes on an archived document, and its keep-until date is the rule of its class applied to the date on it.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `documentId` | path | `string (uuid)` | Yesrequired | The document. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the document you read. |
| `by` | `string` | Yesrequired | Who archives the document. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `document_not_found` or `person_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `document_archived`, `revision_conflict`, `operation_reused`, `signature_required` or `document_not_final`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/documents/v1/documents/1ac68de2-2c38-4777-8300-64463eb461b3/archive" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "a2fff411-d74b-45a7-a967-98b1b163ade5",
  "expectedRevision": 8,
  "by": "ioana-marin"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/1ac68de2-2c38-4777-8300-64463eb461b3/archive`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "a2fff411-d74b-45a7-a967-98b1b163ade5",
    "expectedRevision": 8,
    "by": "ioana-marin"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents/1ac68de2-2c38-4777-8300-64463eb461b3/archive',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'a2fff411-d74b-45a7-a967-98b1b163ade5',
        'expectedRevision': 8,
        'by': 'ioana-marin',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "a2fff411-d74b-45a7-a967-98b1b163ade5",
  "expectedRevision": 8,
  "by": "ioana-marin"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/1ac68de2-2c38-4777-8300-64463eb461b3/archive');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents/1ac68de2-2c38-4777-8300-64463eb461b3/archive");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "a2fff411-d74b-45a7-a967-98b1b163ade5",
  "expectedRevision": 8,
  "by": "ioana-marin"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "a2fff411-d74b-45a7-a967-98b1b163ade5",
  "status": "accepted",
  "aggregateRevision": 9
}
```
