attachInvoiceDocument mutation
attachInvoiceDocument 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 an invoice imported from the accounting system, as the invoice's
own PDF. Call it after you upload the accounting system's PDF with POST /api/v1/files.
An invoice has one PDF, keyed on the invoice and never on a number. The file becomes version 1 of a new document. When the invoice already has an active document of that kind, the file becomes that document's next version instead.
The document's kind and keys come from the invoice:
- An
INVOICEgives anINVOICEdocument, aCREDIT_NOTEaCREDIT_NOTEdocument, and anADVANCEaPROFORMA_INVOICEdocument. externalNumberis the invoice's number, andexternalIdis its id in its accounting system. Every new version brings them up to date.
It returns the same result as attachDocument.
Permissions
- Requires the
invoice.syncpermission, with the invoice in your API key's scope. - The upload (
POST /api/v1/files) requiresinvoice.sync(ororder.write), oremail.send. - Reading the document back (
document,Invoice.documents) requiresinvoice.read.
Repeated calls
requestId makes a retry after a lost response safe.
- The same
requestIdwith the same input (theinvoicereference as you sent it) returnsapplied: falseand the document as it is now. - The same
requestIdwith other input isCONFLICTwithextensions.reasonREQUEST_ID_REUSED. - The same bytes as the current version return
applied: false, and nothing changes.
Errors
| Code | Reason or field | When |
|---|---|---|
CONFLICT | INVOICE_REMOVED | The invoice was removed in its accounting system. A cancelled invoice is accepted. |
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 invoice | The invoice does not exist or your API key cannot see it. |
VALIDATION | field invoice | The reference names both an id and a source key, or neither. |
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:AttachInvoiceDocumentInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.