# Writing data (mutations)


The operations that change data.

#### Errors below a mutation's result

An error whose path runs below a mutation's field, while the mutation's result is in `data`, is
not a failed call. It is a field your API key may not read (`FORBIDDEN_ROLE`,
`FORBIDDEN_SCOPE`), or a nested page that could not be read. That field is null, and the rest
of `data` is returned. The mutation happened: its result (for example `created`, `changed` or
`warnings`) is in `data`.

> Do not retry a mutation because of such an error. Retry rules apply only to an error at the
> mutation's own field (`data.<field>` is null and the error's path is `[<field>]`), or to a
> response without `data`.

## All mutations

### Orders

- [`createSalesOrder`](/chameleoon-max/mutation/create-sales-order) Creates a confirmed sales order from an order placed in an external source, such as an e-shop.
- [`markSalesOrderPaid`](/chameleoon-max/mutation/mark-sales-order-paid) Marks the order as paid in full.
- [`cancelSalesOrder`](/chameleoon-max/mutation/cancel-sales-order) Cancels the order and releases its reserved stock.
- [`updateSalesOrderAddresses`](/chameleoon-max/mutation/update-sales-order-addresses) Updates the order's billing address, delivery address or collection point with the external source's current values.
- [`updateSalesOrderDetails`](/chameleoon-max/mutation/update-sales-order-details) Updates the order's notes, contact, carrier and payment method with the external source's current values.
- [`updateSalesOrderItems`](/chameleoon-max/mutation/update-sales-order-items) Updates the order's items and charges to match the external source's current ones.
- [`reportSalesOrderItemWriteBack`](/chameleoon-max/mutation/report-sales-order-item-write-back) Reports the result of writing one of the order's goods lines back to the external source.
- [`setSalesOrderInvoice`](/chameleoon-max/mutation/set-sales-order-invoice) Records the invoice that another system issued for the order.

### Receipts

- [`createReceiptAdvice`](/chameleoon-max/mutation/create-receipt-advice) Creates and opens one receipt advice in a single step.
- [`updateReceiptAdvice`](/chameleoon-max/mutation/update-receipt-advice) Updates an OPEN receipt advice: removes, changes and adds lines, and changes its header terms and parameters.
- [`cancelReceiptAdvice`](/chameleoon-max/mutation/cancel-receipt-advice) Cancels an OPEN receipt advice that no receipt answers.
- [`setReceiptExternalRef`](/chameleoon-max/mutation/set-receipt-external-ref) Records the receipt's reference in an external source: the record that the external system made of the receipt.
- [`removeReceiptExternalRef`](/chameleoon-max/mutation/remove-receipt-external-ref) Removes the receipt's reference in an external source.

### Transfers

- [`createTransferAdvice`](/chameleoon-max/mutation/create-transfer-advice) Creates a transfer advice and opens it, in one transaction.
- [`updateTransferAdvice`](/chameleoon-max/mutation/update-transfer-advice) Updates an OPEN transfer advice in one transaction: all of it happens or none of it.
- [`cancelTransferAdvice`](/chameleoon-max/mutation/cancel-transfer-advice) Cancels an OPEN transfer advice that nothing has moved against, and releases its reservations.
- [`setTransferExternalRef`](/chameleoon-max/mutation/set-transfer-external-ref) Records the transfer's reference in an external source: the record that another system made of the transfer.
- [`removeTransferExternalRef`](/chameleoon-max/mutation/remove-transfer-external-ref) Removes the transfer's reference in an external source on the side you name.

### Products

- [`setProductVariantExternalRef`](/chameleoon-max/mutation/set-product-variant-external-ref) Records the variant's reference in an external source: the variant's id in that system under the id of its product there, such as an e-shop's variant id or…
- [`removeProductVariantExternalRef`](/chameleoon-max/mutation/remove-product-variant-external-ref) Removes the variant's reference in an external source.

### Partners

- [`setPartnerExternalRef`](/chameleoon-max/mutation/set-partner-external-ref) Records the partner's reference in an external source: the partner's id in that system, such as an e-shop's customer id or OBERON's firm id.
- [`removePartnerExternalRef`](/chameleoon-max/mutation/remove-partner-external-ref) Removes the partner's reference in an external source.

### Inventory

- [`syncStockLevels`](/chameleoon-max/mutation/sync-stock-levels) Sets the stock of an externally managed warehouse to the quantities that the external system that manages the warehouse reports.
- [`confirmStockInExternalSystem`](/chameleoon-max/mutation/confirm-stock-in-external-system) Records that the external system that manages the warehouse holds these receipts, issues and transfers up to their stockVersion, as of its own clock.

### Invoices

- [`attachInvoiceDocument`](/chameleoon-max/mutation/attach-invoice-document) Attaches an uploaded file to an invoice imported from the accounting system, as the invoice's own PDF.
- [`syncInvoice`](/chameleoon-max/mutation/sync-invoice) Writes the accounting system's document into MAX.
- [`removeInvoice`](/chameleoon-max/mutation/remove-invoice) Marks a document as deleted in the accounting system.
- [`updateInvoice`](/chameleoon-max/mutation/update-invoice) Updates the invoice's internal note.
- [`setInvoicePartner`](/chameleoon-max/mutation/set-invoice-partner) Sets, changes or clears the invoice's partner by hand.
- [`linkInvoice`](/chameleoon-max/mutation/link-invoice) Links the invoice to a MAX document your API key can see.
- [`unlinkInvoice`](/chameleoon-max/mutation/unlink-invoice) Removes the invoice's link to a MAX document your API key can see.

### Shipments

- [`shipFulfilment`](/chameleoon-max/mutation/ship-fulfilment) Marks a fulfilment as shipped by another system.

### Issues

- [`reportExternalIssue`](/chameleoon-max/mutation/report-external-issue) Records that an externally managed warehouse already took goods of the order off its stock with one of its own documents.
- [`setIssueExternalRef`](/chameleoon-max/mutation/set-issue-external-ref) Records the issue's reference in an external source: the record that the external system made of the issue.
- [`removeIssueExternalRef`](/chameleoon-max/mutation/remove-issue-external-ref) Removes the issue's reference in an external source.

### Documents

- [`attachDocument`](/chameleoon-max/mutation/attach-document) Attaches an uploaded file to a sales order as a document of a kind.
- [`addDocumentVersion`](/chameleoon-max/mutation/add-document-version) Makes an uploaded file the document's next version, which becomes its current version.
- [`removeDocument`](/chameleoon-max/mutation/remove-document) Removes a document.

### Assets

- [`createAsset`](/chameleoon-max/mutation/create-asset) Creates an asset from an image you uploaded.
- [`updateAsset`](/chameleoon-max/mutation/update-asset) Updates the asset's name or whether it is public.
- [`replaceAssetFile`](/chameleoon-max/mutation/replace-asset-file) Replaces the asset's image with a new upload.
- [`deleteAsset`](/chameleoon-max/mutation/delete-asset) Deletes the asset and its image, and returns the asset's MAX id.

### Print templates

- [`createPrintTemplate`](/chameleoon-max/mutation/create-print-template) Creates a print template.
- [`updatePrintTemplate`](/chameleoon-max/mutation/update-print-template) Updates a print template's name, language, body or default flag.
- [`deletePrintTemplate`](/chameleoon-max/mutation/delete-print-template) Deletes the print template and returns its MAX id.
- [`setPrintTemplateArchived`](/chameleoon-max/mutation/set-print-template-archived) Archives or restores a print template.
- [`copyPrintTemplate`](/chameleoon-max/mutation/copy-print-template) Copies a print template, or a MAX built-in template, under a new name.

### Email templates

- [`createEmailTemplate`](/chameleoon-max/mutation/create-email-template) Creates an e-mail template of the organisation.
- [`copyEmailTemplate`](/chameleoon-max/mutation/copy-email-template) Copies a built-in or organisation template to a new code.
- [`updateEmailTemplate`](/chameleoon-max/mutation/update-email-template) Updates the template's head: its name, resource kind and defaults.
- [`setEmailTemplateVariant`](/chameleoon-max/mutation/set-email-template-variant) Creates or replaces one variant of the template.
- [`removeEmailTemplateVariant`](/chameleoon-max/mutation/remove-email-template-variant) Removes one variant of the template.
- [`setEmailTemplateTexts`](/chameleoon-max/mutation/set-email-template-texts) Replaces the template's whole dictionary of texts.
- [`saveEmailTemplateDesign`](/chameleoon-max/mutation/save-email-template-design) Saves the design of a JSON template's one all-languages variant and replaces its whole dictionary, in one change.
- [`convertEmailTemplateToHtml`](/chameleoon-max/mutation/convert-email-template-to-html) Creates a new HTML template from a JSON one.
- [`deleteEmailTemplate`](/chameleoon-max/mutation/delete-email-template) Deletes the template and returns its code.

### Emails

- [`sendEmail`](/chameleoon-max/mutation/send-email) Renders an e-mail and queues it for delivery.
- [`sendTestEmail`](/chameleoon-max/mutation/send-test-email) Sends a template as a test to 1 to 5 addresses.

### Tags

- [`addSalesOrderTag`](/chameleoon-max/mutation/add-sales-order-tag) Puts a tag on the order.
- [`removeSalesOrderTag`](/chameleoon-max/mutation/remove-sales-order-tag) Takes a tag off the order.
- [`modifySalesOrderTags`](/chameleoon-max/mutation/modify-sales-order-tags) Adds, removes and clears several of the order's tags in one call, all or nothing.
- [`addInvoiceTag`](/chameleoon-max/mutation/add-invoice-tag) Puts a tag on the invoice.
- [`removeInvoiceTag`](/chameleoon-max/mutation/remove-invoice-tag) Takes a tag off the invoice.
- [`modifyInvoiceTags`](/chameleoon-max/mutation/modify-invoice-tags) Adds, removes and clears several of the invoice's tags in one call, all or nothing.
- [`modifyReceiptTags`](/chameleoon-max/mutation/modify-receipt-tags) Adds, removes and clears the receipt's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyIssueTags`](/chameleoon-max/mutation/modify-issue-tags) Adds, removes and clears the issue's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyTransferTags`](/chameleoon-max/mutation/modify-transfer-tags) Adds, removes and clears the transfer's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyReceiptAdviceTags`](/chameleoon-max/mutation/modify-receipt-advice-tags) Adds, removes and clears the receipt advice's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyTransferAdviceTags`](/chameleoon-max/mutation/modify-transfer-advice-tags) Adds, removes and clears the transfer advice's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyProductTags`](/chameleoon-max/mutation/modify-product-tags) Adds, removes and clears the product's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyPartnerTags`](/chameleoon-max/mutation/modify-partner-tags) Adds, removes and clears the partner's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`modifyLotTags`](/chameleoon-max/mutation/modify-lot-tags) Adds, removes and clears the lot's tags in one call, all or nothing -- as modifySalesOrderTags does for an order.
- [`createTag`](/chameleoon-max/mutation/create-tag) Creates a tag.
- [`updateTag`](/chameleoon-max/mutation/update-tag) Changes a live tag, named by its code.
- [`archiveTag`](/chameleoon-max/mutation/archive-tag) Archives a tag: it can no longer be added, and records that have it keep it.
- [`createTagGroup`](/chameleoon-max/mutation/create-tag-group) Creates a tag group: a set of tags with shared settings.
- [`updateTagGroup`](/chameleoon-max/mutation/update-tag-group) Changes a live tag group, named by its code.
- [`archiveTagGroup`](/chameleoon-max/mutation/archive-tag-group) Archives a tag group: its tags can no longer be added, and records that have them keep them.

### Integrations

- [`reportError`](/chameleoon-max/mutation/report-error) Reports that an external system failed to do something with a record in MAX.
