attachDocument mutation
attachDocument is a GraphQL mutation of the Chameleoon MAX API. Send it as POST https://max-api.chameleoon.sk/api/v1/graphql with your API key, see Chameleoon MAX.
Attaches an uploaded file to a sales order as a document of a kind. Call it after you upload
the file with POST /api/v1/files, for example to attach a delivery note or an invoice PDF.
The file becomes version 1 of a new document. When an active document of the same kind on the
order already has the same externalId (or, without one, the same externalNumber), the
file becomes that document's next version instead.
An invoice imported from the accounting system keeps its own PDF: attach it with
attachInvoiceDocument.
Permissions
Requires the order.write permission, with the order in your API key's scope.
Repeated calls
requestId makes a retry after a lost response safe.
- The same
requestIdwith the same input returnsapplied: falseand the document as it is now. - The same
requestIdwith other input isCONFLICTwithextensions.reasonREQUEST_ID_REUSED.
Errors
| Code | Reason or field | When |
|---|---|---|
CONFLICT | ORDER_STATUS | The order is not CONFIRMED, COMPLETED or CANCELLED. |
CONFLICT | INVOICE_REFERENCE_MISMATCH | An INVOICE's externalId or externalNumber differs from the order's invoice reference. extensions.field names the field. |
CONFLICT | FILE_ALREADY_ATTACHED | A version already took the file. |
CONFLICT | REQUEST_ID_REUSED | The requestId was used with other input. |
NOT_FOUND | field fileId | The file does not exist or has expired. |
NOT_FOUND | field salesOrder | The order does not exist or your API key cannot see it. |
Invoice documents
A document of kind INVOICE is bound to the order's invoice reference
(setSalesOrderInvoice).
- An
externalIdorexternalNumberyou leave out is taken from the reference. - One that differs from the reference is
CONFLICTwithextensions.reasonINVOICE_REFERENCE_MISMATCH. - When a linked invoice governs the order's reference, MAX compares only the number. A
different
externalIdis accepted and stored as given.
An error whose path runs below this field does not mean the call failed: the document was attached, so do not retry. See
Mutation.
Arguments
input:AttachDocumentInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.