---
title: "How to add a document to a voucher"
description: "Guide on adding a document to a voucher and transferring it to file service using GraphQL mutations. Includes example queries and notes on limitations."
lang: en
languages:
  en: https://docs.vismasoftware.no/businessnxtapi/examples/howto/voucherdocument/index.md
lastmod: 2026-07-10
---

> Documentation index: https://docs.vismasoftware.no/businessnxtapi/examples/howto/llms.txt


# How to add a document to a voucher

Last modified July 10, 2026

> Guide on adding a document to a voucher and transferring it to file service using GraphQL mutations. Includes example queries and notes on limitations.


You can add a document to a voucher by running the the `AddNewDocument` processing on the `Voucher` table.

The following query adds a document to an existing voucher:

```graphql
mutation upload_voucher_document(
        $cid: Int!,
        $batchNo : Int!,
        $voucherNo: Int!,
        $fileName: String!,
        $description: String!,
        $data: String!)
{
  useCompany(no: $cid) {   
    voucher_processings {
      addNewDocument(
        filter: {_and:[
          {batchNo : {_eq : $batchNo}},
          {voucherNo : {_eq : $voucherNo}}
        ]},
      args: {
        fileName : $fileName,
        description : $description,
        fileBytes : $data
      })
      {
        succeeded        
      }
    }
  }
}
```

> [!NOTE]
>
> The content of the document must be provided as a base64 encoded string.

> [!NOTE]
>
> Beware there is a limit to the raw size of a request. Currently, this is set at 15MB. This limit may be prone to future changes.

## Transfering a document to the file service

Documents attached using the `Voucher.AddNewDocument` processing are stored in the database. If you want to transfer the document to the file service, you can use the `UploadToFileService` processing on the `IncomingAccountingDocumentAttachment` table, as shown in the following example:

```graphql
mutation move_attachment_to_fileservice(
   $cid: Int, 
   $fileName: String,
   $tok: String)
{
  useCompany(no: $cid)
  {
    incomingAccountingDocumentAttachment_processings
    {
      uploadToFileService(
        filter: {fileName: {_eq: $fileName}},
        args: {
          connectToken: $tok
        }
      )
      {
        succeeded
      }
    }
  }
}
```

The argument `connectToken` requires a valid Visma Connect access token. This is the same token you use to authenticate your requests to the Business NXT API.

You can execute these two processings sequentially, in a single request.

```graphql
mutation upload_voucher_document(
        $cid: Int!,
        $batchNo : Int!,
        $voucherNo: Int!,
        $fileName: String!,
        $description: String!,
        $data: String!,
        $tok: String)
{
  useCompany(no: $cid) {   
    voucher_processings {
      addNewDocument(
        filter: {_and:[
          {batchNo : {_eq : $batchNo}},
          {voucherNo : {_eq : $voucherNo}}
        ]},
      args: {
        fileName : $fileName,
        description : $description,
        fileBytes : $data
      })
      {
        succeeded        
      }
    }

    incomingAccountingDocumentAttachment_processings
    {
      uploadToFileService(
        filter: {fileName: {_eq: $fileName}},
        args: {
          connectToken: $tok
        }
      )
      {
        succeeded
      }
    }
  }
}
```

> [!NOTE]
>
> In the future, the `Voucher.AddNewDocument` processing may be updated to transfer the document to the file service directly without needing to execute the second processing explicitly.


---

[View this page](https://docs.vismasoftware.no/businessnxtapi/examples/howto/voucherdocument/)
