# Document type


A file kept with a sales order (such as an invoice or a delivery note) or with an invoice
imported from the accounting system (its PDF). A document has versions; the newest is the
current one.

## Fields

### id

[`UUID!`](/chameleoon-max/type/uuid)

The document's MAX id.

### kind

[`DocumentKind!`](/chameleoon-max/type/document-kind)

What the document is.

### title

`String`

The document's title.

### externalId

`String`

The issuing system's own id of the document.

### externalNumber

`String`

The document's number in the issuing system.

### createdAt

[`Time!`](/chameleoon-max/type/time)

When the document was created.

### updatedAt

[`Time!`](/chameleoon-max/type/time)

When its last version was added.

### versionCount

`Int!`

The number of versions. The current version has the highest number.

### file

[`DocumentFile!`](/chameleoon-max/type/document-file)

The current version's file.

### downloadUrl

`String`

Where to download the current version. The address stays the same across versions.

- The download still requires your API key, with the read permission of the document's
  target: `order.read` for a sales order's document, `invoice.read` for an invoice's.
- Null when MAX has no public address configured.

### versions

[`DocumentVersionConnection`](/chameleoon-max/type/document-version-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The document's versions, newest first.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page. Its
  cursors belong to this document's versions; any other connection refuses them.
- Null, with an error at its path, when its page cannot be read, for example because of a
  cursor of another parent. The rest of the response is returned.
- A page costs 2 + first (or last) × the cost of one node.

### salesOrder

[`SalesOrder`](/chameleoon-max/type/sales-order)

The sales order the document is kept with. Null for an invoice's document (see `invoice`), and
when your API key can no longer see the order. No error comes with the null.

### invoice

[`Invoice`](/chameleoon-max/type/invoice)

The invoice the document is kept with ([`attachInvoiceDocument`](/chameleoon-max/mutation/attach-invoice-document)). Null for a sales
order's document (see `salesOrder`), without the `invoice.read` permission, and when your API
key can no longer see the invoice. No error comes with the null.

## Used by

- [`document`](/chameleoon-max/query/document) (query)
- [`AddDocumentVersionResult`](/chameleoon-max/type/add-document-version-result)
- [`AttachDocumentResult`](/chameleoon-max/type/attach-document-result)
- [`DocumentConnection`](/chameleoon-max/type/document-connection)
- [`DocumentEdge`](/chameleoon-max/type/document-edge)
