createSalesOrder mutation
createSalesOrder 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.
Creates a confirmed sales order from an order placed in an external source, such as an e-shop. Call it once per order, when the customer places the order.
The call runs in one transaction, and either all of it happens or none of it:
- MAX finds or adds the customer and their addresses.
- MAX resolves every item against the catalogue and keeps your prices as sent.
- MAX reserves stock.
- MAX records what was paid.
The new order has the status CONFIRMED. To change it later, use
updateSalesOrderAddresses, updateSalesOrderDetails,
updateSalesOrderItems, markSalesOrderPaid or
cancelSalesOrder.
Permissions
- Requires the
order.write,order.readandpartner.readpermissions. - Adding an address to the customer's address book also requires
partner.write. - Sending
externalIssuealso requiresstock.syncandintegration.read.
Repeated calls
source and externalId identify the order. A repeat with the same pair changes nothing and
returns the existing order with created: false. If the repeat differs from the first call,
it also returns the warning DUPLICATE_WITH_DIFFERENT_CONTENT. A repeat does not return the
first call's other warnings again: read SalesOrder.exceptions for the lasting problems.
Errors
MAX returns every input error that leaves nothing to store at once, each as a VALIDATION
error that names its field. Nothing is created.
Orders that need a review
MAX still creates an order that it can store but that a user in MAX must check. Each
problem is listed in the order's exceptions and returned as a warning with the same code.
When a problem blocks the order, the order is still CONFIRMED and its stock is reserved, but
it is blocked with the reason NEEDS_REVIEW until a user in MAX looks at it.
| Code | Blocks the order | What MAX does |
|---|---|---|
PAYMENT_METHOD_UNKNOWN | Yes | paymentMethod was not sent. MAX stores BANK_TRANSFER in its place. |
TOTAL_MISMATCH | Yes | expectedTotal differs from the MAX total. MAX keeps its own sums. |
LINE_TOTAL_MISMATCH | Yes | An item's lineTotal differs from the MAX line total. |
UNIT_UNKNOWN | Yes | An item's unit is not one of its product's units. MAX uses the base unit. |
PREFERRED_WAREHOUSE_IGNORED | Yes | preferredWarehouseId cannot be used. The order has no preferred warehouse. |
CARRIER_PROFILE_UNKNOWN | Yes | carrier names a well-formed pair that a fresh, authoritative Chameleoon catalogue does not contain. The order's carrier reads null until a user in MAX repairs the order. |
CARRIER_PROFILE_UNVERIFIED | Yes | MAX could not verify carrier against the catalogue. The order's carrier reads null until a user in MAX repairs the order. |
PRODUCT_NOT_FOUND | No | The line is kept unlinked. |
PRODUCT_ARCHIVED | No | The line is kept unlinked. |
UNIT_NOT_VERIFIED | No | The line is unlinked and you sent a unit. MAX cannot check the unit, so it ignores it and keeps the quantity in the product's base unit. |
PRODUCT_AMBIGUOUS | No | Several products carry the EAN. The line is kept unlinked. The warning names the products' SKUs, but only in this call and only to a caller that may read the catalogue. The stored exception carries the EAN and the number of products that carry it (data ean, count), so a user in MAX can find them by searching the EAN. |
SET_CONTENTS_MISSING | No | The product is a set sold as its components (setMode EXPLODED), but MAX cannot split it: the set has no components, a component is archived or is a set itself, or the quantity is not a whole number of sets. The data reason is NO_COMPONENTS, ARCHIVED_COMPONENT, NESTED_SET or FRACTIONAL_QUANTITY. The line is kept unlinked under its sku. |
VAT_DESTINATION_NOT_EU | No | vatDestinationCountry is not an EU state. The order has no stated VAT regime. |
A user links an unlinked line in MAX. A set's line links itself once its contents are fixed.
Warnings
These codes are warnings only. They describe this call only.
DUPLICATE_WITH_DIFFERENT_CONTENTCUSTOMER_MATCHED_BY_REGISTRATION_ID,CUSTOMER_MATCHED_BY_EMAIL,CUSTOMER_MATCHED_SEVERALITEM_CONVERTED_TO_CHARGE,ZERO_PRICE,ORIGINAL_PRICE_INCONSISTENTPAYMENT_REFERENCE_TAKENEXTERNAL_ISSUE_ITEM_UNLINKED(fielditems[i].externallyIssuedQuantity): the item is kept unlinked, so none of it was recorded as externally issued. Report it withreportExternalIssueonce a user in MAX links it.
External issue
externalIssue records, in the same transaction, that an externally managed warehouse already
took the order's goods off its stock with one of its documents. Its rules and errors are on
ExternalIssueInput.
Good to know
orderedAtis on your clock. The order'snumberandconfirmedAtare on the MAX clock.
An error whose path runs below this field does not mean the call failed: the order was placed, so do not retry. See
Mutation.
Arguments
input:CreateSalesOrderInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.