Document and Document Version

Creating Document and Document Version

Document (Dokument) and Document Version (Dokumentversjon) entities are created using the POST /transaction operation. A Document (Dokument) entitiy can be created withouth corresponding Document Version (Dokumentversjon) entity, but this is a very specific use case, so the samples below represent the creation of both the entities and how the electronic document is associated to the newly created Document Version (Dokumentversjon) through the POST /upload operation.

Document (Dokument) entity should be linked to one of the Record (Registrering) types available.

Upload an electronic document

Uploading a document is done using the POST /upload operation. The file content is streamed in the API request and as a result the API returns a new unique identifier of this electronic document. The document is deleted from Documaster Archive in case it is not linked for a certain period of time to a DocumentVersion (Documentverjion) and from there to a Document (Dokument).

The ID of the electronic document is not the same ID as the one of the Document (Dokument) entity objects. Document (Dokument) entity object is metadata describing the document, while the ID returned as a result of this operation identfies the actually uploaded document.

      Request

POST https://<documaster-instance>.local.documaster.tech:8083/rms/api/public/noark5/v1/upload HTTP/1.1
...
Authorization: Bearer {{accessTokenIntegrator}}
Content-Disposition: attachment; filename="sample-document.pdf"; filename*=utf-8''sample-document.pdf
Content-Type: application/octet-stream

... binary file content ...

      Response

HTTP/1.1 200 OK
Content-Type: application/json

{
    "id":"999"
}

ID of the electronic document is extracted from $.id of the response.

Document (Dokument) and DocumentVersion (Dokumentversjion) are created using the POST /transaction operation. The electronic document ID, retrieved as the result of the POST /upload operation is used in the creation of the DocumentVersion(Dokumentversjion) through the field $.actions[?(@.action == 'save' && @.type=='Dokumentversjon')].fields.referanseDokumentfil, which is a field of DocumentVersion.

      Request

POST https://<documaster-instance>.local.documaster.tech:8083/rms/api/public/noark5/v1/transaction HTTP/1.1
...
Authorization: Bearer {{accessTokenIntegrator}}
Content-Type: application/json
X-Documaster-Error-Response-Type: application/json

{
    "actions": [
        {
            "action": "save",
            "type": "Dokument",
            "id": "dokument-temp-id-1",
            "fields": {
                "tittel": "sample-document.pdf",
                "tilknyttetRegistreringSom": "V"
            }
        },
        {
            "action": "link",
            "type": "Dokument",
            "id": "dokument-temp-id-1",
            "ref": "refRegistrering",
            "linkToId": "994"
        },
        {
            "action": "save",
            "type": "Dokumentversjon",
            "id": "dokumentversjon-temp-id-1",
            "fields": {
                "format": "pdf",
                "referanseDokumentfil": "1079",
                "variantformat": "P"
            }
        },
        {
            "action": "link",
            "type": "Dokumentversjon",
            "id": "dokumentversjon-temp-id-1",
            "ref": "refDokument",
            "linkToId": "dokument-temp-id-1"
        }
    ]
}

      Response

HTTP/1.1 200 OK
Content-Type: application/json

{
    "saved": {
        "dokument-temp-id-1": {
            "type": "Dokument",
            "id": "1081",
            "version": "7",
            "fields": {
                "uuid": "8775e127-29ad-48de-a549-7a0c75ab0bd2",
                "opprettetDato": "2021-11-25T14:58:35.242+0100",
                "opprettetAv": "External Integrator ACME",
                "opprettetAvBrukerIdent": "e6e6318e-fdcb-41cb-ae3a-1940f98ea153",
                "dokumentstatus": "B",
                "tittel": "sample-document.pdf",
                "dokumentmedium": "E",
                "tilknyttetRegistreringSom": "V",
                "dokumentnummer": 2
            },
            "links": {
                "refRegistrering": 994
            }
        },
        "dokumentversjon-temp-id-1": {
            "type": "Dokumentversjon",
            "id": "1082",
            "version": "5",
            "fields": {
                "uuid": "f20796a3-3550-4c87-85dd-36bc18cc65f7",
                "opprettetDato": "2021-11-25T14:58:35.250+0100",
                "opprettetAv": "External Integrator ACME",
                "opprettetAvBrukerIdent": "e6e6318e-fdcb-41cb-ae3a-1940f98ea153",
                "versjonsnummer": 1,
                "variantformat": "P",
                "format": "pdf",
                "kryptertDokument": false,
                "sjekksum": "59844ce7572b1411445179c25e4182e328e43391d733782828277f22e340166b",
                "sjekksumAlgoritme": "SHA-256",
                "filstoerrelse": 3191,
                "filnavn": "sample-document.pdf",
                "referanseDokumentfil": "1079",
                "innholdstype": "application/pdf"
            },
            "links": {
                "refDokument": 1081
            }
        }
    }
}