This feature is currently under development and, although not available in the current version, its preliminary documentation is provided to give you a preview of the enhancements that will be included in an upcoming update.

HTTP Operation Type Object DTO Why-DTOs?
(Query) files EntityFile

Description

The Files query returns a list of information about files previously uploaded using the uploadFileToEntity mutation, or generated/uploaded directly from Sage Active.
For each file, details such as fileName, mimeType, uploadDate, size, and related entity information are provided.
It supports advanced filtering, sorting, and pagination on fields such as entityType, entityId, businessDate, and fileName.

This query is useful for multiple scenarios:

  • Retrieving all document records linked to business entities (e.g., all invoices attached to an accounting entry)
  • Retrieving information about a specific file by its id (to check metadata or availability)
  • Checking whether an uploaded file has been fully processed and is safe to use (via id filter, useful right after an upload)
  • Listing files generated by an filesExport request

As each uploaded file undergoes an antivirus scan, the query response normally includes only processed and safe files.

  • Files that are still being processed (pending upload submission or antivirus scan results) or that have been rejected as infected are excluded from the response.
  • Exception: when filtering explicitly by id, the query may also return files that are still being processed, allowing you to check the status of a recently uploaded file.

If explicitly requested, each file entry can include short-lived access paths:

  • downloadPath: a temporary relative path to download the file.
  • previewPath: a temporary relative path to preview the file content in a browser.

These short paths are valid only for a limited time and should be used promptly after retrieval.

img

img

Filtering

The query supports the following filtering options:

Filtering Restrictions

Due to technical constraints, the query only supports a limited and controlled set of filtering options.
Any unsupported combination may result in errors or ignored filters.

Supported Filters
  Field Operators Allowed Notes
entityType eq, in Use in to match up to 10 values. Values are treated as OR.
entityId eq, in Use in to match up to 10 IDs. Values are treated as OR.
businessDate gte, gt, lte Date range filters supported
uploadDate gte, gt, lte Date range filters supported
fileName contains Case-insensitive partial match
type eq, in Use in to match up to 10 types. Values are treated as OR.
id eq Filter by file ID, typically used to check the status of an upload process
filesExport eq Boolean filter. When true, returns only files generated by filesExport.
Not Supported

Ordering

The query supports ordering results in ASC or DESC order for the following fields:

Ordering Restrictions

Due to technical constraints, only a limited and controlled set of orderings are supported.

Supported Orderings
  Field Directions Allowed Notes
businessDate ASC, DESC Orders by the file’s business date
Not Supported

Pagination

The query supports cursor-based pagination using the first argument.

Pagination Restrictions
Supported Pagination
  Argument Values Allowed Notes
first 1500 The maximum value accepted is 500.
When the requested pagination value is greater than or equal to 100, results are returned in chunks of 100.
Not Supported


graphQL Query
query {
  files(
    order: { businessDate: DESC },
    where: {
        entityType: { eq: ACCOUNTING_ENTRY }
        entityId: { eq: "8b21a143-4d9c-41ea-b1dc-1cf9d91a72f1" }
        businessDate: { gte: "2024-01-01" }
        businessDate: { lte: "2025-04-30" }
        fileName: { contains: "invoice" }
        type: { eq: "pdf" }
    },
    first: 10
  ) {
    edges {
      node {
        id
        fileName
        type
        mimeType
        size
        businessDate
        comment
        uploadDate
        entityType
        entityId
        downloadPath
        previewPath
      }
    }
  }
}
Example Response
{
  "data": {
    "files": {
      "edges": [
        {
          "node": {
            "id": "98f7adc7dd104cd984f9c113ef9a8e54.pdf",
            "fileName": "invoice-q1.pdf",
            "type": "pdf",
            "mimeType": "application/pdf",
            "size": 2497741,
            "businessDate": "2025-04-04T00:00:00Z",
            "comment": "Invoice for Q1",
            "uploadDate": "2025-04-04T08:12:43Z",
            "entityType": "ACCOUNTING_ENTRY",
            "entityId": "8b21a143-4d9c-41ea-b1dc-1cf9d91a72f1",
            "downloadPath": "/files/LqTJRFny",
            "previewPath": "/files/pR4mGwVe",
          }
        }
      ]
    }
  }
}
graphQL Query
query {
  files(
    order: { uploadDate: DESC },
    where: {
      filesExport: { eq: true }
    }
  ) {
    edges {
      node {
        id
        fileName
        type  
        mimeType
        size
        uploadDate
        downloadPath
        previewPath
        filesExport
      }
    }
  }
}
Example Response
{
  "data": {
    "files": {
      "edges": [
        {
          "node": {
            "id": "d2c33b7f-4c89-4e21-9f6e-1a75a1f4f8aa.csv",
            "fileName": "index.csv",
            "type": "csv",
            "mimeType": "text/csv",
            "size": 1842,
            "uploadDate": "2025-09-15T10:05:23Z",
            "downloadPath": "/files/LqTJRFny",
            "previewPath": "/files/aZ3kTyPq",
            "filesExport": true
          }
        },
        {
          "node": {
            "id": "7a5b91d2-8e72-4d3a-92ac-3dbcf76f3214.zip",
            "fileName": "archives.zip",
            "type": "zip",
            "mimeType": "application/zip",
            "size": 6543210,
            "uploadDate": "2025-09-15T10:05:24Z",
            "downloadPath": "/files/M8rNfVxJ",
            "previewPath": "/files/pR4mGwVe",
            "filesExport": true
          }
        }
      ]
    }
  }
}
Key Value
Authorization Bearer Current access Token How to find?
X-TenantId Current tenant id How to find?
X-OrganizationId Current organization Id How to find?
x-api-key Primary or secondary subscription key of your app How to find?

files

Fields Type Description Length
id String File ID  
uploadDate DateTime Date and time when the file was uploaded  
       
fileName String Name of the uploaded file 255
type String File extension (e.g., pdf, jpg, xml) 10
mimeType String MIME type of the file (e.g., application/pdf) 100
size Int File size in bytes  
       
businessDate DateTime Business-relevant date associated with the file  
comment String Optional comment or description 500
       
entityType
  • CUSTOMER
  • SUPPLIER
  • EMPLOYEE
  • PRODUCT
  • ACCOUNTING_ENTRY
  • PURCHASE_INVOICE
  • ORGANIZATION
Type of entity the file is linked to  
entityId UUID ID of the record in the related entity  
filesExport Boolean Indicates whether the file originates from filesExport  
downloadPath String Temporary relative short path to download the file. 255
previewPath String Temporary relative short path to preview the file. 255
Info
  • downloadPath: A temporary relative short path to download the file.
    • Example: /files/LqTJRFny
    • It is valid for 10 minutes.
    • The GraphQL query returns only metadata and the link, not the file content itself.
    • To use this path as a short link, prefix it with the base URL of the API (without the /graphql path).
    • The backend always returns the header Content-Disposition: attachment, which instructs browsers to download the file instead of displaying it inline.
    • Behind this short link, the file stream of the requested file is returned.
  • previewPath: A temporary relative short path to preview the file.
    • Example: /files/aZ3kTyPq
    • Unlike downloadPath, the backend does not include a Content-Disposition: attachment header. This allows browsers to try to display the file inline whenever possible.
    • For .csv, .xml, and .txt files, an HTML preview layout is generated when a tabular structure or valid XML is detected, so the browser displays a readable table.
    • Other file types such as PDFs and images are streamed as is.
    • It is valid for 10 minutes.
    • The GraphQL query returns only metadata and the link, not the file content itself.
    • To use this path as a short link, prefix it with the base URL of the API (without the /graphql path).
    • Behind this short link, a file stream is returned.

Link paths are consumed with a simple HTTP GET.
Build the URL by prefixing the downloadPath or previewPath with the API base URL (without /graphql).
The response is always a file stream, so the URL can be opened directly in a web browser.

Unlike standard GraphQL queries, which are always executed with a POST on the /graphql endpoint, link paths are consumed with a direct GET on /files/....
The comparison below highlights this difference:

HTTP URL Example Description
https://<apidomain>/graphql Standard GraphQL call (e.g., files or filesExport query via POST body).
https://<apidomain>/files/LqTJRFny Direct call to a link path to retrieve the file stream.
Errors
Status Error message
404 The link path has expired. Please request a new link and try again.
404 The associated file could not be found. It may have been removed.