Skip to content
Docs
API 1.0.0 · 23 Nov 2026

Search the docs

    Română

    Retention

    How the keep-until date of a document follows from its date and its class, what archiving does and why nothing is deleted through the API.

    On this page

    The keep-until date, keepUntil, is the day a document is kept until: the end of the year of its date plus its class years.

    An archived invoice

    {
      "number": "DOC-2026-0395",
      "class": "invoice",
      "date": "2026-10-30",
      "status": "archived",
      "keepUntil": "2036-12-31"
    }

    Read the keep-until date

    Every document carries keepUntil, and getDocument and listDocuments return it. The years come from keepYears of the class, which you read with listClasses.

    ClassYears kept`keepUntil` for a document dated 2026-11-20
    contract102036-12-31
    invoice102036-12-31
    offer32029-12-31
    report52031-12-31

    The years are the policy of the company, set for each class in the product. The date follows date: when you change the date of a draft with updateProperties, keepUntil changes with it.

    What archiving does

    archiveDocument sets the status to archived. From then on nothing changes on the document: every change is refused with document_archived, and the keep-until date stays as it was.

    An invoice or a report is archived once it is approved. A contract or an offer is archived once it is signed. See Documents and versions.

    List the documents near their date

    Ask for archived documents whose keepUntil is on or before the day 90 days from today. For a request sent on 2026-11-23 that day is 2027-02-21.

    Archived documents that expire in the next 90 days

    curl

    curl "$RDC_BASE_URL/documents/v1/documents?status=archived&keepUntilBefore=2027-02-21" \
      -H "Authorization: Bearer $RDC_TOKEN"

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents?status=archived&keepUntilBefore=2027-02-21`, {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
      },
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'GET',
        f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents?status=archived&keepUntilBefore=2027-02-21',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents?status=archived&keepUntilBefore=2027-02-21');
    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#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/documents?status=archived&keepUntilBefore=2027-02-21");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    See Views and search for the answer and for paging through it.

    Import an archive

    importDocument files a document that was approved elsewhere straight into the archive. It is kept by the same rule, counted from the date on the document and not from the day you import it.

    curl

    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

    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

    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
    
    $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#

    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

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

    The invoice imported in the request above, dated 2018-04-12, is kept until 2028-12-31. It is archived at once and nothing changes on it afterwards.

    Nothing is deleted

    The API has no operation that deletes a document or a version, before its keep-until date or after it. An archived document stays until its keep-until date.