syncInvoice mutation
syncInvoice 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.
Writes the accounting system's document into MAX. Call it whenever the document is created or changes in the accounting system, and always send the whole document.
The first call creates the invoice. Every later call replaces every field of the input, the
lines, the VAT summary and the settlements. The internal note and the tags, set in MAX or
through modifyInvoiceTags, are never touched.
Permissions
Requires the invoice.sync permission. MAX creates a partner only when your API key also has
the partner.write permission. Without invoice.read, the result's internalNote is null.
Repeated calls
source and externalId identify the document, so a retry is safe.
- A call with the same document writes nothing and returns
changed: false. - A call whose
sourceChangedAtis older than the one MAX holds writes nothing and returnschanged: falsewithreasonSTALE.
Errors
CONFLICTwithextensions.reasonKIND_CHANGEDwhenkindordirectiondiffers from the first call.VALIDATION, withextensions.fieldnaming the input, when the input is invalid. For example:sourceis unknown, archived or not of kindERP; on an issuedINVOICE,numberis over 100 characters orexternalIdover 200; correction fields are sent on a document that is not a credit note;supplierNumberorreceivedDateis sent on an issued invoice;partner.idnames a partner your API key cannot see; orlinksnames a document your API key cannot see.INTERNALwhen the invoice's links to sales orders kept changing during the call. Send the same request again.
Warnings
| Code | When |
|---|---|
PARTNER_MATCHED_BY_REGISTRATION_ID | MAX found the partner by the party's company registration number (IČO). |
PARTNER_MATCHED_BY_EMAIL | MAX found the partner by the party's e-mail. |
PARTNER_MATCHED_SEVERAL | Several partners matched. MAX took the oldest. |
PARTNER_NOT_CREATED | No partner matched, and MAX could not create one from the party, or your API key lacks partner.write. The invoice has no partner. |
ORDER_MATCHED_SEVERAL | orderNumber names several sales orders. MAX linked none. |
LINE_NOT_MATCHED | No code of the line matched a product variant. |
Good to know
- Dates are calendar days. MAX keeps the date part of each value and returns it as midnight UTC.
- When an issued invoice's
orderNumberchanges, MAX removes itsAUTOlinks to sales orders that the new number does not name. - This call may change a linked sales order's invoice reference, which follows the order's
governing invoice (
SalesOrder.governingInvoice).
An error whose path runs below this field does not mean the call failed: the invoice was written, so do not retry. See
Mutation.
Arguments
input:SyncInvoiceInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.