---
title: "Upload and classify | Docs | DMS by R&D Copilot"
description: "Create a draft from one file and a class, read the result and change its properties before it goes to approval."
canonical: "https://documents.rdcopilot.com/docs/guides/upload-and-classify/"
language: en
updated: 2026-11-23
---

# Upload and classify

Create a draft from one file and a class, read the result and change its properties before it goes to approval.

Send the file in base64 with the class and the properties of the document. The samples read `$RDC_BASE_URL` and `$RDC_TOKEN`; the [Quickstart](https://documents.rdcopilot.com/docs/get-started/quickstart/) shows both.

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

## Read the result

The answer says that the change was accepted. It carries the `documentId` and the `number` of the new document, here `DOC-2026-0403`. Keep both next to the file you sent.

Look the operation up with the `operationId` you sent. When `status` is `completed`, the document exists.

curl

```bash
curl "$RDC_BASE_URL/documents/v1/operations/8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/operations/8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246`, {
  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/operations/8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/operations/8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246');
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/operations/8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246");
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
{
  "operationId": "8d1f4c6b-2a37-4e90-b5d8-71c3e0a9f246",
  "status": "completed",
  "aggregateRevision": 1,
  "documentId": "ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6"
}
```

Then read the document with `getDocument`. A new document is a draft with `version` 1 and `revision` 1, and its `keepUntil` is already set: 2036-12-31.

Get the document

curl

```bash
curl "$RDC_BASE_URL/documents/v1/documents/ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6`, {
  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/ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6');
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/ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6");
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
{
  "id": "ba4d0edc-7dd5-41e9-82ab-0ed0b4c95fa6",
  "number": "DOC-2026-0403",
  "name": "Invoice MV-2026-03117",
  "class": "invoice",
  "counterpartyId": "365fcde1-a8f1-4abc-bff5-001cc36ad963",
  "counterparty": "Moara Vadului SRL",
  "project": "Purchasing",
  "owner": "sorin-avram",
  "date": "2026-11-20",
  "amount": "12502.17",
  "currency": "RON",
  "status": "draft",
  "version": 1,
  "returned": false,
  "keepUntil": "2036-12-31",
  "changedAt": "2026-11-23T07:12:00Z",
  "approval": {
    "route": [],
    "decisions": [],
    "next": null
  },
  "signature": null,
  "readers": {
    "groups": [
      "finance",
      "purchasing"
    ],
    "people": [
      "sorin-avram"
    ]
  },
  "revision": 1
}
```

## Choose the class

The `class` is one of `contract`, `invoice`, `offer` or `report`. It decides who approves the document, whether it is signed and how long it is kept. Read the same table from `listClasses`.

| Class | Approvers, in order | After approval | Kept |
| --- | --- | --- | --- |
| `contract` | ioana-marin up to 100000.00 RON; above it ioana-marin, then ana-rusu | Sent for signature, then archived | 10 years from the end of the year of its date |
| `invoice` | ioana-marin up to 25000.00 RON; above it ioana-marin, then ana-rusu | Archived | 10 years from the end of the year of its date |
| `offer` | ioana-marin up to 50000.00 RON; above it ioana-marin, then ana-rusu | Sent for signature, then archived | 3 years from the end of the year of its date |
| `report` | ana-rusu for every amount | Archived | 5 years from the end of the year of its date |

curl

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

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/classes?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/classes?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/classes?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/classes?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
{
  "items": [
    {
      "id": "contract",
      "signed": true,
      "keepYears": 10,
      "readers": [
        "finance",
        "sales",
        "purchasing"
      ],
      "approval": {
        "limit": "100000.00",
        "approvers": [
          "ioana-marin",
          "ana-rusu"
        ]
      }
    },
    {
      "id": "invoice",
      "signed": false,
      "keepYears": 10,
      "readers": [
        "finance",
        "purchasing"
      ],
      "approval": {
        "limit": "25000.00",
        "approvers": [
          "ioana-marin",
          "ana-rusu"
        ]
      }
    },
    {
      "id": "offer",
      "signed": true,
      "keepYears": 3,
      "readers": [
        "finance",
        "sales"
      ],
      "approval": {
        "limit": "50000.00",
        "approvers": [
          "ioana-marin",
          "ana-rusu"
        ]
      }
    },
    {
      "id": "report",
      "signed": false,
      "keepYears": 5,
      "readers": [
        "finance",
        "warehouse"
      ],
      "approval": {
        "limit": null,
        "approvers": [
          "ana-rusu"
        ]
      }
    }
  ],
  "nextCursor": null
}
```

A document of a class with a limit goes to the first approver when its amount is at most the limit, and to every approver above it. The keep-until date is the end of the year of the `date` on the document plus the years of its class. [Approvals](https://documents.rdcopilot.com/docs/guides/approvals/) and [Retention](https://documents.rdcopilot.com/docs/concepts/retention/) follow both rules.

## If the class is wrong

A draft cannot change its class: `updateProperties` has no `class` field. Create a new document with the right class and submit that one. The API has no delete, and a draft cannot be archived, so the first draft stays in the list as a draft.

Check the class before you send

The class chooses the approvers, the signature and the years of keeping. A wrong class sends the document to the wrong people and leaves a draft behind.

## Change the properties of a draft

While the document is a draft, `updateProperties` changes its name, counterparty, project, date and amount. Send only what changes, and the `revision` you read as `expectedRevision`.

curl

```bash
curl -X POST "$RDC_BASE_URL/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
  "expectedRevision": 1,
  "by": "sorin-avram",
  "name": "Transport agreement 2027, Transbistrița Logistic",
  "amount": "64500.00"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
    "expectedRevision": 1,
    "by": "sorin-avram",
    "name": "Transport agreement 2027, Transbistrița Logistic",
    "amount": "64500.00"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '66a3c447-ac92-4bec-8056-4be113f4de08',
        'expectedRevision': 1,
        'by': 'sorin-avram',
        'name': 'Transport agreement 2027, Transbistrița Logistic',
        'amount': '64500.00',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
  "expectedRevision": 1,
  "by": "sorin-avram",
  "name": "Transport agreement 2027, Transbistrița Logistic",
  "amount": "64500.00"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties');
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/417fc646-2924-483f-b1d7-b2c07692e924/properties");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
  "expectedRevision": 1,
  "by": "sorin-avram",
  "name": "Transport agreement 2027, Transbistrița Logistic",
  "amount": "64500.00"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
  "status": "accepted",
  "aggregateRevision": 2
}
```

A new file for the draft is a new version: send it with `reviseDocument`. The owner and the class stay as they were created.

## The file

| Field | Rule |
| --- | --- |
| `file.content` | The file in base64, up to 10 MiB before it is encoded. |
| `file.mediaType` | `application/pdf`, `image/png`, `image/jpeg` or `image/tiff`. |
| `file.name` | 1 to 200 characters. |
| `name` | The name of the document: 1 to 280 characters. |
| `date` | A real day in the form `YYYY-MM-DD`. |
| `amount` | A decimal string above zero with at most two decimals, in RON. |

## Send it again safely

Create the `operationId` before the first request and store it with the file. After a timeout, send the same request with the same `operationId`: the document is created once and the answer is the first one. See [Idempotency and concurrency](https://documents.rdcopilot.com/docs/reference/idempotency/).

| Code | Status | What to do |
| --- | --- | --- |
| `class_not_valid` | `422` | Send one of the four classes. Do not send the same body again. |
| `name_required` | `422` | Give the document a name within the length above. |
| `date_not_valid` | `422` | Send a real day as `YYYY-MM-DD`. |
| `amount_not_valid` | `422` | Send the amount as a decimal string with at most two decimals. |
| `counterparty_not_found` | `404` | Use the `counterpartyId` of a customer, a supplier or a carrier of your account. |
| `person_not_found` | `404` | Use the identifier of a person of your account as `owner`. |
| `invalid_request` | `400` | `fields` names each wrong field, such as `file.mediaType` or a file over 10 MiB. Correct it and send the request with a new `operationId`. |
| `operation_reused` | `409` | The `operationId` was used with another body. Send the first body again, or a new `operationId` for a new document. |
| `rate_limited` | `429` | Wait the seconds in `Retry-After`, then send the same request with the same `operationId`. |
| `unavailable` | `503` | Send the same request again with the same `operationId`. |

## Related pages

-   [Extract data](https://documents.rdcopilot.com/docs/guides/extract-data/): read and settle the values of an invoice.
-   [Approvals](https://documents.rdcopilot.com/docs/guides/approvals/): send the draft to its approvers.
-   [Classes and properties](https://documents.rdcopilot.com/docs/concepts/classes-and-properties/): the properties of each class.
-   [Documents and versions](https://documents.rdcopilot.com/docs/concepts/documents-and-versions/): how a document changes.
